/** * @param f An Archive file to read. * @return An ArchiveReader * @throws IOException */ public static ArchiveReader get(final File f) throws IOException { return ArchiveReaderFactory.factory.getArchiveReader(f); }
protected ArchiveReader getArchiveReader(final URL u) throws IOException { // If url represents a local file then return file it points to. if (u.getPath() != null) { // TODO: Add scheme check and host check. File f = new File(u.getPath()); if (f.exists()) { return get(f, 0); } } String scheme = u.getProtocol(); if (scheme.startsWith("http") || scheme.equals("s3")) { // Try streaming if http or s3 URLs rather than copying local // and then reading (Passing an offset will get us an Reader // that wraps a Stream). return get(u, 0); } return makeARCLocal(u.openConnection()); }
".tmp"); addUserAgent((HttpURLConnection)connection); connection.connect(); try { reader = get(localFile, 0); } catch (IOException e) { localFile.delete();
protected ArchiveReader getArchiveReader(final URL f, final long offset) throws IOException { // Get URL connection. URLConnection connection = f.openConnection(); if (connection instanceof HttpURLConnection) { addUserAgent((HttpURLConnection)connection); } if (offset != 0) { // Use a Range request (Assumes HTTP 1.1 on other end). If // length >= 0, add open-ended range header to the request. Else, // because end-byte is inclusive, subtract 1. connection.addRequestProperty("Range", "bytes=" + offset + "-"); // TODO: should actually verify that server respected 'Range' request // (spec allows them to ignore; 206 response or Content-Range header // should be present if Range satisfied; multipart/byteranges could be // a problem). } return getArchiveReader(f.toString(), connection.getInputStream(), (offset == 0)); }
protected ArchiveReader getArchiveReader(final URL u) throws IOException { // If url represents a local file then return file it points to. if (u.getPath() != null) { // TODO: Add scheme check and host check. File f = new File(u.getPath()); if (f.exists()) { return get(f, 0); } } String scheme = u.getProtocol(); if (scheme.startsWith("http") || scheme.equals("s3")) { // Try streaming if http or s3 URLs rather than copying local // and then reading (Passing an offset will get us an Reader // that wraps a Stream). return get(u, 0); } return makeARCLocal(u.openConnection()); }
".tmp"); addUserAgent((HttpURLConnection)connection); connection.connect(); try { reader = get(localFile, 0); } catch (IOException e) { localFile.delete();
protected ArchiveReader getArchiveReader(final URL f, final long offset) throws IOException { // Get URL connection. URLConnection connection = f.openConnection(); if (connection instanceof HttpURLConnection) { addUserAgent((HttpURLConnection)connection); } if (offset != 0) { // Use a Range request (Assumes HTTP 1.1 on other end). If // length >= 0, add open-ended range header to the request. Else, // because end-byte is inclusive, subtract 1. connection.addRequestProperty("Range", "bytes=" + offset + "-"); // TODO: should actually verify that server respected 'Range' request // (spec allows them to ignore; 206 response or Content-Range header // should be present if Range satisfied; multipart/byteranges could be // a problem). } return getArchiveReader(f.toString(), connection.getInputStream(), (offset == 0)); }
protected ArchiveReader getArchiveReader(final URL u) throws IOException { // If url represents a local file then return file it points to. if (u.getPath() != null) { // TODO: Add scheme check and host check. File f = new File(u.getPath()); if (f.exists()) { return get(f, 0); } } String scheme = u.getProtocol(); if (scheme.startsWith("http") || scheme.equals("s3")) { // Try streaming if http or s3 URLs rather than copying local // and then reading (Passing an offset will get us an Reader // that wraps a Stream). return get(u, 0); } return makeARCLocal(u.openConnection()); }
".tmp"); addUserAgent((HttpURLConnection)connection); connection.connect(); try { reader = get(localFile, 0); } catch (IOException e) { localFile.delete();
/** * @param f An Archive file to read. * @param offset Have returned Reader set to start reading at this offset. * @return An ArchiveReader * @throws IOException */ public static ArchiveReader get(final File f, final long offset) throws IOException { return ArchiveReaderFactory.factory.getArchiveReader(f, offset); }
protected ArchiveReader getArchiveReader(final URL f, final long offset) throws IOException { // Get URL connection. URLConnection connection = f.openConnection(); if (connection instanceof HttpURLConnection) { addUserAgent((HttpURLConnection)connection); } if (offset != 0) { // Use a Range request (Assumes HTTP 1.1 on other end). If // length >= 0, add open-ended range header to the request. Else, // because end-byte is inclusive, subtract 1. connection.addRequestProperty("Range", "bytes=" + offset + "-"); // TODO: should actually verify that server respected 'Range' request // (spec allows them to ignore; 206 response or Content-Range header // should be present if Range satisfied; multipart/byteranges could be // a problem). } return getArchiveReader(f.toString(), connection.getInputStream(), (offset == 0)); }
private boolean nextFile() throws IOException { currentPath++; if (currentPath >= paths.length) { return false; } // Output the archive filename, to help with debugging: log.info("Opening nextFile: " + paths[currentPath]); // Set up the ArchiveReader: this.status = this.filesystem.getFileStatus(paths[currentPath]); datainputstream = this.filesystem.open(paths[currentPath]); arcreader = (ArchiveReader) ArchiveReaderFactory.get( paths[currentPath].getName(), datainputstream, true); // Set to strict reading, in order to cope with malformed archive files // which cause an infinite loop otherwise. arcreader.setStrict(true); // Get the iterator: iterator = arcreader.iterator(); this.archiveName = paths[currentPath].getName(); return true; }
/** * Get an Archive file Reader on passed path or url. * Does primitive heuristic figuring if path or URL. * @param arcFileOrUrl File path or URL pointing at an Archive file. * @return An Archive file Reader. * @throws IOException * @throws MalformedURLException * @throws IOException */ public static ArchiveReader get(final String arcFileOrUrl) throws MalformedURLException, IOException { return ArchiveReaderFactory.factory.getArchiveReader(arcFileOrUrl); }
private boolean nextFile() throws IOException { currentPath++; if (currentPath >= paths.length) { return false; } // Output the archive filename, to help with debugging: log.info("Opening nextFile: " + paths[currentPath]); // Set up the ArchiveReader: this.status = this.filesystem.getFileStatus(paths[currentPath]); datainputstream = this.filesystem.open(paths[currentPath]); arcreader = (ArchiveReader) ArchiveReaderFactory .get(paths[currentPath].getName(), datainputstream, true); // Set to strict reading, in order to cope with malformed archive files // which cause an infinite loop otherwise. arcreader.setStrict(true); // Get the iterator: iterator = arcreader.iterator(); this.archiveName = paths[currentPath].getName(); return true; }
/** * Get an Archive file Reader on passed path or url. * Does primitive heuristic figuring if path or URL. * @param arcFileOrUrl File path or URL pointing at an Archive file. * @return An Archive file Reader. * @throws IOException * @throws MalformedURLException * @throws IOException */ public static ArchiveReader get(final String arcFileOrUrl) throws MalformedURLException, IOException { return ArchiveReaderFactory.factory.getArchiveReader(arcFileOrUrl); }
private boolean nextFile() throws IOException { currentPath++; if (currentPath >= paths.length) { return false; } // Output the archive filename, to help with debugging: log.info("Opening nextFile: " + paths[currentPath]); // Set up the ArchiveReader: this.status = this.filesystem.getFileStatus(paths[currentPath]); datainputstream = this.filesystem.open(paths[currentPath]); arcreader = (ArchiveReader) ArchiveReaderFactory .get(paths[currentPath].getName(), datainputstream, true); // Set to strict reading, in order to cope with malformed archive files // which cause an infinite loop otherwise. arcreader.setStrict(true); // Get the iterator: iterator = arcreader.iterator(); this.archiveName = paths[currentPath].getName(); return true; }
/** * @param f An Archive file to read. * @param offset Have returned Reader set to start reading at this offset. * @return An ArchiveReader * @throws IOException */ public static ArchiveReader get(final File f, final long offset) throws IOException { return ArchiveReaderFactory.factory.getArchiveReader(f, offset); }