diff options
Diffstat (limited to 'source/OSSupport')
-rw-r--r-- | source/OSSupport/File.cpp | 16 | ||||
-rw-r--r-- | source/OSSupport/File.h | 3 |
2 files changed, 19 insertions, 0 deletions
diff --git a/source/OSSupport/File.cpp b/source/OSSupport/File.cpp index 86276bd79..274aa52da 100644 --- a/source/OSSupport/File.cpp +++ b/source/OSSupport/File.cpp @@ -420,6 +420,22 @@ AStringVector cFile::GetFolderContents(const AString & a_Folder) +AString cFile::ReadWholeFile(const AString & a_FileName) +{ + cFile f; + if (!f.Open(a_FileName, fmRead)) + { + return ""; + } + AString Contents; + f.ReadRestOfFile(Contents); + return Contents; +} + + + + + int cFile::Printf(const char * a_Fmt, ...) { AString buf; diff --git a/source/OSSupport/File.h b/source/OSSupport/File.h index 70f81c8d2..01663a229 100644 --- a/source/OSSupport/File.h +++ b/source/OSSupport/File.h @@ -121,6 +121,9 @@ public: /// Creates a new folder with the specified name. Returns true if successful. Path may be relative or absolute static bool CreateFolder(const AString & a_FolderPath); + /// Returns the entire contents of the specified file as a string. Returns empty string on error. + static AString ReadWholeFile(const AString & a_FileName); + // tolua_end /// Returns the list of all items in the specified folder (files, folders, nix pipes, whatever's there). |