From faf6d691d980fe09798b4b3e2edd8550893b8860 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 22 Jun 2025 14:19:43 +1200 Subject: [PATCH] 'Generic Commit' --- .vscode/c_cpp_properties.json | 4 ++-- getpkg/src/{ => common}/ArchiveManager.cpp | 6 +++++- getpkg/src/{ => common}/ArchiveManager.hpp | 6 +++++- getpkg/src/main.cpp | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) rename getpkg/src/{ => common}/ArchiveManager.cpp (96%) rename getpkg/src/{ => common}/ArchiveManager.hpp (83%) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 9332000..987403f 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -8,9 +8,9 @@ "cppStandard": "c++23", "includePath": [ "${workspaceFolder}/getpkg/src", - "${workspaceFolder}/getpkg/src/autogen" + "${workspaceFolder}/getpkg/src/autogen", + "${workspaceFolder}/getpkg/src/common" ] - // ... other settings ... } ], "version": 4 diff --git a/getpkg/src/ArchiveManager.cpp b/getpkg/src/common/ArchiveManager.cpp similarity index 96% rename from getpkg/src/ArchiveManager.cpp rename to getpkg/src/common/ArchiveManager.cpp index 6e9a2e5..4cffc36 100644 --- a/getpkg/src/ArchiveManager.cpp +++ b/getpkg/src/common/ArchiveManager.cpp @@ -9,6 +9,8 @@ #include "ArchiveManager.hpp" +namespace common { + namespace fs = std::filesystem; // Escape string for shell command @@ -50,4 +52,6 @@ bool ArchiveManager::unpack(const std::string& archivePath, const std::string& o cmd << shellEscape(outDir); int ret = std::system(cmd.str().c_str()); return ret == 0; -} \ No newline at end of file +} + +} // namespace common \ No newline at end of file diff --git a/getpkg/src/ArchiveManager.hpp b/getpkg/src/common/ArchiveManager.hpp similarity index 83% rename from getpkg/src/ArchiveManager.hpp rename to getpkg/src/common/ArchiveManager.hpp index 3a91b3c..d46f932 100644 --- a/getpkg/src/ArchiveManager.hpp +++ b/getpkg/src/common/ArchiveManager.hpp @@ -1,9 +1,13 @@ #pragma once #include +namespace common { + class ArchiveManager { public: ArchiveManager(); bool pack(const std::string& folderPath, const std::string& archivePath); bool unpack(const std::string& archivePath, const std::string& outDir); -}; \ No newline at end of file +}; + +} // namespace common \ No newline at end of file diff --git a/getpkg/src/main.cpp b/getpkg/src/main.cpp index 95363ae..247bbaa 100644 --- a/getpkg/src/main.cpp +++ b/getpkg/src/main.cpp @@ -213,7 +213,7 @@ int install_tool(int argc, char* argv[]) { } // Unpack tool - ArchiveManager archiver; + common::ArchiveManager archiver; if (!archiver.unpack(archivePath.string(), binDir.string())) { std::cerr << "Failed to unpack tool archive." << std::endl; return 1; @@ -292,7 +292,7 @@ int publish_tool(int argc, char* argv[]) { std::filesystem::path archivePath = std::filesystem::path(home) / ".tmp" / (labeltag + ".tgz"); std::filesystem::create_directories(archivePath.parent_path()); - ArchiveManager archiver; + common::ArchiveManager archiver; if (!archiver.pack(folder, archivePath.string())) { std::cerr << "Failed to create archive." << std::endl; return 1;