From 0f679dc34594f55c09cbd60055e809288c761794 Mon Sep 17 00:00:00 2001 From: Nicole O'Connor Date: Mon, 20 Jan 2025 16:31:48 -0800 Subject: [PATCH] cellar is now capable of finding your steam libraries --- CMakeLists.txt | 2 +- include/internal/steam.hpp | 10 ---------- include/internal/steam.hpp.cog | 26 ++++++++++++++++++++++++++ src/modules.txt | 1 + src/steam/commands.txt | 1 + src/steam/paths.cpp | 10 ++++++++++ src/steam/test_command.cpp | 11 +++++++++++ 7 files changed, 50 insertions(+), 11 deletions(-) delete mode 100644 include/internal/steam.hpp create mode 100644 include/internal/steam.hpp.cog create mode 100644 src/steam/commands.txt create mode 100644 src/steam/test_command.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fab757f..f8d387c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ set(src "${CMAKE_SOURCE_DIR}/src") set(libcellar_subdirs bottles config launch paths) if(ENABLE_STEAM) - list(APPEND steam) + list(APPEND libcellar_subdirs steam) endif() build_library(TARGET libcellar SUBDIRS ${libcellar_subdirs} diff --git a/include/internal/steam.hpp b/include/internal/steam.hpp deleted file mode 100644 index 9c21332..0000000 --- a/include/internal/steam.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include -#include - -namespace cellar { - namespace steam { - extern std::vector find_steam_libraries(); - } -} \ No newline at end of file diff --git a/include/internal/steam.hpp.cog b/include/internal/steam.hpp.cog new file mode 100644 index 0000000..4e30664 --- /dev/null +++ b/include/internal/steam.hpp.cog @@ -0,0 +1,26 @@ +#pragma once + +#include +#include +#include + +#include "commands.hpp" + +namespace cellar { + namespace steam { + extern std::vector find_steam_libraries(); + extern void test_command(int argc, std::vector argv); + /*[[[cog + import cog + + with open("src/steam/commands.txt") as commandsfile: + for line in commandsfile: + item = line.strip().split(" ") + cog.outl("extern void {0} (int, vector);".format(item[1])) + ]]]*/ + //[[[end]]] + } + namespace commands { + extern std::map steam_commands(); + } +} \ No newline at end of file diff --git a/src/modules.txt b/src/modules.txt index d5451df..9f4a953 100644 --- a/src/modules.txt +++ b/src/modules.txt @@ -2,3 +2,4 @@ core config bottles launch +steam \ No newline at end of file diff --git a/src/steam/commands.txt b/src/steam/commands.txt new file mode 100644 index 0000000..71e71c1 --- /dev/null +++ b/src/steam/commands.txt @@ -0,0 +1 @@ +steamtest test_command Test Steam related thing. \ No newline at end of file diff --git a/src/steam/paths.cpp b/src/steam/paths.cpp index bc3529c..9fcc10c 100644 --- a/src/steam/paths.cpp +++ b/src/steam/paths.cpp @@ -20,4 +20,14 @@ std::vector cellar::steam::find_steam_libraries() { std::ifstream fd_steam_library_config(str_steam_library_config); auto hnd_steam_library_config = vdf::read(fd_steam_library_config); + + std::vector result; + + for (auto hnd_library_def : hnd_steam_library_config.childs) { + std::string str_index = hnd_library_def.first; + auto hnd_library = hnd_library_def.second; + result.push_back(hnd_library->attribs["path"]); + } + + return result; } \ No newline at end of file diff --git a/src/steam/test_command.cpp b/src/steam/test_command.cpp new file mode 100644 index 0000000..c5b088e --- /dev/null +++ b/src/steam/test_command.cpp @@ -0,0 +1,11 @@ +#include + +#include "output.hpp" +#include "steam.hpp" +#include "internal/steam.hpp" + +void cellar::steam::test_command(int argc, std::vector argv) { + for (std::string str_path : cellar::steam::find_steam_libraries()) { + output::statement(str_path); + } +} \ No newline at end of file