diff options
Diffstat (limited to 'src/zencore/filesystem.cpp')
| -rw-r--r-- | src/zencore/filesystem.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp index 29ec14e0c..3e94b550f 100644 --- a/src/zencore/filesystem.cpp +++ b/src/zencore/filesystem.cpp @@ -811,11 +811,17 @@ WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t Buffer hRes = Outfile.Write(DataPtr, gsl::narrow_cast<uint32_t>(WriteSize)); if (FAILED(hRes)) { + Outfile.Close(); + std::error_code DummyEc; + std::filesystem::remove(Path, DummyEc); ThrowSystemException(hRes, fmt::format("File write failed for '{}'", Path).c_str()); } #else if (write(Fd, DataPtr, WriteSize) != int64_t(WriteSize)) { + close(Fd); + std::error_code DummyEc; + std::filesystem::remove(Path, DummyEc); ThrowLastError(fmt::format("File write failed for '{}'", Path)); } #endif // ZEN_PLATFORM_WINDOWS @@ -825,7 +831,9 @@ WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t Buffer } } -#if !ZEN_PLATFORM_WINDOWS +#if ZEN_PLATFORM_WINDOWS + Outfile.Close(); +#else close(Fd); #endif } |