mirror of
https://github.com/boostorg/beast.git
synced 2025-08-01 22:04:34 +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.
|
* Add tests for file open in append mode.
|
||||||
* Fix file open with append/append_existing flag on Windows.
|
* 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_ |
|
desired_access = boost::winapi::GENERIC_READ_ |
|
||||||
boost::winapi::GENERIC_WRITE_;
|
boost::winapi::GENERIC_WRITE_;
|
||||||
|
|
||||||
creation_disposition = boost::winapi::CREATE_ALWAYS_;
|
creation_disposition = boost::winapi::OPEN_ALWAYS_;
|
||||||
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -88,11 +88,13 @@ test_file()
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto const create =
|
auto const create =
|
||||||
[](fs::path const& path)
|
[](fs::path const& path, std::string const& data = "")
|
||||||
{
|
{
|
||||||
BEAST_EXPECT(! fs::exists(path));
|
BEAST_EXPECT(! fs::exists(path));
|
||||||
fs::ofstream out(path);
|
fs::ofstream out(path);
|
||||||
BEAST_EXPECT(out.is_open());
|
BEAST_EXPECT(out.is_open());
|
||||||
|
if (data.size())
|
||||||
|
out.write(data.c_str(), data.size());
|
||||||
};
|
};
|
||||||
|
|
||||||
auto const remove =
|
auto const remove =
|
||||||
@@ -285,10 +287,16 @@ test_file()
|
|||||||
{
|
{
|
||||||
File f;
|
File f;
|
||||||
error_code ec;
|
error_code ec;
|
||||||
create(path);
|
create(path, "the cat");
|
||||||
BEAST_EXPECT(fs::exists(path));
|
|
||||||
f.open(path, file_mode::append_existing, ec);
|
f.open(path, file_mode::append_existing, ec);
|
||||||
BEAST_EXPECT(! 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);
|
remove(path);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user