diff options
| author | Dan Engelbrecht <[email protected]> | 2022-03-21 10:06:10 +0100 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-03-31 11:28:33 +0200 |
| commit | f98dfd8f2f853aeb33eff572a9658f2993cc17bb (patch) | |
| tree | ff50b82c2f3783ebb0057b27c39cb72fafdc1c90 /zenstore/basicfile.cpp | |
| parent | Change block size of compactcas stores (diff) | |
| download | zen-f98dfd8f2f853aeb33eff572a9658f2993cc17bb.tar.xz zen-f98dfd8f2f853aeb33eff572a9658f2993cc17bb.zip | |
Move MarkAsDeleteOnClose to BasicFile
Diffstat (limited to 'zenstore/basicfile.cpp')
| -rw-r--r-- | zenstore/basicfile.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/zenstore/basicfile.cpp b/zenstore/basicfile.cpp index 17a57309d..efa91f107 100644 --- a/zenstore/basicfile.cpp +++ b/zenstore/basicfile.cpp @@ -296,6 +296,31 @@ BasicFile::SetFileSize(uint64_t FileSize) #endif } +void +BasicFile::MarkAsDeleteOnClose(std::error_code& Ec) +{ + Ec.clear(); +#if ZEN_PLATFORM_WINDOWS + FILE_DISPOSITION_INFO Fdi{}; + Fdi.DeleteFile = TRUE; + BOOL Success = SetFileInformationByHandle(m_FileHandle, FileDispositionInfo, &Fdi, sizeof Fdi); + if (!Success) + { + Ec = MakeErrorCodeFromLastError(); + } +#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC + std::filesystem::path SourcePath = PathFromHandle(FileRef.FileHandle); + if (unlink(SourcePath.c_str()) < 0) + { + int UnlinkError = zen::GetLastError(); + if (UnlinkError != ENOENT) + { + Ec = MakeErrorCode(UnlinkError); + } + } +#endif +} + ////////////////////////////////////////////////////////////////////////// TemporaryFile::~TemporaryFile() |