this added some small refinements as well as first forays in working with gz files. Added zlib.h. Checked if valid gz file via mgic number.

This commit is contained in:
Marcel Nowicki
2022-02-11 03:28:13 +01:00
parent 0114829d5b
commit a80f78c36d
2 changed files with 19 additions and 0 deletions

View File

@@ -9,6 +9,7 @@
#include <filesystem>
#include "tarconst.h"
#include "tarfunc.h"
#include "zlib.h"
int main(int argc, char** argv) {
// Trivial check for arguments.
@@ -26,6 +27,7 @@ int main(int argc, char** argv) {
}
bool toFile = false;
bool toJSON = false;
bool g = false;
std::vector<std::string> archiveFilename {};
for (auto i : cmdparam) {
@@ -44,6 +46,9 @@ int main(int argc, char** argv) {
case 'h':
tar::printhelp();
return 9;
case 'g':
g = true;
break;
case '-':
break;
default:
@@ -55,6 +60,17 @@ int main(int argc, char** argv) {
}
}
if (g) {
std::ifstream test("test4.tar.gz", std::ios::binary);
char x;
test.seekg(1);
test.read((&x), 1);
test.close();
if (x == '\213')
std::cout << "success" << std::endl;
return 0;
}
for (auto &archiveName : archiveFilename) {
//count the types of all items
std::map<std::string, uintmax_t> typecount{