longName.write(SMALL_BUF, 0, length); getNextEntry(); if (currEntry == null) {
private void paxHeaders() throws IOException { Map<String, String> headers = parsePaxHeaders(this); getNextEntry(); // Get the actual file entry applyPaxHeadersToCurrentEntry(headers); }
@Override public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOException { ArrayList<String> names = new ArrayList<>(); try (TarInputStream zis = new TarInputStream(src.getStream())) { TarEntry entry; while ((entry = zis.getNextEntry()) != null) { String name = entry.getName(); names.add(name); if (xrefOut != null) { Util.htmlize(name, xrefOut); xrefOut.append("<br/>"); } } } doc.add(new OGKTextField(QueryBuilder.FULL, new IteratorReader(names))); } }
/** * fetches information from the named entry inside the archive. */ @Override protected void fetchEntry() { Resource archive = getArchive(); try (TarInputStream i = new TarInputStream(archive.getInputStream())) { TarEntry te = null; while ((te = i.getNextEntry()) != null) { if (te.getName().equals(getName())) { setEntry(te); return; } } } catch (IOException e) { log(e.getMessage(), Project.MSG_DEBUG); throw new BuildException(e); } setEntry(null); }
try { TarEntry entry = null; while ((entry = ti.getNextEntry()) != null) { Resource r = new TarResource(src, entry); String name = entry.getName();
/** * Return an InputStream for reading the contents of this Resource. * @return an InputStream object. * @throws IOException if the tar file cannot be opened, * or the entry cannot be read. */ @Override public InputStream getInputStream() throws IOException { if (isReference()) { return getCheckedRef().getInputStream(); } Resource archive = getArchive(); final TarInputStream i = new TarInputStream(archive.getInputStream()); TarEntry te; while ((te = i.getNextEntry()) != null) { if (te.getName().equals(getName())) { return i; } } FileUtils.close(i); throw new BuildException("no entry " + getName() + " in " + getArchive()); }
/** * @since Ant 1.7 */ private void expandStream(String name, InputStream stream, File dir) throws IOException { try (TarInputStream tis = new TarInputStream( compression.decompress(name, new BufferedInputStream(stream)), getEncoding())) { log("Expanding: " + name + " into " + dir, Project.MSG_INFO); boolean empty = true; FileNameMapper mapper = getMapper(); TarEntry te; while ((te = tis.getNextEntry()) != null) { empty = false; extractFile(FileUtils.getFileUtils(), null, dir, tis, te.getName(), te.getModTime(), te.isDirectory(), mapper); } if (empty && getFailOnEmptyArchive()) { throw new BuildException("archive '%s' is empty", name); } log("expand complete", Project.MSG_VERBOSE); } }
public static void decompressTarGz(File tarGzFile, File destDir) { try { IOUtils.forceMkdir(destDir); TarInputStream tin = new TarInputStream(new GZIPInputStream(new FileInputStream(tarGzFile))); TarEntry tarEntry = tin.getNextEntry(); while (tarEntry != null) { File destPath = new File(destDir, tarEntry.getName()); if (tarEntry.isDirectory()) { IOUtils.forceMkdir(destPath); } else { FileOutputStream fout = new FileOutputStream(destPath); tin.copyEntryContents(fout); fout.close(); } tarEntry = tin.getNextEntry(); } tin.close(); } catch (IOException e) { throw new UncheckedIOException(e); } }
tarFile))); TarEntry tarEntry = tin.getNextEntry(); tarEntry = tin.getNextEntry();
@Override public ArchiveEntry getNextEntry(boolean calculateSize) { try { TarEntry entry = in.getNextEntry(); if (entry != null) { return new DefaultArchiveEntry(entry.getName(), entry.getSize(), entry.getModTime().getTime()); } } catch (IOException e) { LOGGER.error("Failed reading entries in file " + file.getAbsolutePath(), e); } return null; }
protected void getFileContent(Launcher launcher, String containerId, String filename, OutputStream outputStream) throws IOException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder() .add("cp", containerId + ":" + filename, "-"); ByteArrayOutputStream out = new ByteArrayOutputStream(); int status = launchDockerCLI(launcher, args) .stdout(out).stderr(launcher.getListener().getLogger()).join(); if (status != 0) { throw new IOException("Failed to get file"); } TarInputStream tar = new TarInputStream(new ByteArrayInputStream(out.toByteArray())); tar.getNextEntry(); tar.copyEntryContents(outputStream); tar.close(); }
protected void getFileContent(Launcher launcher, String containerId, String filename, OutputStream outputStream) throws IOException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder() .add("cp", containerId + ":" + filename, "-"); ByteArrayOutputStream out = new ByteArrayOutputStream(); int status = launchDockerCLI(launcher, args) .stdout(out).stderr(launcher.getListener().getLogger()).join(); if (status != 0) { throw new IOException("Failed to get file"); } TarInputStream tar = new TarInputStream(new ByteArrayInputStream(out.toByteArray())); tar.getNextEntry(); tar.copyEntryContents(outputStream); tar.close(); }
private void untarTo(InputStream source, File path) throws IOException { TarInputStream is = new TarInputStream(source); TarEntry entry = null; try { while (null != (entry = is.getNextEntry())) { File target = new File(path, entry.getName()); ensureParentDirectory(target); if (entry.isDirectory()) { target.mkdirs(); } else { if (target.exists()) { target.delete(); } FileOutputStream os = new FileOutputStream(target); try { is.copyEntryContents(os); } finally { finallyClose(os); } } } } finally { finallyClose(is); } } public String getName() {
entry = tar_in.getNextEntry(); while (entry != null) { if (!didReplacement && entry = tar_in.getNextEntry();
private void processTar(InputStream is) throws Exception { TarInputStream inputStream = new TarInputStream(is); try { TarEntry inputEntry = null; do { inputEntry = inputStream.getNextEntry(); if (inputEntry != null && !inputEntry.isDirectory()) { processEntry(inputEntry.getName(), inputStream, (int) inputEntry.getSize()); } } while (inputEntry != null && !abort); } finally { if (inputStream != null) { inputStream.close(); } } }