diff --git a/PKGBUILD b/PKGBUILD index 9fe2823..5223291 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,6 +1,6 @@ pkgname=stc-git _gitname=stc -pkgver=0.1.5 +pkgver=0.1.6 pkgrel=1 pkgdesc="Easily download collections and mods from steam." url="https://github.com/DRAGONTOS/stc" diff --git a/line-count b/line-count index c0b1635..fd66832 100644 --- a/line-count +++ b/line-count @@ -1,8 +1,8 @@ =============================================================================== Language Files Lines Code Comments Blanks =============================================================================== - C++ 4 319 251 21 47 - C++ Header 4 66 53 5 8 + C++ 4 389 320 21 48 + C++ Header 4 73 59 5 9 =============================================================================== - Total 8 385 304 26 55 + Total 8 462 379 26 57 =============================================================================== diff --git a/props.json b/props.json index 74a6a2d..4d652e2 100644 --- a/props.json +++ b/props.json @@ -1,3 +1,3 @@ { - "version": "0.1.5" + "version": "0.1.6" } diff --git a/src/Regex.cpp b/src/Regex.cpp index d7427c4..d9bc249 100644 --- a/src/Regex.cpp +++ b/src/Regex.cpp @@ -1,3 +1,6 @@ +#include +#include +#include #include #include #include "regex" @@ -48,3 +51,60 @@ void Regex(cmd *inputCmd) { inputCmd->slashtp++; } } + +void filerestort(cmd *inputCmd) { + std::filesystem::path steamdir = std::string(inputCmd->userHome) + "/.cache/steamapps/workshop/content/" + inputCmd->gameid + "/" + inputCmd->idnumber; + std::filesystem::path modname = inputCmd->dir + "/" + inputCmd->idname; + + // renames and moves the files. + try { + if (std::filesystem::exists(steamdir)) { + if (std::filesystem::exists(modname)) { + std::filesystem::remove_all(modname); + } + std::filesystem::rename(steamdir, modname); + } else { + std::cerr << "Error: The directory " << steamdir << " does not exist." << std::endl; + } + } catch (const std::filesystem::filesystem_error& e) { + std::cerr << "Filesystem error: " << e.what() << std::endl; + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << std::endl; + } +} + +void Modname(cmd *inputCmd, std::string input) { + if (!inputCmd->sucids.empty()) { + std::regex downloadItemRegex(R"(Downloaded item (\d+))"); + + std::smatch match; + if (std::regex_search(input, match, downloadItemRegex)) { + std::string downloadItemNumber = match[1].str(); + inputCmd->idnumber = downloadItemNumber; + } + + std::istringstream inputStream(inputCmd->source); + + std::regex grepRegex("\"id\":\"" + inputCmd->idnumber + "\",\"title\":\""); + std::string line; + + while (std::getline(inputStream, line)) { + + if (std::regex_search(line, grepRegex)) { + + std::size_t divPos = line.find("\",\"description\":"); + if (divPos != std::string::npos) { + line = line.substr(0, divPos); // Trim everything after '">