diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-10-30 18:19:57 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-10-30 18:19:57 +0100 |
commit | 29c346fea61da23813dbee30f774547d913abf33 (patch) | |
tree | 6fa97dd00b548efdc9c165f784e4844cbbbb2a3c /src/Storage.cpp | |
parent | 853e6db3123415c57aabd7ae3644ebe28a46939f (diff) |
Diffstat (limited to 'src/Storage.cpp')
-rw-r--r-- | src/Storage.cpp | 15 |
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)) { |