mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-23 02:49:46 +00:00
make memory device create file on flush
This commit is contained in:
parent
ec51848447
commit
682ca665c9
1 changed files with 6 additions and 1 deletions
|
|
@ -14,8 +14,13 @@ std::filesystem::path io::MemoryDevice::resolve(std::string_view path) {
|
||||||
|
|
||||||
std::unique_ptr<std::ostream> io::MemoryDevice::write(std::string_view path) {
|
std::unique_ptr<std::ostream> io::MemoryDevice::write(std::string_view path) {
|
||||||
std::string filePath = std::string(path);
|
std::string filePath = std::string(path);
|
||||||
|
|
||||||
|
auto memoryStream = std::make_unique<memory_ostream>();
|
||||||
|
memoryStream->set_sync_callback([this, filePath](std::string_view data) {
|
||||||
|
createFile(std::move(filePath), util::Buffer<char>(data.data(), data.size()));
|
||||||
|
});
|
||||||
return std::make_unique<finalizing_ostream>(
|
return std::make_unique<finalizing_ostream>(
|
||||||
std::make_unique<memory_ostream>(),
|
std::move(memoryStream),
|
||||||
[this, filePath](auto ostream) {
|
[this, filePath](auto ostream) {
|
||||||
auto& memoryStream = dynamic_cast<memory_ostream&>(*ostream);
|
auto& memoryStream = dynamic_cast<memory_ostream&>(*ostream);
|
||||||
createFile(std::move(filePath), memoryStream.release());
|
createFile(std::move(filePath), memoryStream.release());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue