in src/main/org/apache/ant/compress/taskdefs/Un7z.java [48:104]
protected void expandFile(FileUtils fileUtils, File srcF, File dir) {
if (!srcF.exists()) {
throw new BuildException("Unable to expand " + srcF
+ " as the file does not exist",
getLocation());
}
log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
FileNameMapper mapper = getMapper();
SevenZFile outer = null;
try {
final SevenZFile zf = outer = new SevenZFile(srcF);
boolean empty = true;
SevenZArchiveEntry ze = zf.getNextEntry();
while (ze != null) {
empty = false;
/* TODO implement canReadEntryData in CC
if (getSkipUnreadableEntries() && !zf.canReadEntryData(ze)) {
log(Messages.skippedIsUnreadable(ze));
continue;
}
*/
log("extracting " + ze.getName(), Project.MSG_DEBUG);
try (InputStream is = new InputStream() {
@Override
public int read() throws IOException {
return zf.read();
}
@Override
public int read(byte[] b) throws IOException {
return zf.read(b);
}
}) {
extractFile(fileUtils, srcF, dir, is,
ze.getName(), ze.getLastModifiedDate(),
ze.isDirectory(), mapper);
}
ze = zf.getNextEntry();
}
if (empty && getFailOnEmptyArchive()) {
throw new BuildException("archive '" + srcF + "' is empty");
}
log("expand complete", Project.MSG_VERBOSE);
} catch (IOException ioe) {
throw new BuildException(
"Error while expanding " + srcF.getPath()
+ "\n" + ioe.toString(),
ioe);
} finally {
if (outer != null) {
try {
outer.close();
} catch (IOException ex) {
// swallow
}
}
}
}