sebastiandev / zipper Goto Github PK
View Code? Open in Web Editor NEWC++ wrapper around minizip compression library
License: MIT License
C++ wrapper around minizip compression library
License: MIT License
Currently your cmake does not produce lot of compilation flags. Could be nice to add -O2 -W -Wall.
And why not an option for address sanitizer (do not call with valgrind) ?
CXXFLAGS += -O1 -g -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls
LDFLAGS += -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls
LIBS += -static-libstdc++ -static-libasan
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer)
Look:
----------------------------------------------------------------------
Zipper version 0.9.1
----------------------------------------------------------------------
Configured on host ''
host type = Linux
host operating system = Linux 4.10.0-35-generic
host CPU architecture = i686
General build flags:
CC = /usr/bin/cc
CXX = /usr/bin/c++
CPPFLAGS = -DLINUX
CFLAGS = -fno-strict-aliasing -fPIC
CXXFLAGS = -fno-strict-aliasing -fPIC
LDFLAGS = -L/usr/local/lib
Zlib library configuration:
Zlib library = /usr/lib/i386-linux-gnu/libz.so
Zlib include dir = /usr/include
Other configuration settings:
Installation $prefix = /usr/local
Hi,
It is noobish question , I faced a big problem on my project while using your library , I got error of unresolved external symbol :
1>------ Build started: Project: Real-Engine, Configuration: Debug x64 ------
1>libZipper-static.lib(unzip.obj) : error LNK2019: unresolved external symbol inflate referenced in function unzReadCurrentFile
1>libZipper-static.lib(unzip.obj) : error LNK2019: unresolved external symbol inflateEnd referenced in function unzCloseCurrentFile
1>libZipper-static.lib(unzip.obj) : error LNK2019: unresolved external symbol crc32 referenced in function unzReadCurrentFile
1>libZipper-static.lib(tools.obj) : error LNK2001: unresolved external symbol crc32
1>libZipper-static.lib(unzip.obj) : error LNK2019: unresolved external symbol inflateInit2_ referenced in function unzOpenCurrentFile3
1>libZipper-static.lib(unzip.obj) : error LNK2019: unresolved external symbol get_crc_table referenced in function unzOpenCurrentFile3
1>E:\Project\Real-Engine\Real-Engine\x64\Debug\Real-Engine.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I build zlib and zipper for x64 platform windows of course without any error on the process but i try to build up my project can not the error.
I added on my project settings :
• "libZipper-static.lib" On Additional Dependencies
• "E:\Project\Real-Engine\zipper-master\build\Debug" On Additional Library Directories
I re-compiled every thing but still get that error. If you can not find a solution post how i Compile it with steps if i did a mistake on compiling and thx !
• My code :
#include "zipper\unzipper.h"
#include "CGame.h"
int main()
{
std::string key = "PASS";
std::string word = "WORD";
std::string cword = re::CGame::encrypt(word, key);
std::vector<unsigned char> mem;
zipper::Unzipper uz_content("Content.PREP", cword);
uz_content.extractEntryToMemory("icon.jpeg", mem);
uz_content.close();
return 0;
}
Hi Sebastiandev
I am searching for a c++ zip generator and zipper seems to be the solution.
It is posible to compile it with mac?
Thanks for the help
David
==84530== Memcheck, a memory error detector
==84530== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==84530== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==84530== Command: ./Zipper-test
==84530==
--84530-- run: /usr/bin/dsymutil "./Zipper-test"
warning: no debug symbols in executable (-arch x86_64)
--84530-- UNKNOWN mach_msg unhandled MACH_SEND_TRAILER option
--84530-- UNKNOWN mach_msg unhandled MACH_SEND_TRAILER option (repeated 2 times)
--84530-- UNKNOWN mach_msg unhandled MACH_SEND_TRAILER option (repeated 4 times)
==84530== Conditional jump or move depends on uninitialised value(s)
==84530== at 0x100733A28: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10004ED60: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100053F65: zipper::Unzipper::Impl::extractToFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, zipper::ZipEntry&) (in ./Zipper-test)
==84530== by 0x100053C7E: zipper::Unzipper::Impl::extractCurrentEntryToFile(zipper::ZipEntry&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100052F84: zipper::Unzipper::Impl::extractAll(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&) (in ./Zipper-test)
==84530== by 0x10005316D: zipper::Unzipper::extract(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100003ED8: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== by 0x10000EE84: Catch::RunContext::runTest(Catch::TestCase const&) (in ./Zipper-test)
==84530== Uninitialised value was created by a stack allocation
==84530== at 0x10004E949: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530==
==84530== Conditional jump or move depends on uninitialised value(s)
==84530== at 0x100733A28: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10004EE01: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100053F65: zipper::Unzipper::Impl::extractToFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, zipper::ZipEntry&) (in ./Zipper-test)
==84530== by 0x100053C7E: zipper::Unzipper::Impl::extractCurrentEntryToFile(zipper::ZipEntry&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100052F84: zipper::Unzipper::Impl::extractAll(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&) (in ./Zipper-test)
==84530== by 0x10005316D: zipper::Unzipper::extract(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100003ED8: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== by 0x10000EE84: Catch::RunContext::runTest(Catch::TestCase const&) (in ./Zipper-test)
==84530== Uninitialised value was created by a stack allocation
==84530== at 0x10004E949: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530==
==84530== Invalid read of size 16
==84530== at 0x100733A05: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10004ED60: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x1000044D8: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== by 0x10000EE84: Catch::RunContext::runTest(Catch::TestCase const&) (in ./Zipper-test)
==84530== by 0x10000E744: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530== by 0x100031443: Catch::Session::run() (in ./Zipper-test)
==84530== by 0x10001C9C7: main (in ./Zipper-test)
==84530== Address 0x100f66b80 is 16 bytes before a block of size 80 alloc'd
==84530== at 0x100154086: malloc (in /usr/local/Cellar/valgrind/3.14.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==84530== by 0x100DD9627: operator new(unsigned long) (in /usr/lib/libc++abi.dylib)
==84530== by 0x1001B3F08: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in /usr/lib/libc++.1.dylib)
==84530== by 0x10004EC98: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x1000044D8: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== by 0x10000EE84: Catch::RunContext::runTest(Catch::TestCase const&) (in ./Zipper-test)
==84530== by 0x10000E744: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530== by 0x100031443: Catch::Session::run() (in ./Zipper-test)
==84530==
==84530== Invalid read of size 16
==84530== at 0x100733A05: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10004EE01: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x1000044D8: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== by 0x10000EE84: Catch::RunContext::runTest(Catch::TestCase const&) (in ./Zipper-test)
==84530== by 0x10000E744: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530== by 0x100031443: Catch::Session::run() (in ./Zipper-test)
==84530== by 0x10001C9C7: main (in ./Zipper-test)
==84530== Address 0x100f66b80 is 16 bytes before a block of size 80 alloc'd
==84530== at 0x100154086: malloc (in /usr/local/Cellar/valgrind/3.14.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==84530== by 0x100DD9627: operator new(unsigned long) (in /usr/lib/libc++abi.dylib)
==84530== by 0x1001B3F08: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in /usr/lib/libc++.1.dylib)
==84530== by 0x10004EC98: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x1000044D8: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== by 0x10000EE84: Catch::RunContext::runTest(Catch::TestCase const&) (in ./Zipper-test)
==84530== by 0x10000E744: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530== by 0x100031443: Catch::Session::run() (in ./Zipper-test)
==84530==
==84530== Conditional jump or move depends on uninitialised value(s)
==84530== at 0x100733A28: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10004ED60: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EB83: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x1000044D8: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== by 0x10000EE84: Catch::RunContext::runTest(Catch::TestCase const&) (in ./Zipper-test)
==84530== by 0x10000E744: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530== by 0x100031443: Catch::Session::run() (in ./Zipper-test)
==84530== by 0x10001C9C7: main (in ./Zipper-test)
==84530== Uninitialised value was created by a heap allocation
==84530== at 0x100154086: malloc (in /usr/local/Cellar/valgrind/3.14.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==84530== by 0x100DD9627: operator new(unsigned long) (in /usr/lib/libc++abi.dylib)
==84530== by 0x1001B3F08: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in /usr/lib/libc++.1.dylib)
==84530== by 0x10004EC98: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EB83: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x1000044D8: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== by 0x10000EE84: Catch::RunContext::runTest(Catch::TestCase const&) (in ./Zipper-test)
==84530== by 0x10000E744: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530==
==84530== Conditional jump or move depends on uninitialised value(s)
==84530== at 0x100733A28: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10004EE01: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EB83: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x1000044D8: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== by 0x10000EE84: Catch::RunContext::runTest(Catch::TestCase const&) (in ./Zipper-test)
==84530== by 0x10000E744: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530== by 0x100031443: Catch::Session::run() (in ./Zipper-test)
==84530== by 0x10001C9C7: main (in ./Zipper-test)
==84530== Uninitialised value was created by a heap allocation
==84530== at 0x100154086: malloc (in /usr/local/Cellar/valgrind/3.14.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==84530== by 0x100DD9627: operator new(unsigned long) (in /usr/lib/libc++abi.dylib)
==84530== by 0x1001B3F08: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in /usr/lib/libc++.1.dylib)
==84530== by 0x10004EC98: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EB83: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x1000044D8: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== by 0x10000EE84: Catch::RunContext::runTest(Catch::TestCase const&) (in ./Zipper-test)
==84530== by 0x10000E744: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530==
==84530== Invalid read of size 16
==84530== at 0x100733A05: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10004ED60: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EB83: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100053F65: zipper::Unzipper::Impl::extractToFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, zipper::ZipEntry&) (in ./Zipper-test)
==84530== by 0x100053C7E: zipper::Unzipper::Impl::extractCurrentEntryToFile(zipper::ZipEntry&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100052F84: zipper::Unzipper::Impl::extractAll(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&) (in ./Zipper-test)
==84530== by 0x10005316D: zipper::Unzipper::extract(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100004D7F: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== Address 0x101095420 is 16 bytes before a block of size 80 alloc'd
==84530== at 0x100154086: malloc (in /usr/local/Cellar/valgrind/3.14.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==84530== by 0x100DD9627: operator new(unsigned long) (in /usr/lib/libc++abi.dylib)
==84530== by 0x1001B3F08: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in /usr/lib/libc++.1.dylib)
==84530== by 0x10004EC98: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EB83: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100053F65: zipper::Unzipper::Impl::extractToFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, zipper::ZipEntry&) (in ./Zipper-test)
==84530== by 0x100053C7E: zipper::Unzipper::Impl::extractCurrentEntryToFile(zipper::ZipEntry&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100052F84: zipper::Unzipper::Impl::extractAll(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&) (in ./Zipper-test)
==84530== by 0x10005316D: zipper::Unzipper::extract(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100004D7F: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530==
==84530== Invalid read of size 16
==84530== at 0x100733A05: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10004EE01: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EB83: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100053F65: zipper::Unzipper::Impl::extractToFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, zipper::ZipEntry&) (in ./Zipper-test)
==84530== by 0x100053C7E: zipper::Unzipper::Impl::extractCurrentEntryToFile(zipper::ZipEntry&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100052F84: zipper::Unzipper::Impl::extractAll(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&) (in ./Zipper-test)
==84530== by 0x10005316D: zipper::Unzipper::extract(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100004D7F: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530== by 0x100027855: Catch::RunContext::invokeActiveTestCase() (in ./Zipper-test)
==84530== by 0x100027097: Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (in ./Zipper-test)
==84530== Address 0x101095420 is 16 bytes before a block of size 80 alloc'd
==84530== at 0x100154086: malloc (in /usr/local/Cellar/valgrind/3.14.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==84530== by 0x100DD9627: operator new(unsigned long) (in /usr/lib/libc++abi.dylib)
==84530== by 0x1001B3F08: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in /usr/lib/libc++.1.dylib)
==84530== by 0x10004EC98: zipper::CDirEntry::normalize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EADD: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x10004EB83: zipper::CDirEntry::createDir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100051300: zipper::makedir(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100053F65: zipper::Unzipper::Impl::extractToFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, zipper::ZipEntry&) (in ./Zipper-test)
==84530== by 0x100053C7E: zipper::Unzipper::Impl::extractCurrentEntryToFile(zipper::ZipEntry&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100052F84: zipper::Unzipper::Impl::extractAll(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&) (in ./Zipper-test)
==84530== by 0x10005316D: zipper::Unzipper::extract(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in ./Zipper-test)
==84530== by 0x100004D7F: ____C_A_T_C_H____T_E_S_T____15() (in ./Zipper-test)
==84530==
==84530== Conditional jump or move depends on uninitialised value(s)
==84530== at 0x100733A28: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10045BBA5: __sfvwrite (in /usr/lib/system/libsystem_c.dylib)
==84530== by 0x10045BF59: fwrite (in /usr/lib/system/libsystem_c.dylib)
==84530== by 0x10000BA34: std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) (in ./Zipper-test)
==84530== by 0x10000B871: std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) (in ./Zipper-test)
==84530== by 0x100029D3A: Catch::(anonymous namespace)::PosixColourImpl::use(Catch::Colour::Code) (in ./Zipper-test)
==84530== by 0x10001221D: Catch::Colour::use(Catch::Colour::Code) (in ./Zipper-test)
==84530== by 0x100043525: Catch::ConsoleReporter::printTotalsDivider(Catch::Totals const&) (in ./Zipper-test)
==84530== by 0x1000220A0: Catch::ConsoleReporter::testRunEnded(Catch::TestRunStats const&) (in ./Zipper-test)
==84530== by 0x100027ED9: Catch::RunContext::~RunContext() (in ./Zipper-test)
==84530== by 0x10000E883: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530== by 0x100031443: Catch::Session::run() (in ./Zipper-test)
==84530== Uninitialised value was created by a stack allocation
==84530== at 0x100029BB0: Catch::(anonymous namespace)::PosixColourImpl::use(Catch::Colour::Code) (in ./Zipper-test)
==84530==
==84530== Invalid read of size 16
==84530== at 0x100733A65: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10045BBA5: __sfvwrite (in /usr/lib/system/libsystem_c.dylib)
==84530== by 0x10045BF59: fwrite (in /usr/lib/system/libsystem_c.dylib)
==84530== by 0x10000BA34: std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) (in ./Zipper-test)
==84530== by 0x10000B871: std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) (in ./Zipper-test)
==84530== by 0x1000438B8: Catch::ConsoleReporter::printTotalsDivider(Catch::Totals const&) (in ./Zipper-test)
==84530== by 0x1000220A0: Catch::ConsoleReporter::testRunEnded(Catch::TestRunStats const&) (in ./Zipper-test)
==84530== by 0x100027ED9: Catch::RunContext::~RunContext() (in ./Zipper-test)
==84530== by 0x10000E883: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530== by 0x100031443: Catch::Session::run() (in ./Zipper-test)
==84530== by 0x10001C9C7: main (in ./Zipper-test)
==84530== Address 0x1013adad0 is 0 bytes after a block of size 80 alloc'd
==84530== at 0x100154086: malloc (in /usr/local/Cellar/valgrind/3.14.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==84530== by 0x100DD9627: operator new(unsigned long) (in /usr/lib/libc++abi.dylib)
==84530== by 0x100043869: Catch::ConsoleReporter::printTotalsDivider(Catch::Totals const&) (in ./Zipper-test)
==84530== by 0x1000220A0: Catch::ConsoleReporter::testRunEnded(Catch::TestRunStats const&) (in ./Zipper-test)
==84530== by 0x100027ED9: Catch::RunContext::~RunContext() (in ./Zipper-test)
==84530== by 0x10000E883: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530== by 0x100031443: Catch::Session::run() (in ./Zipper-test)
==84530== by 0x10001C9C7: main (in ./Zipper-test)
==84530==
===============================================================================
==84530== Conditional jump or move depends on uninitialised value(s)
==84530== at 0x100733A28: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
==84530== by 0x10045BBA5: __sfvwrite (in /usr/lib/system/libsystem_c.dylib)
==84530== by 0x10045BF59: fwrite (in /usr/lib/system/libsystem_c.dylib)
==84530== by 0x1001952EB: std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) (in /usr/lib/libc++.1.dylib)
==84530== by 0x1001955C8: std::__1::num_put<char, std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > >::do_put(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, std::__1::ios_base&, char, unsigned long) const (in /usr/lib/libc++.1.dylib)
==84530== by 0x1001893C5: std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(unsigned long) (in /usr/lib/libc++.1.dylib)
==84530== by 0x100041681: Catch::ConsoleReporter::printTotals(Catch::Totals const&) (in ./Zipper-test)
==84530== by 0x1000220AB: Catch::ConsoleReporter::testRunEnded(Catch::TestRunStats const&) (in ./Zipper-test)
==84530== by 0x100027ED9: Catch::RunContext::~RunContext() (in ./Zipper-test)
==84530== by 0x10000E883: Catch::runTests(Catch::Ptr<Catch::Config> const&) (in ./Zipper-test)
==84530== by 0x100031443: Catch::Session::run() (in ./Zipper-test)
==84530== by 0x10001C9C7: main (in ./Zipper-test)
==84530== Uninitialised value was created by a stack allocation
==84530== at 0x10019549C: std::__1::num_put<char, std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > >::do_put(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, std::__1::ios_base&, char, unsigned long) const (in /usr/lib/libc++.1.dylib)
==84530==
All tests passed (42 assertions in 2 test cases)
==84530==
==84530== HEAP SUMMARY:
==84530== in use at exit: 46,139 bytes in 187 blocks
==84530== total heap usage: 2,470 allocs, 2,283 frees, 5,732,015 bytes allocated
==84530==
==84530== LEAK SUMMARY:
==84530== definitely lost: 27,064 bytes in 75 blocks
==84530== indirectly lost: 6,912 bytes in 9 blocks
==84530== possibly lost: 72 bytes in 3 blocks
==84530== still reachable: 4,480 bytes in 10 blocks
==84530== suppressed: 7,611 bytes in 90 blocks
==84530== Rerun with --leak-check=full to see details of leaked memory
==84530==
==84530== For counts of detected and suppressed errors, rerun with: -v
==84530== ERROR SUMMARY: 49 errors from 11 contexts (suppressed: 4 from 4)
And fix compilation errors:
While the static get called staticZipper and shared Zipper internally. However, when the are to output the library files the staticZipper gets renamed to Zipper.
This causes a ninja: error: build.ninja:5910: multiple rules generate Binaries/Lib/Zipper.lib [-w dupbuild=err]
Ninja Generator/CMake error when trying to build both the shared and the static library
The easy fix is, of course, to have them named differently/remove the rename.
Don't know if this is only caused on the newer version of CMake, as I am running 3.18.0 or if the visual studio generator allows this?
EDIT:
This was on Windows, so it might behave differently on Unix
I see in many files a check for the macro WIN32
when it should be _WIN32
.
Test case:
Zipper zipper("ux0:data/testzipper/ziptest.zip");
zipper.add("ux0:data/testzipper/somefolder/");
zipper.close();
Result: ziptest.zip
--> /
--> some files
Expected: ziptest.zip
--> somefolder
--> some files
The culprit is this line:
Line 97 in 787b97d
/
should be ignored.When trying to compile with mingw-w64 under msys2 the error: "The opendir() API is provided by this compiler, so should not be built here" is raised.
Had an issue zipping folders from windows. Found that the GetFileAttributes call in opendir in dirent.c will cast a std::string to a stringw which doesnt ever find the file as std::string is ascii and a stringw is unicode. Changing the code to always call the ascii macro fixed the issue:
DIR *opendir(char const *name)
{
DIR *result = NULL;
DWORD dwAttr;
/* Must be a valid name */
if( !name ||
!*name ||
(dwAttr = GetFileAttributesA(name)) == 0xFFFFFFFF)
{
errno = ENOENT;
}
I would ask to do a pull request or something, but it looks like the last one that's open is from a year ago so I'd guess this project is dead... but for any windows people who run into this issue this should fix it.
Simply extracting a downloaded .tar.gz file doesn't allow to build zipper, without having to clone minizip.
Since minizip is not versioned, it is hard to do it properly via release files.
Two things can happen to improve this:
There are files in folder minizip @ e3a8cb7 in https://github.com/sebastiandev/zipper, but download folder minizip is empty.
The readme states that passwords are supported and there is a parameter provided on the API for a password, but zipping a file with a password set does not encrypt the zip file. Is password use supported?
Hi Sebastian,
The information about the files that are added to an archive are not preserved. For example I create an archive, then decompress a file. The decompressed file has a date, let's say: 12/14/1657.
I compared the 'add' function from zipper.cpp with the 'main' function from minizip.
The difference is that the 'add' function doesn't contain
/* Get information about the file on disk so we can store it in zip */ filetime(nameInZip.c_str(), &zi.tmz_date, &zi.dosDate);
I've added this line and it's working properly now.
Can you test this and make the necessary changes?
.../zipper/defs.h:35:24: fatal error: filesystem: No such file or directory
#include <filesystem>
^
Why #include <filesystem>
? It's the C++1z std library but the README in the zipper wrote "using the latest C++11"
. Don't you wrote the wrong the C++ standard specification level in the README? I cannot compile the zipper using cmake with default -std=c++11
option.
Environment: msys2 + mingw-w64 / g++-6.1.0 / cmake-3.6.1 / ninja-1.7.1
Rev: 7d795d7 ( the latest current master )
Now it links only to dynamic library on linux but I would prefer static one.
Now when I try to use libzipper I have the following errors:
undefined reference to `crc32'
undefined reference to `inflate'
undefined reference to `inflateInit2_'
undefined reference to `inflateEnd'
undefined reference to `get_crc_table'
collect2: error: ld returned 1 exit status
There is completely no way to override or specify zipper's CMakeLists.txt to link to static version of zlib
.
what should I do
When building shared libraries on Windows the lib file is not generated because there are no symbols are exported. On Windows the .lib is necessary for linking, while runtime the .dll is used.
This can be fixed by adding
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
to the CMakeLists.txt.
I would also suggest to require C++11 and add a debug postfix to distinguish between the debug/release binaries.
Dear you,
here is my code
if( !unzipper.extractEntry( entry.name, GetFullPathToOutputDir() ) )
{ // I do not like this but it works
LOG( WARNING ) << "zipper lib returns extraction failed, whereas it works... for " << entry.name;
}
it works, the file are properly unzipped and located at the right location. But extractEntry returns false for every extracted file.
I do not like it as it could hide some problem or defect in the extracted file ... I do not know exactly why but I do not like it.
I've been using zipper
in some C++ code to create zip files and add files in it.
Later, I use Python's zipfile
library to open those zip files but I get the following exception:
BadZipFile: Bad CRC-32 for file '2017-04-12.csv'
I haven't done anything peculiar and followed zipper
s documentation.
Also, when doing unzip myarchive.zip
it unzips properly without any error.
Do you guys have any idea why this might be happening?
Hi,
Until now I was using Zipper on GNU/Linux and it worked well, but now I tried to build Zipper on a Windows 10 machine for the first time, and it seems to work, except for this one failing test:
C:\Projects\lib\zipper\build>libZipper-test.exe
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libZipper-test.exe is a Catch v1.5.6 host application.
Run with -? for options
-------------------------------------------------------------------------------
Scenario: zipfile feed with different inputs
Given: A Zip outputed to a file
When: a file containing 'test file compression' is added and named
'test1'
Then: the zip file has one entry named 'test1.txt'
And: extracting the test1.txt entry creates a file named 'test1.txt'
with the text 'test file compression'
And when: another file containing 'other data to compression test' and named
'test2.dat' is added inside a folder 'TestFolder'
And: the zip file has two entrys named 'test1.txt' and 'TestFolder/test2
.dat'
And: extracting the test2.dat entry creates a folder 'TestFolder' with a
file named 'test2.dat' with the text 'other data to compression
test'
And when: adding a folder to the zip, creates one entry for each file inside
the folder with the name in zip as 'Folder/...'
-------------------------------------------------------------------------------
C:\Projects\lib\zipper\test\file_zip_test.cpp(15)
...............................................................................
C:\Projects\lib\zipper\test\file_zip_test.cpp(105): FAILED:
{Unknown expression after the reported line}
due to unexpected exception with message:
invalid string position
===============================================================================
test cases: 2 | 1 passed | 1 failed
assertions: 50 | 49 passed | 1 failed
With a little help from debug prints, I can say that the exception is thrown from this call:
test/file_zip_test.cpp : 124 : zipper.add("TestFiles");
* To clarify, this is from master
, without any of my changes from #16.
* Everything (Zipper, zlib 1.2.11) was compiled for x64, with MSVC 19 (VS 14.0 / 2015).
Here is the CMake summary:
--
----------------------------------------------------------------------
Zipper version 0.9.1
----------------------------------------------------------------------
Configured on host ''
host type = Windows
host operating system = Windows 10.0.14393
host CPU architecture = AMD64
General build flags:
CC = C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe
CXX = C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe
CPPFLAGS = -D_CRT_SECURE_NO_WARNINGS
CFLAGS = /DWIN32 /D_WINDOWS /W3
CXXFLAGS = /DWIN32 /D_WINDOWS /W3 /GR /EHsc
LDFLAGS = /machine:x64
Zlib library configuration:
Zlib library = C:/Program Files/zlib/lib/zlib.lib
Zlib include dir = C:/Program Files/zlib/include
Other configuration settings:
Installation $prefix = C:/Program Files/zipper
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Projects/lib/zipper/build
Hi i used code from tutorial like:
Zipper zipper("ziptest.zip");
std::stringstream mSt;
mSt << "TEST";
zipper.add(mSt,"stuff.txt");
zipper.close();
and the zip file is created on hdd.
Step 2: i try to extract file from zip just created using Winzip or Windows and it fails.. i mean you can see
the content of the zip but when try to extract it fails.
The only one which can extract the file from archive with success is 7zip.
Is anyone aware of this issue ? Or maybe i am doing something wrong in the above code?!!!
Cheers,
Alex.
the stream.tellg() may return -1, in this case, the size may be 0xffffffff after converting to a unsigned int (size_t). Then the code would try to allocate a large number of memory, the size of new memory is 0xffffffff. It would cause new exception.
there's no need to convert the size into size_t, as there's judgement below.
bool initWithStream(std::iostream& stream)
{
m_zipmem.grow = 1;
stream.seekg(0, std::ios::end);
size_t size = (size_t)stream.tellg();
stream.seekg(0);
if (size > 0)
{
m_zipmem.base = new char[(size_t)size];
stream.read(m_zipmem.base, size);
}
fill_memory_filefunc(&m_filefunc, &m_zipmem);
return initMemory(size > 0 ? APPEND_STATUS_CREATE : APPEND_STATUS_ADDINZIP, m_filefunc);
}
ZipCrypto is an outdated and insecure encryption method, which the password protected zipping uses. Consider defining HAVE_AES
when compiling minizip to use AES encryption instead.
For now, in your root CMakeLists.txt, you can use
add_definitions(-DHAVE_AES)
to circumvent this :)
This is because before archiving with password CRC is computed, which causes stream's eof bit to be on. When this bit is on seekg(0) will not work
Hi Sebastian,
I compiled your code in VS2015. I had to make the following changes to tools.cpp for VS2015 otherwise it wont compile.
std::string parentDirectory(const std::string& filepath)
{
return fs::path(filepath).parent_path().string();
}
std::string currentPath()
{
return fs::current_path().string();
}
std::vector<std::string> filesFromDirectory(const std::string& path)
{
std::vector<std::string> files;
auto folder = fs::path(path);
auto it = fs::recursive_directory_iterator(folder);
for (it; it != fs::recursive_directory_iterator(); ++it)
{
// file object contains absolute path in the case of recursive iterators
const auto& file = it->path();
if (!fs::is_directory(file))
files.push_back(file.string());
}
return files;
}
std::string fileNameFromPath(const std::string& path)
{
return fs::path(path).filename().string();
}
When running the test program, Unhandled exception is raised while unzipping. Exception is raised while creating a Unzipper object.
std::exception at memory location 0x00E7E9C8
Hi Sebastian
I am using your code for zipping the folder which have images . But during extracting from zip files it gives me header . could you please help me what is the issue .
Continuing discussion from #16 in order to decide effort to fix leaks and interface improvements
Yeah I rushed a little with C++17, but the main point was making a fork that would let us have a project that only deals with latest standard without having to worry with old compiler and odd platforms compatibility. Many of the issues we are seeing here are mostly because we decided not to use boost/qt as dependencies because of having compatibility in mind with other platforms.
My question is, is it worth it to work on a fix for the path management and memory leaks. Or maybe use that time to decide/improve the interface and have a state of the art up to date library?
Hi,
I have a problem with zip files where filenames/folder names contain "umlaute" and the zip was created in Windows using local latin9 encoding.
When unzipping on Linux utf8 encoding is expected, causing mangled filenames.
How could zip-filename-encoding be supported best in zipper?
Hi,
thank you for your lib. Very useful!
Issue:
unzipper.extractEntry( "file1.txt", "/tmp" );
Writes a file called /tmp\file1.txt
instead of writing file1.txt in path /tmp
Hi think the problem is here:
./unzipper.cpp: std::string outputFile = destination.empty() ? name : destination + "\" + name;
A nice to have thing when the library is installed in an automated script.
Hi,
First of all, thanks for this library.
I need some pretty straightforward zip file manipulation (take an existing zip, add a file from memory stream, close), and this helps me do it with 3 simple and straightforward code lines that read exactly that story (ctor/open, add, close).
While testing for any memory leaks in my program (with valgrind
), I found out that I have some small memory leaks any time I do this process, and I pinned it down to Zipper.
I fixed the code enough that my Zipper
use case does not leak anymore, and the test doesn't show any other leaks in Zipper
.
However the valgrind
test shows leaks in Unzipper too. I made some changes there, but not enough to fix all leaks apparently.
If you want to take a look at the changes I made, take a look at oranja/zipper, but note that (a) it's not a complete solution, and (b) I also made changes to use the latest minizip
code from nmoinvaz. This is why I didn't create a PR yet.
nice lib, have plans to add password anytime soon?
The old cmake_minimum_required(VERSION 2.6) is causing zipperTargets-*.cmake to contain absolute paths, making it unusable on machines other than the one the package was built on.
Additionally zipper could use the newer namespacing-style. I've patched that into zipperConfig.cmake.in, but it could probably be done in a nicer way:
changes.txt
I have a C++ program that does computations on several hundreds of data files. Once a computation on one data file is over, I use zipper to save the results inside of a zip file. I create a new file in the zip for every processed data file.
To speed up the computations, I use OpenMP for parallelism. But of course, I put the part of the code that opens and closes the zip file to add new results inside of a #pragma omp critical
section. This makes sure that only one single thread at a time is modifying the zip file.
Though, every once in a while (but quite frequently), the "Error, couldn't get the current entry info" is raised. I don't know why and would like to know more about what it means and if it could be related to my multi-threaded processing.
The error "Error, couldn't get the current entry info" is thrown here.
Hi Sebastian,
I compiled your code in VS2015 after I've made the changes Antony007 said about in the issue he opened.
It's working properly (compressing and uncompressing) for text files, but I had problems whenever I chose files like dlls, libs, exes, chms, etc. They were incomplete (much smaller in size) after archive.
I've made it working by specifying the 'binary' flag when you create the ifstreams and ofstreams:
bool Zipper::add(const std::string& fileOrFolderPath, zipFlags flags)
{
...
std::ifstream input(f, std::ifstream::binary);
...
std::ifstream input(fileOrFolderPath, std::ifstream::binary);
...
}
and
int extractToFile(const std::string& filename, ZipEntry& info)
{
...
std::ofstream output_file(filename, std::ofstream::binary);
...
}
Maybe you could test it for binary files too and make the necessary modificationsif it doesn't work on VS2013.
The details of the vulnerability are detailed in this post: https://snyk.io/research/zip-slip-vulnerability
To summarize, Zip files can be crafted to contain entries with paths such as ../../../../../tmp/evil.sh
, which point to outside of the extraction folder and might be used to overwrite important executables or config files.
Therefore, it's crucial to check on file extraction that the path doesn't escape from the scope of the destination folder.
Line 388 in 01b3566
replacing it with CMAKE_CURRENT_LIST_DIR
fixes this issue.
After #68 got integrated, this opens up for getting zlib as a submodule, I do not know if this is wanted, would make it easier to build on Windows where zlib is not standard?
I made a personal branch where I added zlib to Zipper found here
I did a very minor change to the original zlib library, to stop the renaming of zconf.h
in out of source build.
As the submodule works now, it installs the zlib to the build/zlib_bin (or more accurately ${CMAKE_CURRENT_BINARY_DIR}/zlib_bin
). As of now, I know it works on Windows, and I plan on testing it on Ubuntu later. Just want to know if this is something that could be wanted?
minizip seems not to be up to date and unicode encoding seems not to be managed on windows (path + password)
Are you planning to fix these issues soon?
Sorry if this is a really noobie question but i'm stuck at the compiling step on Windows.
"cmake .." gives the following error:
`CMake Error at CMakeLists.txt:167 (message):
The include directory specified for zlib does not appear to be
valid. It should contain the file zlib.h, but it does not. Please
verify the LIBZ_INCLUDE_DIR variable.`
I tried to set a new environment variable ZLIBROOT = "c:\zlib"
Tried to add "c:\zlib" to the Path variable too, no luck.
Any help very appreciated :-)
I am getting the following build error
/home/mia/git/Sigmmma/Vulpes/lib/zipper/zipper/unzipper.cpp: In member function ‘zipper::ZipEntry zipper::Unzipper::Impl::currentEntryInfo()’:
/home/mia/git/Sigmmma/Vulpes/lib/zipper/zipper/unzipper.cpp:40:78: error: no matching function for call to ‘std::exception::exception(const char [42])’
40 | throw EXCEPTION_CLASS("Error, couln't get the current entry info");
| ^
In file included from /usr/lib/gcc/i686-w64-mingw32/9.2-win32/include/c++/exception:38,
from /usr/lib/gcc/i686-w64-mingw32/9.2-win32/include/c++/new:40,
from /usr/lib/gcc/i686-w64-mingw32/9.2-win32/include/c++/ext/new_allocator.h:33,
from /usr/lib/gcc/i686-w64-mingw32/9.2-win32/include/c++/i686-w64-mingw32/bits/c++allocator.h:33,
from /usr/lib/gcc/i686-w64-mingw32/9.2-win32/include/c++/bits/allocator.h:46,
from /usr/lib/gcc/i686-w64-mingw32/9.2-win32/include/c++/vector:64,
from /home/mia/git/Sigmmma/Vulpes/lib/zipper/zipper/unzipper.h:3,
from /home/mia/git/Sigmmma/Vulpes/lib/zipper/zipper/unzipper.cpp:1:
It seems Zipper has a switch in defs.h
that switches which exception class is used based on implementation:
#if (defined(_WIN32)) || (defined(_WIN64))
# define EXCEPTION_CLASS std::exception
#else
# define EXCEPTION_CLASS std::runtime_error
#endif
In my environment, it is selecting std::exception
. The problem is, std::exception
does not appear to have a constructor that supports passing const char*
. std::runtime_error
does support const char*
, but that's not what Zipper is selecting for me.
My build environment is using i686-w64-mingw32 to cross-compile Windows binaries in Linux, using C++17. I am using the most recent commit to master for Zipper.
Is this a bug, or am I missing something simple?
Fixed the segfault, but now i get another error
terminate called after throwing an instance of 'std::runtime_error'
what(): Error 18446744073709551514 opening internal file 'release-notes.txt' in zip
Aborted (core dumped)
% cmake ..
-- The C compiler identification is GNU 6.4.0
-- The CXX compiler identification is GNU 6.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for gzopen in /usr/lib/libz.so
-- Looking for gzopen in /usr/lib/libz.so - found
--
----------------------------------------------------------------------
Zipper version 0.9.1
----------------------------------------------------------------------
Configured on host ''
host type = Linux
host operating system = Linux 4.9.76-gentoo-r1
host CPU architecture = x86_64
General build flags:
CC = /usr/bin/cc
CXX = /usr/bin/c++
CPPFLAGS = -DLINUX
CFLAGS = -fno-strict-aliasing -fPIC
CXXFLAGS = -fno-strict-aliasing -fPIC
LDFLAGS =
Zlib library configuration:
Zlib library = /usr/lib/libz.so
Zlib include dir = /usr/include
Other configuration settings:
Installation $prefix = /usr/local
-- Configuring done
-- Generating done
-- Build files have been written to: /media/data/Programming/Projects/ziptest/zipper/build
% make
Scanning dependencies of target Zipper-static
[ 4%] Building CXX object CMakeFiles/Zipper-static.dir/zipper/CDirEntry.cpp.o
[ 8%] Building CXX object CMakeFiles/Zipper-static.dir/zipper/tools.cpp.o
In file included from /media/data/Programming/Projects/ziptest/zipper/minizip/zip.h:27:0,
from /media/data/Programming/Projects/ziptest/zipper/zipper/defs.h:21,
from /media/data/Programming/Projects/ziptest/zipper/zipper/tools.cpp:2:
/media/data/Programming/Projects/ziptest/zipper/minizip/ioapi.h:97:51: error: expected initializer before 'OF'
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
^~
/media/data/Programming/Projects/ziptest/zipper/minizip/ioapi.h:98:51: error: expected initializer before 'OF'
typedef voidpf (ZCALLBACK *opendisk_file_func) OF((voidpf opaque, voidpf stream, int number_disk, int mode));
^~
/media/data/Programming/Projects/ziptest/zipper/minizip/ioapi.h:99:51: error: expected initializer before 'OF'
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
^~
/media/data/Programming/Projects/ziptest/zipper/minizip/ioapi.h:100:51: error: expected initializer before 'OF'
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
and many more similar
UPD: Looks like it's the Gentoo bug: https://bugs.gentoo.org/383179
Would be nice to get a v0.9.1-beta tag with current state of code to create a modern release, unless some major bug is affecting the current code. The last one is dated from 2015 !
Hi there,
I'm not entirely sure how to build this, especially without taking advantage of CMake. Every time I attempt to use Visual Studio to build it, I keep running into countless linker errors and don't know where to start. Is there any way you can improve upon the build instructions? Thank you!
When zipping files on a system, make the timestamp of the file a part of the zipping.
Currently, unless you specify the timestamp yourself, Zipper gives an empty std::tm
:
zipper::Zipper zipf("test.zip");
zipf.add("test.txt");
zipf.close();
The file timestamp will look like this:
Now currently, as stated you can give a timestamp yourself, so the workaround would be something like this:
//Get the last write time in filesystem clock
auto time = std::filesystem::last_write_time("test.txt");
//A "dirty" way to convert filesystem clock to system_clock, and then get the time_point
auto sctp = std::chrono::time_point_cast<std::chrono::system_clock::duration>(
time - std::filesystem::file_time_type::clock::now() + std::chrono::system_clock::now());
//use the time_point to to get the time_t
auto timet = std::chrono::system_clock::to_time_t(sctp);
//convert the time_t to std::tm
const auto timestamp = *std::localtime(&timet);
std::ifstream inp("test.txt");
zipper::Zipper zip("test.zip");
zip.add(inp, timestamp, "test.txt");
zip.close();
One issue is that converting std::chrono::file_clock
to std::chrono::system_clock
to then use system_clock
's to_time_t
, now there should be UNIX and Windows call to more accurately get a file's timestamp. C++20
seeks to fix this issue.
Another is the very minor inaccuracy as I call ::now()
twice to convert to the time. see SO for more details.
Anyways the result in this:
It is decades more accurate than what is currently here, and cross-platform. However to be very proper (before C++20
), then a timestamp on unix would look something like this:
#include <sys/stat.h>
struct stat buf;
stat("test.txt", &buf);
zipper::Zipper zip("test.zip");
auto timet = static_cast<time_t>(buf.st_mtim.tv_sec);
const auto timestamp = *std::localtime(&timet);
zip.add(inp, timestamp, "test.txt");
zip.close();
On Windows, you probably need to call GetFileTime from the API. I am not a windows machine for the moment, so can't draft anything.
It would be really nice if the timestamp got set automatically when calling the bool Zipper::add(const std::string& fileOrFolderPath, zipFlags flags)
constructor, as there you have to open the file/folder and can also do this read.
`
Following #20 (comment)
I do not have Windows and as a consequence, my Continuous Integration script for Windows (AppVeyor) is not working. I'm looking for someone who knows to fix it.
Thanks!
Some functions have been deprecated and they need to be replaced. I tried by my own but I had some problems with VS2017 and I couldn't reach it. Could you update the project with the new functions please?
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.