Fix crash when loading Steam games on flatpak
This commit is contained in:
+17
-10
@@ -177,21 +177,26 @@ std::optional<uint32_t> guess_steam_userid(const std::filesystem::path & root)
|
|||||||
|
|
||||||
std::unordered_set<uint64_t> installed_appids(std::filesystem::path root)
|
std::unordered_set<uint64_t> installed_appids(std::filesystem::path root)
|
||||||
{
|
{
|
||||||
wivrn::vdf::root vdf(root / "config/libraryfolders.vdf");
|
|
||||||
using values_t = std::vector<wivrn::vdf::keyvalue>;
|
|
||||||
if (vdf.key != "libraryfolders")
|
|
||||||
return {};
|
|
||||||
|
|
||||||
std::unordered_set<uint64_t> res;
|
std::unordered_set<uint64_t> res;
|
||||||
for (const auto & kv: std::get<values_t>(vdf.value))
|
try
|
||||||
{
|
{
|
||||||
for (const auto & [appid, _]: std::get<values_t>(kv["apps"].value))
|
wivrn::vdf::root vdf(root / "config/libraryfolders.vdf");
|
||||||
|
using values_t = std::vector<wivrn::vdf::keyvalue>;
|
||||||
|
if (vdf.key != "libraryfolders")
|
||||||
|
return {};
|
||||||
|
|
||||||
|
for (const auto & kv: std::get<values_t>(vdf.value))
|
||||||
{
|
{
|
||||||
uint64_t val;
|
for (const auto & [appid, _]: std::get<values_t>(kv["apps"].value))
|
||||||
if (std::from_chars(appid.data.begin(), appid.data.end(), val).ec == std::errc())
|
{
|
||||||
res.emplace(val);
|
uint64_t val;
|
||||||
|
if (std::from_chars(appid.data.begin(), appid.data.end(), val).ec == std::errc())
|
||||||
|
res.emplace(val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (...)
|
||||||
|
{}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,6 +481,7 @@ std::vector<wivrn::steam::application> wivrn::steam::list_applications()
|
|||||||
}
|
}
|
||||||
catch (std::exception & e)
|
catch (std::exception & e)
|
||||||
{
|
{
|
||||||
|
std::cerr << "Listing Steam applications failed (user id " << *default_userid << "): " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -496,6 +502,7 @@ std::vector<wivrn::steam::application> wivrn::steam::list_applications()
|
|||||||
}
|
}
|
||||||
catch (std::exception & e)
|
catch (std::exception & e)
|
||||||
{
|
{
|
||||||
|
std::cerr << "Listing Steam applications failed (" << entry.path().filename() << "): " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-5
@@ -145,12 +145,19 @@ wivrn::vdf::keyvalue const & wivrn::vdf::keyvalue::operator[](const char * key)
|
|||||||
|
|
||||||
wivrn::vdf::root::root(const std::filesystem::path & file)
|
wivrn::vdf::root::root(const std::filesystem::path & file)
|
||||||
{
|
{
|
||||||
boost::iostreams::mapped_file in{file};
|
try
|
||||||
opaque = in;
|
{
|
||||||
|
boost::iostreams::mapped_file_source in{file};
|
||||||
|
opaque = in;
|
||||||
|
|
||||||
const char * pos = in.begin();
|
const char * pos = in.begin();
|
||||||
key = read_string(pos, in.end());
|
key = read_string(pos, in.end());
|
||||||
value = read_value(pos, in.end());
|
value = read_value(pos, in.end());
|
||||||
|
}
|
||||||
|
catch (std::exception & e)
|
||||||
|
{
|
||||||
|
throw std::runtime_error(std::format("failed to parse {}: {}", file.native(), e.what()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump(const wivrn::vdf::keyvalue & kv, int depth)
|
void dump(const wivrn::vdf::keyvalue & kv, int depth)
|
||||||
|
|||||||
Reference in New Issue
Block a user