diff --git a/src/nhttpd/yhttpd_core/helper.cpp b/src/nhttpd/yhttpd_core/helper.cpp index 8bd342654..d1d1d3f45 100644 --- a/src/nhttpd/yhttpd_core/helper.cpp +++ b/src/nhttpd/yhttpd_core/helper.cpp @@ -250,9 +250,9 @@ std::string string_tolower(std::string str) { //----------------------------------------------------------------------------- // write string to a file //----------------------------------------------------------------------------- -bool write_to_file(std::string filename, std::string content) { +bool write_to_file(std::string filename, std::string content, bool append) { FILE *fd = NULL; - if ((fd = fopen(filename.c_str(), "w")) != NULL) // open file + if ((fd = fopen(filename.c_str(), append ? "a" : "w")) != NULL) // open file { fwrite(content.c_str(), content.length(), 1, fd); fflush(fd); // flush and close file diff --git a/src/nhttpd/yhttpd_core/helper.h b/src/nhttpd/yhttpd_core/helper.h index fd04c3247..20e6a0a13 100644 --- a/src/nhttpd/yhttpd_core/helper.h +++ b/src/nhttpd/yhttpd_core/helper.h @@ -35,7 +35,7 @@ bool ySplitStringLast(std::string str, std::string delimiter, std::string& left, CStringArray ySplitStringVector(std::string str, std::string delimiter); bool nocase_compare (char c1, char c2); std::string timeString(time_t time); -bool write_to_file(std::string filename, std::string content); +bool write_to_file(std::string filename, std::string content, bool append=false); //----------------------------------------------------------------------------- // JSON Helpers