mirror of
https://github.com/edubart/otclient.git
synced 2025-10-18 21:43:26 +02:00
use exceptions in FML
This commit is contained in:
@@ -36,14 +36,14 @@ bool Configs::load(const std::string& fileName)
|
||||
if(!g_resources.loadFile(fileName, fin))
|
||||
return false;
|
||||
|
||||
FML::Parser parser;
|
||||
if(parser.load(fin)) {
|
||||
try {
|
||||
FML::Parser parser(fin, fileName);
|
||||
FML::Node* doc = parser.getDocument();
|
||||
|
||||
foreach(FML::Node* node, *doc)
|
||||
m_confsMap[node->tag()] = node->value();
|
||||
} else {
|
||||
flogError("ERROR: Malformed config file: %s", parser.getErrorMessage());
|
||||
} catch(FML::Exception e) {
|
||||
flogError("ERROR: Malformed config file: %s", e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -118,7 +118,7 @@ bool Resources::loadFile(const std::string& fileName, std::iostream& out)
|
||||
char *buffer = new char[fileSize];
|
||||
PHYSFS_read(file, (void*)buffer, 1, fileSize);
|
||||
out.write(buffer, fileSize);
|
||||
delete buffer;
|
||||
delete[] buffer;
|
||||
} else
|
||||
out.clear(std::ios::eofbit);
|
||||
PHYSFS_close(file);
|
||||
|
Reference in New Issue
Block a user