aboutsummaryrefslogtreecommitdiff
path: root/src/Storage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Storage.cpp')
-rw-r--r--src/Storage.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Storage.cpp b/src/Storage.cpp
index 7bb3be6..5c12911 100644
--- a/src/Storage.cpp
+++ b/src/Storage.cpp
@@ -244,6 +244,21 @@ namespace QuickMedia {
return rename_atomic(tmp_path.data.c_str(), path.data.c_str());
}
+ bool file_append(const Path &path, const std::string &data) {
+ FILE *file = fopen_eintr(path.data.c_str(), "ab");
+ if(!file) {
+ perror(path.data.c_str());
+ return false;
+ }
+
+ if(fwrite_eintr(data.data(), data.size(), file) != data.size()) {
+ fclose(file);
+ return false;
+ }
+
+ return fclose(file) == 0;
+ }
+
void for_files_in_dir(const Path &path, FileIteratorCallback callback) {
try {
for(auto &p : std::filesystem::directory_iterator(path.data)) {