summaryrefslogtreecommitdiff
path: root/src/utils/files.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/files.cpp')
-rw-r--r--src/utils/files.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils/files.cpp b/src/utils/files.cpp
index d3a04d69f..e435249da 100644
--- a/src/utils/files.cpp
+++ b/src/utils/files.cpp
@@ -270,6 +270,22 @@ std::string Files::getPath(const std::string &file)
return path;
}
+std::string Files::loadTextFileString(const std::string &fileName)
+{
+ int contentsLength;
+ char *fileContents = static_cast<char*>(
+ PhysFs::loadFile(fileName, contentsLength));
+
+ if (!fileContents)
+ {
+ logger->log("Couldn't load text file: %s", fileName.c_str());
+ return std::string();
+ }
+ const std::string str = std::string(fileContents, contentsLength);
+ free(fileContents);
+ return str;
+}
+
bool Files::loadTextFile(const std::string &fileName,
StringVect &lines)
{