mirror of
https://gitea.home.endeavr.de/Marcel/Tarstats-pp.git
synced 2025-12-10 00:39:01 +01:00
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:
@@ -1,7 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(Tarstats__)
|
||||
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -std=c++20")
|
||||
|
||||
add_executable(tarstats_pp main.cpp tarconst.h tarfunc.cpp tarfunc.h)
|
||||
target_link_libraries(tarstats_pp)
|
||||
|
||||
|
||||
16
main.cpp
16
main.cpp
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user