mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 21:34:46 +02:00
Fix open append mode for file_win32
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Fix open append mode for file_win32.
|
||||
* Add tests for file open in append mode.
|
||||
* Fix file open with append/append_existing flag on Windows.
|
||||
|
||||
|
@@ -175,7 +175,7 @@ open(char const* path, file_mode mode, error_code& ec)
|
||||
desired_access = boost::winapi::GENERIC_READ_ |
|
||||
boost::winapi::GENERIC_WRITE_;
|
||||
|
||||
creation_disposition = boost::winapi::CREATE_ALWAYS_;
|
||||
creation_disposition = boost::winapi::OPEN_ALWAYS_;
|
||||
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
||||
break;
|
||||
|
||||
|
@@ -88,11 +88,13 @@ test_file()
|
||||
};
|
||||
|
||||
auto const create =
|
||||
[](fs::path const& path)
|
||||
[](fs::path const& path, std::string const& data = "")
|
||||
{
|
||||
BEAST_EXPECT(! fs::exists(path));
|
||||
fs::ofstream out(path);
|
||||
BEAST_EXPECT(out.is_open());
|
||||
if (data.size())
|
||||
out.write(data.c_str(), data.size());
|
||||
};
|
||||
|
||||
auto const remove =
|
||||
@@ -285,10 +287,16 @@ test_file()
|
||||
{
|
||||
File f;
|
||||
error_code ec;
|
||||
create(path);
|
||||
BEAST_EXPECT(fs::exists(path));
|
||||
create(path, "the cat");
|
||||
f.open(path, file_mode::append_existing, ec);
|
||||
BEAST_EXPECT(! ec);
|
||||
static std::string const extra = " sat";
|
||||
f.write(extra.c_str(), extra.size(), ec);
|
||||
BEAST_EXPECT(!ec);
|
||||
f.close(ec);
|
||||
BEAST_EXPECT(!ec);
|
||||
auto s = consume_file(path);
|
||||
BEAST_EXPECTS(s == "the cat sat", s);
|
||||
}
|
||||
remove(path);
|
||||
}
|
||||
|
Reference in New Issue
Block a user