fix load text bug

This commit is contained in:
Eduardo Bart 2011-02-08 21:05:31 -02:00
parent b2c61760e5
commit b80dc4d6e0
2 changed files with 3 additions and 3 deletions

View File

@ -58,12 +58,11 @@ bool ConfigManager::load(const std::string& fileName)
YAML::Node doc;
parser.GetNextDocument(doc);
for(YAML::Iterator it = doc.begin(); it != doc.end(); it++) {
for(YAML::Iterator it = doc.begin(); it != doc.end(); ++it) {
std::string key, value;
it.first() >> key;
it.second() >> value;
m_confsMap[key] = value;
dump() << key << value;
}
} catch (YAML::ParserException& e) {
error("Malformed configuration file!");

View File

@ -81,8 +81,9 @@ unsigned char *ResourceManager::loadFile(const std::string& fileName, unsigned i
}
*fileSize = PHYSFS_fileLength(file);
unsigned char *buffer = new unsigned char[*fileSize];
unsigned char *buffer = new unsigned char[*fileSize + 1];
PHYSFS_read(file, (void*)buffer, 1, *fileSize);
buffer[*fileSize] = 0;
PHYSFS_close(file);
return buffer;
}