io/FileOutputStream: merge win32 function Cancel

Win32 had a separate implementation for FileOutputStream::CANCEL Logic
was added to the other platform function, but forgotten in this one.

This merges the functions into one, as only the call for file deletion
is platform specific.
This commit is contained in:
Philipp Wollschlegel 2021-11-23 22:40:38 +01:00 committed by Max Kellermann
parent 5ad4f3c54b
commit c072902f23
1 changed files with 4 additions and 11 deletions

View File

@ -146,16 +146,6 @@ FileOutputStream::Commit()
Close();
}
void
FileOutputStream::Cancel() noexcept
{
assert(IsDefined());
Close();
DeleteFile(GetPath().c_str());
}
#else
#include <cerrno>
@ -274,6 +264,8 @@ FileOutputStream::Commit()
}
}
#endif
void
FileOutputStream::Cancel() noexcept
{
@ -288,6 +280,8 @@ FileOutputStream::Cancel() noexcept
#endif
#ifdef __linux__
unlinkat(directory_fd.Get(), GetPath().c_str(), 0);
#elif _WIN32
DeleteFile(GetPath().c_str());
#else
unlink(GetPath().c_str());
#endif
@ -301,4 +295,3 @@ FileOutputStream::Cancel() noexcept
}
}
#endif