| ... | @@ -776,7 +776,8 @@ Error os_fetch_file(FILE *f, Buf *out_buf) { | ... | @@ -776,7 +776,8 @@ Error os_fetch_file(FILE *f, Buf *out_buf) { |
| 776 | | 776 | |
| 777 | Error os_file_exists(Buf *full_path, bool *result) { | 777 | Error os_file_exists(Buf *full_path, bool *result) { |
| 778 | #if defined(ZIG_OS_WINDOWS) | 778 | #if defined(ZIG_OS_WINDOWS) |
| 779 | *result = GetFileAttributes(buf_ptr(full_path)) != INVALID_FILE_ATTRIBUTES; | 779 | PathSpace path_space = slice_to_prefixed_file_w({ (uint8_t*)buf_ptr(full_path), buf_len(full_path) }); |
| | 780 | *result = GetFileAttributesW(&path_space.data.items[0]) != INVALID_FILE_ATTRIBUTES; |
| 780 | return ErrorNone; | 781 | return ErrorNone; |
| 781 | #else | 782 | #else |
| 782 | *result = access(buf_ptr(full_path), F_OK) != -1; | 783 | *result = access(buf_ptr(full_path), F_OK) != -1; |
| ... | @@ -1333,7 +1334,9 @@ Error os_rename(Buf *src_path, Buf *dest_path) { | ... | @@ -1333,7 +1334,9 @@ Error os_rename(Buf *src_path, Buf *dest_path) { |
| 1333 | return ErrorNone; | 1334 | return ErrorNone; |
| 1334 | } | 1335 | } |
| 1335 | #if defined(ZIG_OS_WINDOWS) | 1336 | #if defined(ZIG_OS_WINDOWS) |
| 1336 | if (!MoveFileExA(buf_ptr(src_path), buf_ptr(dest_path), MOVEFILE_REPLACE_EXISTING)) { | 1337 | PathSpace src_path_space = slice_to_prefixed_file_w({ (uint8_t*)buf_ptr(src_path), buf_len(src_path) }); |
| | 1338 | PathSpace dest_path_space = slice_to_prefixed_file_w({ (uint8_t*)buf_ptr(dest_path), buf_len(dest_path) }); |
| | 1339 | if (!MoveFileExW(&src_path_space.data.items[0], &dest_path_space.data.items[0], MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH)) { |
| 1337 | return ErrorFileSystem; | 1340 | return ErrorFileSystem; |
| 1338 | } | 1341 | } |
| 1339 | #else | 1342 | #else |
| ... | @@ -2014,8 +2017,8 @@ Error os_self_exe_shared_libs(ZigList<Buf *> &paths) { | ... | @@ -2014,8 +2017,8 @@ Error os_self_exe_shared_libs(ZigList<Buf *> &paths) { |
| 2014 | | 2017 | |
| 2015 | Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool need_write, uint32_t mode) { | 2018 | Error os_file_open_rw(Buf *full_path, OsFile *out_file, OsFileAttr *attr, bool need_write, uint32_t mode) { |
| 2016 | #if defined(ZIG_OS_WINDOWS) | 2019 | #if defined(ZIG_OS_WINDOWS) |
| 2017 | // TODO use CreateFileW | 2020 | PathSpace path_space = slice_to_prefixed_file_w({ (uint8_t*)buf_ptr(full_path), buf_len(full_path) }); |
| 2018 | HANDLE result = CreateFileA(buf_ptr(full_path), | 2021 | HANDLE result = CreateFileW(&path_space.data.items[0], |
| 2019 | need_write ? (GENERIC_READ|GENERIC_WRITE) : GENERIC_READ, | 2022 | need_write ? (GENERIC_READ|GENERIC_WRITE) : GENERIC_READ, |
| 2020 | need_write ? 0 : FILE_SHARE_READ, | 2023 | need_write ? 0 : FILE_SHARE_READ, |
| 2021 | nullptr, | 2024 | nullptr, |
| ... | @@ -2119,8 +2122,9 @@ Error os_file_open_w(Buf *full_path, OsFile *out_file, OsFileAttr *attr, uint32_ | ... | @@ -2119,8 +2122,9 @@ Error os_file_open_w(Buf *full_path, OsFile *out_file, OsFileAttr *attr, uint32_ |
| 2119 | | 2122 | |
| 2120 | Error os_file_open_lock_rw(Buf *full_path, OsFile *out_file) { | 2123 | Error os_file_open_lock_rw(Buf *full_path, OsFile *out_file) { |
| 2121 | #if defined(ZIG_OS_WINDOWS) | 2124 | #if defined(ZIG_OS_WINDOWS) |
| | 2125 | PathSpace path_space = slice_to_prefixed_file_w({ (uint8_t*)buf_ptr(full_path), buf_len(full_path) }); |
| 2122 | for (;;) { | 2126 | for (;;) { |
| 2123 | HANDLE result = CreateFileA(buf_ptr(full_path), GENERIC_READ | GENERIC_WRITE, | 2127 | HANDLE result = CreateFileW(&path_space.data.items[0], GENERIC_READ | GENERIC_WRITE, |
| 2124 | 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); | 2128 | 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); |
| 2125 | | 2129 | |
| 2126 | if (result == INVALID_HANDLE_VALUE) { | 2130 | if (result == INVALID_HANDLE_VALUE) { |