HADOOP-10075. addendum to fix compilation on Windows
This commit is contained in:
parent
76a1042980
commit
ebb88231f8
@ -24,10 +24,12 @@
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,8 +103,10 @@ public void accept(Path path) {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
File outFile = new File(outputDir, path.toFile().getCanonicalPath()
|
File outFile = new File(outputDir, path.toFile().getCanonicalPath()
|
||||||
.replaceFirst(inputDir.getCanonicalPath(), "") + ".gz");
|
.replaceFirst(Matcher.quoteReplacement(
|
||||||
outFile.getParentFile().mkdirs();
|
inputDir.getCanonicalPath()), "") + ".gz");
|
||||||
|
if (outFile.getParentFile().isDirectory() ||
|
||||||
|
outFile.getParentFile().mkdirs()) {
|
||||||
try (
|
try (
|
||||||
GZIPOutputStream os = new GZIPOutputStream(
|
GZIPOutputStream os = new GZIPOutputStream(
|
||||||
new FileOutputStream(outFile));
|
new FileOutputStream(outFile));
|
||||||
@ -110,8 +114,10 @@ public void accept(Path path) {
|
|||||||
) {
|
) {
|
||||||
getLog().info("Compressing " + path + " to " + outFile);
|
getLog().info("Compressing " + path + " to " + outFile);
|
||||||
IOUtils.copy(is, os);
|
IOUtils.copy(is, os);
|
||||||
} catch (Throwable t) {
|
}
|
||||||
this.throwable = t;
|
} else {
|
||||||
|
throw new IOException("Directory " + outFile.getParent()
|
||||||
|
+ " does not exist or was unable to be created");
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
this.throwable = t;
|
this.throwable = t;
|
||||||
|
Loading…
Reference in New Issue
Block a user