This commit is contained in:
Reinhard Pointner 2016-05-16 03:34:26 +08:00
parent f28800a3a9
commit 83dc1c40f6
2 changed files with 2 additions and 6 deletions

View File

@ -324,7 +324,7 @@ class RenameAction extends AbstractAction {
File source = mapping.getKey(); File source = mapping.getKey();
File destination = resolve(mapping.getKey(), mapping.getValue()); File destination = resolve(mapping.getKey(), mapping.getValue());
if (!source.equals(destination) || (source.equals(destination) && !source.getName().equals(destination.getName()))) { if (!equalsCaseSensitive(source, destination)) {
action.rename(source, destination); action.rename(source, destination);
} }

View File

@ -72,7 +72,7 @@ public final class FileUtilities {
// on Windows, use ATOMIC_MOVE which allows us to rename files even if only lower/upper-case changes (without ATOMIC_MOVE the operation would be ignored) // on Windows, use ATOMIC_MOVE which allows us to rename files even if only lower/upper-case changes (without ATOMIC_MOVE the operation would be ignored)
// but ATOMIC_MOVE can only work for files on the same drive, if that is not the case there is no point trying move with ATOMIC_MOVE // but ATOMIC_MOVE can only work for files on the same drive, if that is not the case there is no point trying move with ATOMIC_MOVE
if (isWindows() && source.equals(destination)) { if (source.equals(destination)) {
try { try {
return Files.move(source.toPath(), destination.toPath(), StandardCopyOption.ATOMIC_MOVE).toFile(); return Files.move(source.toPath(), destination.toPath(), StandardCopyOption.ATOMIC_MOVE).toFile();
} catch (AtomicMoveNotSupportedException e) { } catch (AtomicMoveNotSupportedException e) {
@ -246,10 +246,6 @@ public final class FileUtilities {
return UTF_8.decode(data).toString(); return UTF_8.decode(data).toString();
} }
public static boolean isWindows() {
return '\\' == File.separatorChar;
}
public static boolean equalsCaseSensitive(File a, File b) { public static boolean equalsCaseSensitive(File a, File b) {
return a.getPath().equals(b.getPath()); return a.getPath().equals(b.getPath());
} }