mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Workaround for crash with older version of jsoncpp
This commit is contained in:
parent
b0a90f6c60
commit
257946dbc1
@ -71,6 +71,7 @@ namespace Util
|
||||
void parseOptionString(const std::string &option_string, std::vector<unsigned int> &priority, unsigned int &type, const std::vector<GlobalConstants::optionsStruct>& options);
|
||||
std::string getLocalFileHash(const std::string& xml_dir, const std::string& filepath, const std::string& gamename = std::string());
|
||||
void shortenStringToTerminalWidth(std::string& str);
|
||||
std::string getJsonUIntValueAsString(const Json::Value& json);
|
||||
|
||||
template<typename ... Args> std::string formattedString(const std::string& format, Args ... args)
|
||||
{
|
||||
|
@ -410,7 +410,7 @@ std::vector<gameFile> galaxyAPI::installerJsonNodeToGameFileVector(const std::st
|
||||
gf.language = iLanguage;
|
||||
gf.name = name;
|
||||
gf.path = path;
|
||||
gf.size = fileNode["size"].asString();
|
||||
gf.size = Util::getJsonUIntValueAsString(fileNode["size"]);
|
||||
gf.updated = 0; // assume not updated
|
||||
gf.galaxy_downlink_json_url = downlink;
|
||||
|
||||
@ -499,7 +499,7 @@ std::vector<gameFile> galaxyAPI::extraJsonNodeToGameFileVector(const std::string
|
||||
gf.id = fileNode["id"].asString();
|
||||
gf.name = name;
|
||||
gf.path = path;
|
||||
gf.size = fileNode["size"].asString();
|
||||
gf.size = Util::getJsonUIntValueAsString(fileNode["size"]);
|
||||
gf.updated = 0; // assume not updated
|
||||
gf.galaxy_downlink_json_url = downlink;
|
||||
|
||||
|
23
src/util.cpp
23
src/util.cpp
@ -590,3 +590,26 @@ void Util::shortenStringToTerminalWidth(std::string& str)
|
||||
str.replace(str.begin()+pos1, str.begin()+pos2, "...");
|
||||
}
|
||||
}
|
||||
|
||||
std::string Util::getJsonUIntValueAsString(const Json::Value& json_value)
|
||||
{
|
||||
std::string value;
|
||||
try
|
||||
{
|
||||
value = json_value.asString();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
try
|
||||
{
|
||||
uintmax_t value_uint = json_value.asLargestUInt();
|
||||
value = std::to_string(value_uint);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user