authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-01-19 16:53:08-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-01-19 16:53:08-05:00
log890bf001dbd4120ca8660d0e63594aa27d2a683f
treed1ed77a2f117b5dbb891c4c0de049d8ea8b280a0
parent9f5c0b6e6049fa53807be3334ce7ce96de2d24b4

os_rename uses MoveFileEx on windows


1 files changed, 6 insertions(+), 8 deletions(-)

src/os.cpp+6-8
...@@ -797,17 +797,15 @@ int os_rename(Buf *src_path, Buf *dest_path) {...@@ -797,17 +797,15 @@ int os_rename(Buf *src_path, Buf *dest_path) {
797 if (buf_eql_buf(src_path, dest_path)) {797 if (buf_eql_buf(src_path, dest_path)) {
798 return 0;798 return 0;
799 }799 }
800#if defined(ZIG_OS_WINDOWS)
801 if (!MoveFileEx(buf_ptr(dest_path), buf_ptr(src_path), MOVEFILE_REPLACE_EXISTING)) {
802 return ErrorFileSystem;
803 }
804#else
800 if (rename(buf_ptr(src_path), buf_ptr(dest_path)) == -1) {805 if (rename(buf_ptr(src_path), buf_ptr(dest_path)) == -1) {
801 // Windows requires the dest path to be missing
802 if (errno == EACCES) {
803 remove(buf_ptr(dest_path));
804 if (rename(buf_ptr(src_path), buf_ptr(dest_path)) == -1) {
805 return ErrorFileSystem;
806 }
807 return 0;
808 }
809 return ErrorFileSystem;806 return ErrorFileSystem;
810 }807 }
808#endif
811 return 0;809 return 0;
812}810}
813811