CFile: Add write function that accepts string data
authorAthanasios Oikonomou <athoik@gmail.com>
Tue, 5 Jan 2016 20:49:09 +0000 (22:49 +0200)
committerErik Slagter <erik@openpli.org>
Wed, 6 Jan 2016 09:51:59 +0000 (10:51 +0100)
(cherry picked from commit 46ca30e5a07b28022302a38b84a738e757beaa1f)
Signed-off-by: Erik Slagter <erik@openpli.org>

lib/base/cfile.cpp
lib/base/cfile.h

index 9b67b60..93a52d4 100644 (file)
@@ -35,3 +35,11 @@ int CFile::writeInt(const char *filename, int value)
                return -1;
        return fprintf(f, "%d", value);
 }
+
+int CFile::write(const char *filename, const char *value)
+{
+       CFile f(filename, "w");
+       if (!f)
+               return -1;
+       return fprintf(f, "%s", value);
+}
index 3c41fd5..1f3ab2c 100644 (file)
@@ -28,6 +28,7 @@ struct CFile
        static int parseInt(int *result, const char *filename);
        static int writeIntHex(const char *filename, int value);
        static int writeInt(const char *filename, int value);
+       static int write(const char *filename, const char *value);
 };
 
 #endif