| ... | ... | @@ -1070,9 +1070,11 @@ static FILETIME windows_os_timestamp_to_filetime(OsTimeStamp mtime) { |
| 1070 | 1070 | |
| 1071 | 1071 | static Error set_file_times(OsFile file, OsTimeStamp ts) { |
| 1072 | 1072 | #if defined(ZIG_OS_WINDOWS) |
| 1073 | | const atime_ft = windows.nanoSecondsToFileTime(atime); |
| 1074 | | const mtime_ft = windows.nanoSecondsToFileTime(mtime); |
| 1075 | | return SetFileTime(file, null, &atime_ft, &mtime_ft); |
| 1073 | FILETIME ft = windows_os_timestamp_to_filetime(ts); |
| 1074 | if (SetFileTime(file, nullptr, &ft, &ft) == 0) { |
| 1075 | return ErrorUnexpected; |
| 1076 | } |
| 1077 | return ErrorNone; |
| 1076 | 1078 | #else |
| 1077 | 1079 | struct timespec times[2] = { |
| 1078 | 1080 | { ts.sec, ts.nsec }, |
| ... | ... | @@ -1114,14 +1116,25 @@ Error os_update_file(Buf *src_path, Buf *dst_path) { |
| 1114 | 1116 | os_file_close(&dst_file); |
| 1115 | 1117 | return ErrorNone; |
| 1116 | 1118 | } |
| 1117 | | |
| 1119 | #if defined(ZIG_OS_WINDOWS) |
| 1120 | if (SetEndOfFile(dst_file) == 0) { |
| 1121 | return ErrorUnexpected; |
| 1122 | } |
| 1123 | #else |
| 1124 | if (ftruncate(dst_file, 0) == -1) { |
| 1125 | return ErrorUnexpected; |
| 1126 | } |
| 1127 | #endif |
| 1128 | #if defined(ZIG_OS_WINDOWS) |
| 1129 | FILE *src_libc_file = _fdopen(_open_osfhandle((intptr_t)src_file, _O_RDONLY), "rb"); |
| 1130 | FILE *dst_libc_file = _fdopen(_open_osfhandle((intptr_t)dst_file, 0), "wb"); |
| 1131 | #else |
| 1118 | 1132 | FILE *src_libc_file = fdopen(src_file, "rb"); |
| 1119 | 1133 | FILE *dst_libc_file = fdopen(dst_file, "wb"); |
| 1134 | #endif |
| 1120 | 1135 | assert(src_libc_file); |
| 1121 | 1136 | assert(dst_libc_file); |
| 1122 | | if (ftruncate(dst_file, 0) == -1) { |
| 1123 | | return ErrorUnexpected; |
| 1124 | | } |
| 1137 | |
| 1125 | 1138 | if ((err = copy_open_files(src_libc_file, dst_libc_file))) { |
| 1126 | 1139 | fclose(src_libc_file); |
| 1127 | 1140 | fclose(dst_libc_file); |