Skip to content

Commit 69219b7

Browse files
[FIX] XQuery, file:copy: preserve capitalization of the target path
1 parent 2b7d7bc commit 69219b7

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

basex-core/src/main/java/org/basex/query/func/file/FileCopy.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ public static void relocate(final Path src, final Path trg, final boolean copy,
7777
if(copy) {
7878
Files.copy(src, trg, StandardCopyOption.REPLACE_EXISTING);
7979
} else {
80-
Files.move(src, trg, StandardCopyOption.REPLACE_EXISTING);
80+
// Windows: preserve capitalization of the target path
81+
if(src.getFileName().toString().equalsIgnoreCase(trg.getFileName().toString())) {
82+
Path temp = Files.createTempFile(src.getParent(), null, null);
83+
Files.move(src, temp, StandardCopyOption.REPLACE_EXISTING);
84+
Files.move(temp, trg);
85+
} else {
86+
Files.move(src, trg, StandardCopyOption.REPLACE_EXISTING);
87+
}
8188
}
8289
}
8390
}

0 commit comments

Comments
 (0)