feat: new "copyToDir" where inFilename/outFilename differs

This commit is contained in:
Connor Tumbleson 2019-04-26 11:14:08 -04:00
parent 73ac0d96fb
commit d068c3e481

View File

@ -41,17 +41,19 @@ public class DirUtil {
public static void copyToDir(Directory in, Directory out, String fileName)
throws DirectoryException {
copyToDir(in, out, fileName, fileName);
}
public static void copyToDir(Directory in, Directory out, String inFile, String outFile)
throws DirectoryException {
try {
if (in.containsDir(fileName)) {
// TODO: remove before copying
in.getDir(fileName).copyToDir(out.createDir(fileName));
if (in.containsDir(inFile)) {
in.getDir(inFile).copyToDir(out.createDir(outFile));
} else {
BrutIO.copyAndClose(in.getFileInput(fileName),
out.getFileOutput(fileName));
BrutIO.copyAndClose(in.getFileInput(inFile), out.getFileOutput(outFile));
}
} catch (IOException ex) {
throw new DirectoryException(
"Error copying file: " + fileName, ex);
throw new DirectoryException("Error copying file: " + inFile, ex);
}
}