summaryrefslogtreecommitdiff
path: root/src/resources/resourcemanager.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-07-15 23:43:22 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-07-15 23:43:22 +0000
commit9cea91975451a7abb6f15e08f7fb6c20efed152c (patch)
treeddf2aaf22597d8fa63a33dd62a57cb50e083f7e3 /src/resources/resourcemanager.cpp
parent97cac06ae12026f4be3765f68b0aea3caf02d8f0 (diff)
downloadmana-client-9cea91975451a7abb6f15e08f7fb6c20efed152c.tar.gz
mana-client-9cea91975451a7abb6f15e08f7fb6c20efed152c.tar.bz2
mana-client-9cea91975451a7abb6f15e08f7fb6c20efed152c.tar.xz
mana-client-9cea91975451a7abb6f15e08f7fb6c20efed152c.zip
Fixed compiler warnings and added plain text file loading to resource manager.
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r--src/resources/resourcemanager.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 50d0f4b8..6ed933e4 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -281,3 +281,32 @@ ResourceManager::loadFile(const std::string &fileName, int &fileSize)
return buffer;
}
+
+std::vector<std::string>
+ResourceManager::loadTextFile(const std::string &fileName)
+{
+ int contentsLength;
+ char *fileContents = (char*)loadFile(fileName, contentsLength);
+ std::vector<std::string> lines;
+
+ if (!fileContents)
+ {
+ logger->log("Couldn't load text file: %s", fileName.c_str());
+ return lines;
+ }
+
+ // Reallocate and include terminating 0 character
+ fileContents = (char*)realloc(fileContents, contentsLength + 1);
+ fileContents[contentsLength] = '\0';
+
+ // Tokenize and add each line separately
+ char *line = strtok(fileContents, "\n");
+ while (line != NULL)
+ {
+ lines.push_back(line);
+ line = strtok(NULL, "\n");
+ }
+
+ free(fileContents);
+ return lines;
+}