mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
os_rename uses MoveFileEx on windows
This commit is contained in:
parent
9f5c0b6e60
commit
890bf001db
16
src/os.cpp
16
src/os.cpp
@ -797,17 +797,15 @@ int os_rename(Buf *src_path, Buf *dest_path) {
|
||||
if (buf_eql_buf(src_path, dest_path)) {
|
||||
return 0;
|
||||
}
|
||||
if (rename(buf_ptr(src_path), buf_ptr(dest_path)) == -1) {
|
||||
// Windows requires the dest path to be missing
|
||||
if (errno == EACCES) {
|
||||
remove(buf_ptr(dest_path));
|
||||
if (rename(buf_ptr(src_path), buf_ptr(dest_path)) == -1) {
|
||||
return ErrorFileSystem;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#if defined(ZIG_OS_WINDOWS)
|
||||
if (!MoveFileEx(buf_ptr(dest_path), buf_ptr(src_path), MOVEFILE_REPLACE_EXISTING)) {
|
||||
return ErrorFileSystem;
|
||||
}
|
||||
#else
|
||||
if (rename(buf_ptr(src_path), buf_ptr(dest_path)) == -1) {
|
||||
return ErrorFileSystem;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user