From 692ab2ff852eb70ddc0e07ad7780f09206fb3015 Mon Sep 17 00:00:00 2001 From: Marcel Nowicki Date: Fri, 11 Feb 2022 14:53:51 +0100 Subject: [PATCH] this added OS implementation of zlib. this also prototyped extracting the first 512 bytes of a tar.gz file and displaying the content of the first 100 bytes (name of the first file in the tarball) --- CMakeLists.txt | 6 ++++-- main.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4790f8..05e8f19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ 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) + + +add_executable(tarstats_pp main.cpp tarconst.h tarfunc.cpp tarfunc.h) +target_link_libraries(tarstats_pp -lz) diff --git a/main.cpp b/main.cpp index 81d1fec..3765034 100644 --- a/main.cpp +++ b/main.cpp @@ -68,6 +68,12 @@ int main(int argc, char** argv) { test.close(); if (x == '\213') std::cout << "success" << std::endl; + gzFile gzIn = gzopen("test4.tar.gz", "rb"); + gzbuffer(gzIn, 512); + char* testbuf = new char[512]; + gzread(gzIn, testbuf, 512); + std::string teststr (&testbuf[0], 100); + std::cout << teststr << '\n'; return 0; }