'Generic Commit'
Some checks failed
Build-Test-Publish / build (linux/amd64) (push) Failing after 10s
Build-Test-Publish / build (linux/arm64) (push) Successful in 58s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Has been skipped
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Has been skipped

This commit is contained in:
Your Name 2025-06-22 14:21:09 +12:00
parent faf6d691d9
commit 92319ea70e
4 changed files with 15 additions and 23 deletions

View File

@ -1,13 +0,0 @@
#pragma once
#include <string>
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

View File

@ -7,7 +7,7 @@
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
#include "ArchiveManager.hpp" #include "archive_tgz.hpp"
namespace common { namespace common {
@ -29,9 +29,7 @@ static std::string shellEscape(const std::string& str) {
return result; return result;
} }
ArchiveManager::ArchiveManager() {} bool pack_tgz(const std::string& folderPath, const std::string& archivePath) {
bool ArchiveManager::pack(const std::string& folderPath, const std::string& archivePath) {
// Use system tar to create gzipped tarball // Use system tar to create gzipped tarball
std::ostringstream cmd; std::ostringstream cmd;
cmd << "tar -czf "; cmd << "tar -czf ";
@ -43,7 +41,7 @@ bool ArchiveManager::pack(const std::string& folderPath, const std::string& arch
return ret == 0; 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); fs::create_directories(outDir);
std::ostringstream cmd; std::ostringstream cmd;
cmd << "tar -xzf "; cmd << "tar -xzf ";

View File

@ -0,0 +1,9 @@
#pragma once
#include <string>
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

View File

@ -57,7 +57,7 @@
#include "BashrcEditor.hpp" #include "BashrcEditor.hpp"
#include "DropshellScriptManager.hpp" #include "DropshellScriptManager.hpp"
#include "GetbinClient.hpp" #include "GetbinClient.hpp"
#include "ArchiveManager.hpp" #include "archive_tgz.hpp"
#include "hash.hpp" #include "hash.hpp"
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -213,8 +213,7 @@ int install_tool(int argc, char* argv[]) {
} }
// Unpack tool // Unpack tool
common::ArchiveManager archiver; if (!common::unpack_tgz(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,8 +291,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());
common::ArchiveManager archiver; if (!common::pack_tgz(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;
} }