diff --git a/getpkg/src/common/ArchiveManager.hpp b/getpkg/src/common/ArchiveManager.hpp deleted file mode 100644 index d46f932..0000000 --- a/getpkg/src/common/ArchiveManager.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#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); -}; - -} // namespace common \ No newline at end of file diff --git a/getpkg/src/common/ArchiveManager.cpp b/getpkg/src/common/archive_tgz.cpp similarity index 81% rename from getpkg/src/common/ArchiveManager.cpp rename to getpkg/src/common/archive_tgz.cpp index 4cffc36..94fd856 100644 --- a/getpkg/src/common/ArchiveManager.cpp +++ b/getpkg/src/common/archive_tgz.cpp @@ -7,7 +7,7 @@ #include #include -#include "ArchiveManager.hpp" +#include "archive_tgz.hpp" namespace common { @@ -29,9 +29,7 @@ static std::string shellEscape(const std::string& str) { return result; } -ArchiveManager::ArchiveManager() {} - -bool ArchiveManager::pack(const std::string& folderPath, const std::string& archivePath) { +bool pack_tgz(const std::string& folderPath, const std::string& archivePath) { // Use system tar to create gzipped tarball std::ostringstream cmd; cmd << "tar -czf "; @@ -43,7 +41,7 @@ bool ArchiveManager::pack(const std::string& folderPath, const std::string& arch return ret == 0; } -bool ArchiveManager::unpack(const std::string& archivePath, const std::string& outDir) { +bool unpack_tgz(const std::string& archivePath, const std::string& outDir) { fs::create_directories(outDir); std::ostringstream cmd; cmd << "tar -xzf "; diff --git a/getpkg/src/common/archive_tgz.hpp b/getpkg/src/common/archive_tgz.hpp new file mode 100644 index 0000000..8599c31 --- /dev/null +++ b/getpkg/src/common/archive_tgz.hpp @@ -0,0 +1,9 @@ +#pragma once +#include + +namespace common { + + bool pack_tgz(const std::string& folderPath, const std::string& archivePath); + bool unpack_tgz(const std::string& archivePath, const std::string& outDir); + +} // namespace common \ No newline at end of file diff --git a/getpkg/src/main.cpp b/getpkg/src/main.cpp index 247bbaa..eee97e8 100644 --- a/getpkg/src/main.cpp +++ b/getpkg/src/main.cpp @@ -57,7 +57,7 @@ #include "BashrcEditor.hpp" #include "DropshellScriptManager.hpp" #include "GetbinClient.hpp" -#include "ArchiveManager.hpp" +#include "archive_tgz.hpp" #include "hash.hpp" #include #include @@ -213,8 +213,7 @@ int install_tool(int argc, char* argv[]) { } // Unpack tool - common::ArchiveManager archiver; - if (!archiver.unpack(archivePath.string(), binDir.string())) { + if (!common::unpack_tgz(archivePath.string(), binDir.string())) { std::cerr << "Failed to unpack tool archive." << std::endl; return 1; } @@ -292,8 +291,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()); - common::ArchiveManager archiver; - if (!archiver.pack(folder, archivePath.string())) { + if (!common::pack_tgz(folder, archivePath.string())) { std::cerr << "Failed to create archive." << std::endl; return 1; }