filename
This commit is contained in:
@@ -22,9 +22,10 @@ uint64_t get_hash_from_tgz(const std::string &file_path)
|
||||
std::ifstream file(file_path, std::ios::binary);
|
||||
if (!file) return 0;
|
||||
|
||||
char buffer[2];
|
||||
file.read(buffer, 2);
|
||||
if (buffer[0] != 0x1F || buffer[1] != 0x8B) return 0;
|
||||
int result = system("gunzip -t file.gz");
|
||||
if (result != 0) { // not a gzip file.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// gunzip the file to a new temporary directory
|
||||
TempDirectory temp_dir_manager("tgz_unpack_"); // Creates dir and schedules cleanup
|
||||
@@ -32,9 +33,8 @@ uint64_t get_hash_from_tgz(const std::string &file_path)
|
||||
|
||||
// unpack the file on disk
|
||||
std::string command = "tar -zxzf " + file_path + " -C " + temp_dir;
|
||||
int result = system(command.c_str()); // Basic tar extraction - requires 'tar' command
|
||||
result = system(command.c_str()); // Basic tar extraction - requires 'tar' command
|
||||
if (result != 0) {
|
||||
std::cerr << "Error unpacking tgz file: " << file_path << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user