if (srcs.length > 1 && !isDstDir) {
throw new IllegalArgumentException("When moving multiple files, destination should be a directory.");
}
for (Path s : srcs) {
if (!srcFs.rename(s, dstPath)) {
FileStatus srcFstatus = null;
FileStatus dstFstatus = null;
try {
srcFstatus = srcFs.getFileStatus(s);
} catch (FileNotFoundException e) {
// ignore
}
try {
dstFstatus = dstFs.getFileStatus(dstPath);
} catch (IOException e) {
}
if ((srcFstatus != null) && (dstFstatus != null)) {
if (srcFstatus.isDir() && !dstFstatus.isDir()) {
throw new IllegalArgumentException("cannot overwrite non directory " + dstPath
+ " with directory " + s);
}
}
throw new HadoopException("Failed to rename " + s + " to " + dstPath);