mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 17:01:15 +02:00
- nhttpd: add option to appent to file in write_to_file()
This commit is contained in:
@@ -250,9 +250,9 @@ std::string string_tolower(std::string str) {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// write string to a file
|
// 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;
|
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);
|
fwrite(content.c_str(), content.length(), 1, fd);
|
||||||
fflush(fd); // flush and close file
|
fflush(fd); // flush and close file
|
||||||
|
@@ -35,7 +35,7 @@ bool ySplitStringLast(std::string str, std::string delimiter, std::string& left,
|
|||||||
CStringArray ySplitStringVector(std::string str, std::string delimiter);
|
CStringArray ySplitStringVector(std::string str, std::string delimiter);
|
||||||
bool nocase_compare (char c1, char c2);
|
bool nocase_compare (char c1, char c2);
|
||||||
std::string timeString(time_t time);
|
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
|
// JSON Helpers
|
||||||
|
Reference in New Issue
Block a user