HADOOP-14434. Use MoveFileEx to allow renaming a file when the destination exists. Contributed by Lukas Majercak
This commit is contained in:
parent
eb7791b474
commit
ef9e536a71
|
@ -1204,7 +1204,7 @@ done:
|
||||||
if (!src) goto done; // exception was thrown
|
if (!src) goto done; // exception was thrown
|
||||||
dst = (LPCWSTR) (*env)->GetStringChars(env, jdst, NULL);
|
dst = (LPCWSTR) (*env)->GetStringChars(env, jdst, NULL);
|
||||||
if (!dst) goto done; // exception was thrown
|
if (!dst) goto done; // exception was thrown
|
||||||
if (!MoveFile(src, dst)) {
|
if (!MoveFileEx(src, dst, MOVEFILE_REPLACE_EXISTING)) {
|
||||||
throw_ioe(env, GetLastError());
|
throw_ioe(env, GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -536,7 +536,9 @@ public class TestNativeIO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileUtils.deleteQuietly(TEST_DIR);
|
// Test renaming to an existing file
|
||||||
|
assertTrue(targetFile.exists());
|
||||||
|
NativeIO.renameTo(sourceFile, targetFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=10000)
|
@Test(timeout=10000)
|
||||||
|
|
Loading…
Reference in New Issue