Fix file open with append/append_existing flag on Windows

This commit is contained in:
vm2mv
2021-07-06 11:27:41 +03:00
committed by Richard Hodges
parent 1405b5a8eb
commit fb8f57a9e5
2 changed files with 24 additions and 3 deletions

View File

@ -1,3 +1,7 @@
* Fix file open with append/append_existing flag on Windows.
--------------------------------------------------------------------------------
Version 323:
* Fix clang-cl UTF8 path handling for `file_win32`.

View File

@ -199,9 +199,26 @@ open(char const* path, file_mode mode, error_code& ec)
flags_and_attributes,
NULL);
if (h_ == boost::winapi::INVALID_HANDLE_VALUE_)
{
ec.assign(boost::winapi::GetLastError(),
system_category());
else
return;
}
if (mode == file_mode::append ||
mode == file_mode::append_existing)
{
boost::winapi::LARGE_INTEGER_ in;
in.QuadPart = 0;
if (!detail::set_file_pointer_ex(h_, in, 0,
boost::winapi::FILE_END_))
{
ec.assign(boost::winapi::GetLastError(),
system_category());
boost::winapi::CloseHandle(h_);
h_ = boost::winapi::INVALID_HANDLE_VALUE_;
return;
}
}
ec = {};
}