Skip to content

Commit

Permalink
Improve fs::pending_file on Win32
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Mar 2, 2021
1 parent 0885f1e commit a1ced62
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Utilities/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,12 @@ fs::pending_file::pending_file(const std::string& path)

if (file.open(m_path, fs::create + fs::write + fs::read + fs::excl))
{
#ifdef _WIN32
// Delete on close (TODO: O_TMPFILE on POSIX)
FILE_DISPOSITION_INFO disp;
disp.DeleteFileW = true;
SetFileInformationByHandle(file.get_handle(), FileDispositionInfo, &disp, sizeof(disp));
#endif
m_dest = path;
break;
}
Expand All @@ -1951,10 +1957,12 @@ fs::pending_file::~pending_file()
{
file.close();

#ifndef _WIN32
if (!m_path.empty())
{
fs::remove_file(m_path);
}
#endif
}

bool fs::pending_file::commit(bool overwrite)
Expand Down

0 comments on commit a1ced62

Please sign in to comment.