From 29c346fea61da23813dbee30f774547d913abf33 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 30 Oct 2024 18:19:57 +0100 Subject: Only show kick/ban notification once --- src/Storage.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/Storage.cpp') 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)) { -- cgit v1.2.3