From 3079cb842283db4c488d229ed93e9c390dc79c8b Mon Sep 17 00:00:00 2001 From: DRAGONTOS Date: Sat, 19 Oct 2024 17:04:24 +0200 Subject: [PATCH] bumped: (0.1.5) moved slashing to regex.cpp --- PKGBUILD | 2 +- props.json | 2 +- src/Regex.cpp | 12 ++++++++++++ src/includes/Regex.hpp | 7 ++++++- src/main.cpp | 19 ++++--------------- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index d4fd7a7..9fe2823 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,6 +1,6 @@ pkgname=stc-git _gitname=stc -pkgver=0.1.4 +pkgver=0.1.5 pkgrel=1 pkgdesc="Easily download collections and mods from steam." url="https://github.com/DRAGONTOS/stc" diff --git a/props.json b/props.json index 04cf9c3..74a6a2d 100644 --- a/props.json +++ b/props.json @@ -1,3 +1,3 @@ { - "version": "0.1.4" + "version": "0.1.5" } diff --git a/src/Regex.cpp b/src/Regex.cpp index 9fa1282..a74858c 100644 --- a/src/Regex.cpp +++ b/src/Regex.cpp @@ -63,3 +63,15 @@ void Regex(cmd *inputCmd) { outputFile.close(); } } + +void slashing(cmd *inputCmd) { + //checks if a "\" is needed or not + std::ifstream idscount{inputCmd->cacheid}; + + for (std::string line; std::getline(idscount, line); ) { + inputCmd->step++; + } + + inputCmd->slash = (inputCmd->step == 2) ? R"( )": R"( \ )"; + idscount.close(); +} diff --git a/src/includes/Regex.hpp b/src/includes/Regex.hpp index 16981f2..bd53635 100644 --- a/src/includes/Regex.hpp +++ b/src/includes/Regex.hpp @@ -2,6 +2,7 @@ #define REGEX_H #include +// all the var's struct cmd { const char *userHome = getenv("HOME"); @@ -16,9 +17,13 @@ std::string pass; std::string gameid; std::string dir; -int ab = 0; +int ab = 0; +int step = 0; + +std::string slash; }; // void Regex(const std::string& collectionid, const std::string& gameid, const std::string& cacheid, const std::string& cachesc); void Regex(cmd *inputCmd); +void slashing(cmd *inputCmd); #endif diff --git a/src/main.cpp b/src/main.cpp index 37554a1..758b5ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,11 +19,10 @@ std::string woof(std::ifstream &meow) { } int main(int argc, char **argv, char **envp) { - // struct cmd cmd inputCmd; - inputCmd.dir = std::filesystem::current_path(); + inputCmd.dir = std::filesystem::current_path(); // Removes cache if (std::filesystem::exists(inputCmd.cacheid) && std::filesystem::is_directory(inputCmd.cacheid)) { @@ -164,27 +163,17 @@ int main(int argc, char **argv, char **envp) { // regex function Regex(&inputCmd); - - //checks if a "\" is needed or not - std::ifstream idscount{inputCmd.cacheid}; - int step = 0; - - for (std::string line; std::getline(idscount, line); ) { - step++; - } - - std::string slash = (step == 2) ? R"( )": R"( \ )"; - idscount.close(); + slashing(&inputCmd); //gets the ids std::ifstream ids{inputCmd.cacheid}; std::string idsm = (inputCmd.ab == 1) ? R"( +workshop_download_item )" + inputCmd.gameid + " " + inputCmd.modid + " +quit": R"()"; // main command - system(std::string{"sh ~/Steam/steamcmd.sh +force_install_dir " + inputCmd.dir + " +login " + inputCmd.user + inputCmd.pass + slash + idsm + woof(ids)}.c_str()); + system(std::string{"sh ~/Steam/steamcmd.sh +force_install_dir " + inputCmd.dir + " +login " + inputCmd.user + inputCmd.pass + inputCmd.slash + idsm + woof(ids)}.c_str()); // shows how much and what has downloaded - std::string mods = (!inputCmd.modid.empty()) ? "" : R"(Mods: )" + std::to_string(step -1) + "\n"; + std::string mods = (!inputCmd.modid.empty()) ? "" : R"(Mods: )" + std::to_string(inputCmd.step -1) + "\n"; std::string colm = (inputCmd.ab == 1) ? R"(Mod)": R"(Collection)"; std::cout << "\n\n" + mods + colm + " has been downloaded too: " + inputCmd.dir + "\n";