| 225 | } |
| 226 | |
| 227 | void File::overwriteFileWithRename(char const* data, size_t len, String const& filename, String const& newSuffix) { |
| 228 | String newFile = filename + newSuffix; |
| 229 | |
| 230 | try { |
| 231 | auto file = File::open(newFile, IOMode::Write | IOMode::Truncate); |
| 232 | file->writeFull(data, len); |
| 233 | file->sync(); |
| 234 | file->close(); |
| 235 | |
| 236 | File::rename(newFile, filename); |
| 237 | } catch (IOException const&) { |
| 238 | // HACK: Been having trouble on windows with the write / flush / move |
| 239 | // sequence, try super hard to just write the file non-atomically in case |
| 240 | // of weird file locking problems instead of erroring. |
| 241 | |
| 242 | // Ignore any error on removal of the maybe existing newFile |
| 243 | ::_wremove(stringToUtf16(newFile).get()); |
| 244 | |
| 245 | writeFile(data, len, filename); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | void* File::fopen(char const* filename, IOMode mode) { |
| 250 | DWORD desiredAccess = 0; |
nothing calls this directly
no test coverage detected