aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/basicfile.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-11-07 12:27:44 +0100
committerGitHub Enterprise <[email protected]>2025-11-07 12:27:44 +0100
commit72b1797e2b65ad47f4dc8e9fab73b9aa170889b4 (patch)
tree93c9f7c99965393ba9c6ec86c01b63899bfba684 /src/zencore/basicfile.cpp
parentmove progress bar to separate file (#638) (diff)
downloadzen-72b1797e2b65ad47f4dc8e9fab73b9aa170889b4.tar.xz
zen-72b1797e2b65ad47f4dc8e9fab73b9aa170889b4.zip
get oplog attachments (#622)
* add support for downloading individual attachments from an oplog
Diffstat (limited to 'src/zencore/basicfile.cpp')
-rw-r--r--src/zencore/basicfile.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/zencore/basicfile.cpp b/src/zencore/basicfile.cpp
index 6989da67e..2fa02937d 100644
--- a/src/zencore/basicfile.cpp
+++ b/src/zencore/basicfile.cpp
@@ -513,6 +513,30 @@ TemporaryFile::SafeWriteFile(const std::filesystem::path& Path, MemoryView Data,
}
}
+void
+TemporaryFile::SafeWriteFile(const std::filesystem::path& Path, const CompositeBuffer& Data)
+{
+ std::error_code Ec;
+ SafeWriteFile(Path, Data, Ec);
+ if (Ec)
+ {
+ throw std::system_error(Ec, fmt::format("Failed to safely write file '{}'", Path));
+ }
+}
+
+void
+TemporaryFile::SafeWriteFile(const std::filesystem::path& Path, const CompositeBuffer& Data, std::error_code& OutEc)
+{
+ TemporaryFile TempFile;
+ if (TempFile.CreateTemporary(Path.parent_path(), OutEc); !OutEc)
+ {
+ if (TempFile.Write(Data, 0, OutEc); !OutEc)
+ {
+ TempFile.MoveTemporaryIntoPlace(Path, OutEc);
+ }
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
LockFile::LockFile()