| 190 | } |
| 191 | |
| 192 | void ddio_CopyFileTime(const std::filesystem::path &dest, const std::filesystem::path &src) { |
| 193 | HANDLE desthandle, srchandle; |
| 194 | FILETIME a, b, c; |
| 195 | bool first_time = 1; |
| 196 | |
| 197 | try_again:; |
| 198 | |
| 199 | desthandle = CreateFile(dest.u8string().c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
| 200 | srchandle = CreateFile(src.u8string().c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
| 201 | |
| 202 | if (desthandle == INVALID_HANDLE_VALUE || srchandle == INVALID_HANDLE_VALUE) { |
| 203 | mprintf(0, "Couldn't copy file time for %s! Error=%d\n", dest.u8string().c_str(), GetLastError()); |
| 204 | |
| 205 | if (desthandle != INVALID_HANDLE_VALUE) |
| 206 | CloseHandle(desthandle); |
| 207 | |
| 208 | if (srchandle != INVALID_HANDLE_VALUE) |
| 209 | CloseHandle(srchandle); |
| 210 | |
| 211 | if (first_time) { |
| 212 | first_time = 0; |
| 213 | Sleep(500); |
| 214 | goto try_again; |
| 215 | } |
| 216 | |
| 217 | // JEFF: This Int3 has become really annoying...all we do is blow by it anyway |
| 218 | // removed for sanity. |
| 219 | //@@Int3(); //Let Matt know if you hit this! |
| 220 | return; |
| 221 | } |
| 222 | |
| 223 | GetFileTime(srchandle, &a, &b, &c); |
| 224 | SetFileTime(desthandle, &a, &b, &c); |
| 225 | |
| 226 | CloseHandle(desthandle); |
| 227 | CloseHandle(srchandle); |
| 228 | } |
| 229 | |
| 230 | // deletes a file. Returns 1 if successful, 0 on failure |
| 231 | int ddio_DeleteFile(const char *name) { return (DeleteFile(name)); } |
no test coverage detected