'Generic Commit'
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 48s
Build-Test-Publish / build (linux/arm64) (push) Successful in 57s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Successful in 8s
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Successful in 8s

This commit is contained in:
Your Name 2025-06-22 14:19:43 +12:00
parent bdf8ac66b0
commit faf6d691d9
4 changed files with 14 additions and 6 deletions

View File

@ -8,9 +8,9 @@
"cppStandard": "c++23", "cppStandard": "c++23",
"includePath": [ "includePath": [
"${workspaceFolder}/getpkg/src", "${workspaceFolder}/getpkg/src",
"${workspaceFolder}/getpkg/src/autogen" "${workspaceFolder}/getpkg/src/autogen",
"${workspaceFolder}/getpkg/src/common"
] ]
// ... other settings ...
} }
], ],
"version": 4 "version": 4

View File

@ -9,6 +9,8 @@
#include "ArchiveManager.hpp" #include "ArchiveManager.hpp"
namespace common {
namespace fs = std::filesystem; namespace fs = std::filesystem;
// Escape string for shell command // Escape string for shell command
@ -51,3 +53,5 @@ bool ArchiveManager::unpack(const std::string& archivePath, const std::string& o
int ret = std::system(cmd.str().c_str()); int ret = std::system(cmd.str().c_str());
return ret == 0; return ret == 0;
} }
} // namespace common

View File

@ -1,9 +1,13 @@
#pragma once #pragma once
#include <string> #include <string>
namespace common {
class ArchiveManager { class ArchiveManager {
public: public:
ArchiveManager(); ArchiveManager();
bool pack(const std::string& folderPath, const std::string& archivePath); bool pack(const std::string& folderPath, const std::string& archivePath);
bool unpack(const std::string& archivePath, const std::string& outDir); bool unpack(const std::string& archivePath, const std::string& outDir);
}; };
} // namespace common

View File

@ -213,7 +213,7 @@ int install_tool(int argc, char* argv[]) {
} }
// Unpack tool // Unpack tool
ArchiveManager archiver; common::ArchiveManager archiver;
if (!archiver.unpack(archivePath.string(), binDir.string())) { if (!archiver.unpack(archivePath.string(), binDir.string())) {
std::cerr << "Failed to unpack tool archive." << std::endl; std::cerr << "Failed to unpack tool archive." << std::endl;
return 1; 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::path archivePath = std::filesystem::path(home) / ".tmp" / (labeltag + ".tgz");
std::filesystem::create_directories(archivePath.parent_path()); std::filesystem::create_directories(archivePath.parent_path());
ArchiveManager archiver; common::ArchiveManager archiver;
if (!archiver.pack(folder, archivePath.string())) { if (!archiver.pack(folder, archivePath.string())) {
std::cerr << "Failed to create archive." << std::endl; std::cerr << "Failed to create archive." << std::endl;
return 1; return 1;