use of hudson.org.apache.tools.tar.TarInputStream in project hudson-2.x by hudson.
the class FilePath method readFromTar.
/**
* Reads from a tar stream and stores obtained files to the base dir.
*/
private static void readFromTar(String name, File baseDir, InputStream in) throws IOException {
TarInputStream t = new TarInputStream(in);
try {
TarEntry te;
while ((te = t.getNextEntry()) != null) {
File f = new File(baseDir, te.getName());
if (te.isDirectory()) {
f.mkdirs();
} else {
File parent = f.getParentFile();
if (parent != null)
parent.mkdirs();
IOUtils.copy(t, f);
f.setLastModified(te.getModTime().getTime());
int mode = te.getMode() & 0777;
if (// be defensive
mode != 0 && !Functions.isWindows())
_chmod(f, mode);
}
}
} catch (IOException e) {
throw new IOException2("Failed to extract " + name, e);
} finally {
t.close();
}
}
Aggregations