[Core] Fix ParseFile on non-Windows.
This commit is contained in:
parent
306f358c07
commit
13a67d64a9
|
@ -5,17 +5,19 @@
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/string.h"
|
#include "xenia/base/string.h"
|
||||||
|
|
||||||
namespace cpptoml {
|
std::shared_ptr<cpptoml::table> ParseFile(const std::wstring& filename) {
|
||||||
inline std::shared_ptr<table> parse_file(const std::wstring& filename) {
|
#if XE_PLATFORM_WIN32
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filename);
|
||||||
|
#else
|
||||||
|
std::ifstream file(xe::to_string(filename));
|
||||||
|
#endif
|
||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
throw parse_exception(xe::to_string(filename) +
|
throw cpptoml::parse_exception(xe::to_string(filename) +
|
||||||
" could not be opened for parsing");
|
" could not be opened for parsing");
|
||||||
}
|
}
|
||||||
parser p(file);
|
cpptoml::parser p(file);
|
||||||
return p.parse();
|
return p.parse();
|
||||||
}
|
}
|
||||||
} // namespace cpptoml
|
|
||||||
|
|
||||||
CmdVar(config, "", "Specifies the target config to load.");
|
CmdVar(config, "", "Specifies the target config to load.");
|
||||||
namespace config {
|
namespace config {
|
||||||
|
@ -32,7 +34,7 @@ bool sortCvar(cvar::IConfigVar* a, cvar::IConfigVar* b) {
|
||||||
|
|
||||||
std::shared_ptr<cpptoml::table> ParseConfig(const std::wstring& config_path) {
|
std::shared_ptr<cpptoml::table> ParseConfig(const std::wstring& config_path) {
|
||||||
try {
|
try {
|
||||||
return cpptoml::parse_file(config_path);
|
return ParseFile(config_path);
|
||||||
} catch (cpptoml::parse_exception e) {
|
} catch (cpptoml::parse_exception e) {
|
||||||
xe::FatalError(L"Failed to parse config file '%s':\n\n%s",
|
xe::FatalError(L"Failed to parse config file '%s':\n\n%s",
|
||||||
config_path.c_str(), xe::to_wstring(e.what()).c_str());
|
config_path.c_str(), xe::to_wstring(e.what()).c_str());
|
||||||
|
|
Loading…
Reference in New Issue