if (!localFS.getFileStatus(local).isDir()) {
throw new IOException("Path " + local + " is not a directory");
}
try {
while (harReader.hasNext()) {
HarStatus harStatus = harReader.getNext();
String harPath = harStatus.getName();
// skip top level dir
if (harPath.equals(Path.SEPARATOR)) {
continue;
}
String relativePath = harPath.substring(1);
Path output = new Path(local, relativePath);
if (harStatus.isDir()) {
localFS.mkdirs(output);
} else {
OutputStream outputStream = null;
FSDataInputStream inputStream = null;
try {
outputStream = localFS.create(output);
Path partFile = new Path(archivePath, harStatus.getPartName());
inputStream = new HarFSDataInputStream(fs, partFile,
harStatus.getStartIndex(), harStatus.getLength(), conf.getInt("io.file.buffer.size", 4096));
IOUtils.copyBytes(inputStream, outputStream, conf);
} finally {
if (outputStream != null) {
outputStream.close();
}