debug settings for gdb in vscode; steamtest now reports which apps have bottles managed by steam automatically

This commit is contained in:
Nicole O'Connor 2025-01-25 19:15:05 -08:00
parent 9ad87ba79b
commit 19251a253f
4 changed files with 87 additions and 21 deletions

28
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,28 @@
{
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/cellar",
"args": ["steamtest"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}

View File

@ -1,4 +1,4 @@
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(PLATFORM_FOREIGN_ENV FALSE)

View File

@ -9,7 +9,7 @@
#include "output.hpp"
using namespace std;
using namespace boost;
//using namespace boost;
using namespace cellar;
using namespace fs;
@ -21,10 +21,10 @@ void cbnull_remove(string src) { return; }
vector<string> fs::listdir(string path) {
vector<string> result;
filesystem::path cwd(path);
filesystem::directory_iterator iter_end;
boost::filesystem::path cwd(path);
boost::filesystem::directory_iterator iter_end;
for (filesystem::directory_iterator iter_cwd(cwd); iter_cwd != iter_end; ++iter_cwd) {
for (boost::filesystem::directory_iterator iter_cwd(cwd); iter_cwd != iter_end; ++iter_cwd) {
string item = iter_cwd->path().filename().native();
result.push_back(item);
@ -33,10 +33,10 @@ vector<string> fs::listdir(string path) {
}
bool fs::recursive_copy(string src, string dst, CopyCallbackFunc callback) {
if (!filesystem::exists(dst)) {
if (!boost::filesystem::exists(dst)) {
if (dryrun) { output::statement("mkdir: " + dst); }
else {
bool success = filesystem::create_directory(dst);
bool success = boost::filesystem::create_directory(dst);
if (!success) { return false; }
}
}
@ -45,17 +45,17 @@ bool fs::recursive_copy(string src, string dst, CopyCallbackFunc callback) {
string itemabs = src + "/" + itemrel;
string targetabs = dst + "/" + itemrel;
auto itemstat = filesystem::symlink_status(itemabs);
auto itemstat = boost::filesystem::symlink_status(itemabs);
if (filesystem::is_directory(itemstat)) { recursive_copy(itemabs, targetabs, callback); }
else if (filesystem::is_symlink(itemstat)) {
auto symlinkpath = filesystem::read_symlink(itemabs);
if (boost::filesystem::is_directory(itemstat)) { recursive_copy(itemabs, targetabs, callback); }
else if (boost::filesystem::is_symlink(itemstat)) {
auto symlinkpath = boost::filesystem::read_symlink(itemabs);
if (dryrun) { output::statement("symlink: " + symlinkpath.native() + " => " + targetabs); }
else { filesystem::create_symlink(symlinkpath, targetabs); }
else { boost::filesystem::create_symlink(symlinkpath, targetabs); }
}
else {
if (dryrun) { output::statement("copy: " + itemabs + " => " + targetabs); }
else { filesystem::copy(itemabs, targetabs); }
else { boost::filesystem::copy(itemabs, targetabs); }
}
callback(itemabs, targetabs);
@ -67,24 +67,24 @@ bool fs::recursive_copy(string src, string dst, CopyCallbackFunc callback) {
bool fs::recursive_copy(string src, string dst) { return recursive_copy(src, dst, cbnull_copy); }
bool fs::recursive_remove(string target, RemoveCallbackFunc callback) {
if (!filesystem::exists(target)) { return false; }
if (!boost::filesystem::exists(target)) { return false; }
for (string itemrel : listdir(target)) {
string itemabs = target + "/" + itemrel;
auto itemstat = filesystem::symlink_status(itemabs);
auto itemstat = boost::filesystem::symlink_status(itemabs);
if (filesystem::is_directory(itemstat)) { recursive_remove(itemabs, callback); }
if (boost::filesystem::is_directory(itemstat)) { recursive_remove(itemabs, callback); }
else {
if (dryrun) { output::error("rm: " + itemabs); }
else { filesystem::remove(itemabs); }
else { boost::filesystem::remove(itemabs); }
}
callback(itemabs);
}
if (dryrun) { output::error("rm: " + target); }
else { filesystem::remove(target); }
else { boost::filesystem::remove(target); }
return true;
}

View File

@ -1,11 +1,49 @@
#include <iostream>
#include <cstdlib>
#include <filesystem>
#include <format>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include "vdf_parser.hpp"
#include "bottles.hpp"
#include "output.hpp"
#include "steam.hpp"
#include "internal/steam.hpp"
using namespace tyti; // vdf
void cellar::steam::test_command(int argc, std::vector<std::string> argv) {
for (std::string str_path : cellar::steam::find_steam_libraries()) {
output::statement(str_path);
for (std::string str_path_library : cellar::steam::find_steam_libraries()) {
output::statement(str_path_library);
std::filesystem::path pth_library(str_path_library);
std::filesystem::path pth_steam_cellar = pth_library / "steamapps/compatdata";
for (auto const& itm_appid : std::filesystem::directory_iterator(pth_steam_cellar)) {
auto pth_appid = itm_appid.path();
if (std::filesystem::is_directory(pth_appid / "pfx") && ! std::filesystem::is_empty(pth_appid / "pfx")) {
// \/ string-to-unsigned-long
std::string str_appid = pth_appid.filename().string(); // should become, e.g. 1124300
auto pth_appmanifest = pth_library / ("steamapps/appmanifest_" + str_appid + ".acf");
if (! std::filesystem::exists(pth_appmanifest) ) { continue; }
std::string str_gamename = "";
std::ifstream fd_appmanifest(pth_appmanifest);
auto hnd_appmanifest = vdf::read(fd_appmanifest);
for (auto hnd_appmanifest_def : hnd_appmanifest.attribs) {
std::string str_index = hnd_appmanifest_def.first;
std::string str_value = hnd_appmanifest_def.second;
if (str_index == "name") {
str_gamename = str_value;
break;
}
}
output::warning("Steam App #" + str_appid + " (" + str_gamename + ")");
}
}
}
}