Giter Club home page Giter Club logo

lib7zip's Introduction

lib7zip

A library using 7z.dll/7z.so(from 7-Zip) to handle different archive types. lib7zip is based on 7zip/p7zip source code, but NOT including any source code from 7zip/p7zip.

Tips

  • Build lib7zip
    • Under UNIX/LINUX like system
      • Get a copy of p7zip source code, and extract to a folder
      • Define a env P7ZIP_SOURCE_DIR point to the extracted folder
      • cmake -DBUILD_SHARED_LIB=OFF -DP7ZIP_SOURCE_DIR=${P7ZIP_SOURCE_DIR}
    • Under windows
      • Get mingw from http://www.mingw.org
      • Get a copy of original 7zip source code, NOT the p7zip for linux
      • Define a env P7ZIP_SOURCE_DIR point to the extracted folder
      • cmake -DBUILD_SHARED_LIB=OFF -DP7ZIP_SOURCE_DIR=${P7ZIP_SOURCE_DIR}
  • Run lib7zip
    • Under UNIX/LINUX like system
      • install p7zip binary
      • find 7z.so path, export LD_LIBRARY_PATH=<where 7z.so existing>
    • Under Windows
      • install 7zip binary
      • copy 7z.dll to where your application existing

Any time or any problem about lib7zip, please feel free to write me an email.

Any feature or patch request, please also feel free to write me an email.

Thanks

  • Many thanks to Joe who provide so many great patches
  • Many thanks to Christoph who give so many great advises and patch.
  • Many thanks to Christoph Thielecke to provide great patches for OS2 and dynamic library

To Do

  • Add Compress function to library

Related Projects

Change Log

3.0.0

  1. move build system to cmake
  2. fix bug when do signature detect for dmg files
  3. fix bug of memory leaking when deal with sub archive

2.0.0

  1. Make the library compiling with latest p7zip 15.9.0 and 7zip 15.10.0
  2. Fix bug in test7zipmulti

1.6.5

  1. Add new parameter bool fDetectFileTypeBySignature to OpenArchive, when fDetectFileTypeBySignature = true, lib7zip will using file signature instead file name extension to detect file type
  2. remove out-of-dated visual studio files

1.6.4

  1. add AUTHORS COPYING file
  2. add LIB7ZIP_ prefix to error code enum,break the old client, please update your code
  3. add APIs SetLib7ZipLocale and GetLib7ZipLocale, client could use these API to force lib7zip locale, otherwise lib7zip will use current user's locale
  4. add list of path to find 7z.so when 7z.so is not in users ld path
  5. fix Mac OSX compile fail problem

1.6.3

  1. Add GetLastError to C7ZipLibrary and Error code define in lib7zip.h
  2. open archive with password now work for archive created by 7za a -mhe -p, who encrypted the file names in archive

1.6.2

  1. Fixed broken windows built system
  2. Fixed build script for windows

1.6.1

  1. Add OS2 support
  2. create dynamic library along with static library

1.6.0

  1. Add Multi-Volume support

1.5.0

  1. Add Password support

1.4.1

  1. Add GetProperty functions to C7ZipArchive to retrieve archive properties
  2. Add kpidSize to return Item umcompressed size, the same as GetSize returning

1.4.0

  1. Add patches from Christoph
  2. make the test program works when no Test7Zip.7z found
  3. Add functions to get more property about items in the archive
  4. Tested on Mac OS X
  5. Move source control to Mercurial for better distributed development

1.3.0

  1. Add patches from Joe,
  2. make the library work with latest p7zip 9.20

1.0.2

  1. Add patches from Joe,
  2. Add a method to get the compressed size
  3. Add a method to expose whether the file is encrypted
  4. Build scripts update
  5. Small fix to make the lib working with the latest p7zip source

1.0.1

  1. First release, support both LINUX and windows platform.

lib7zip's People

Contributors

mardy avatar stonewell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lib7zip's Issues

There is memory leak

==9140== 4,091,440 (520 direct, 4,090,920 indirect) bytes in 1 blocks are definitely lost in loss record 47 of 47
==9140==    at 0x4835DEF: operator new(unsigned long) (vg_replace_malloc.c:334)
==9140==    by 0x4937E98: NArchive::NPe::CreateArc() (PeHandler.cpp:2667)
==9140==    by 0x48C4AB7: CreateArchiver (ArchiveExports.cpp:77)
==9140==    by 0x48EA922: CreateObject (DllExports2.cpp:75)
==9140==    by 0x41FFDC: CreateInArchive(_union_7zip_functions*, C7ZipObjectPtrArray const&, CMyComPtr<IInStream>&, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >, CMyComPtr<IInArchive>&, bool) (7ZipOpenArchive.cpp:127)
==9140==    by 0x420427: InternalOpenArchive(C7ZipLibrary*, C7ZipDllHandler*, C7ZipInStream*, C7ZipArchiveOpenCallback*, C7ZipArchive**, int*, bool) (7ZipOpenArchive.cpp:238)
==9140==    by 0x42012D: Lib7ZipOpenArchive(C7ZipLibrary*, C7ZipDllHandler*, C7ZipInStream*, C7ZipArchive**, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, int*, bool) (7ZipOpenArchive.cpp:179)
==9140==    by 0x41DF36: C7ZipDllHandler::OpenArchive(C7ZipInStream*, C7ZipMultiVolumes*, C7ZipArchive**, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, int*, bool) (7ZipDllHandler.cpp:131)
==9140==    by 0x4197D2: C7ZipLibrary::OpenArchive(C7ZipInStream*, C7ZipArchive**, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, bool) (7zipLibrary.cpp:131)
==9140==    by 0x4198E9: C7ZipLibrary::OpenArchive(C7ZipInStream*, C7ZipArchive**, bool) (7zipLibrary.cpp:153)
==9140==    by 0x4188A2: main (test_archive.cpp:237)

The sample file is in
memory_leak.zip
860e4e7d205b6a483ed12569fbcb9cf0

and use 7z to extract this file has no memory leak

failed to extract the rar file

I failed to extract the rar file using Test7Zip/Test7ZipRar5.cpp on Linux. It can create new files but not write bytes. I am using p7zip_16.02.

How do I run the code?

I successfully created the bin/7z.so library in the p7zip project by running make 7z.
After that I built lib7zip sources by cmake -DBUILD_SHARED_LIB=OFF -DP7ZIP_SOURCE_DIR=/xxx/p7zip_16.02
What do I do now?
I want to build and run Test7Zip.cpp as a portable executable.

error on windows

C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(39): error C2374: “GUID_DEVINTERFACE_DISK”: 重定义;多次初始化
1> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(39): note: 参见“GUID_DEVINTERFACE_DISK”的声明
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(40): error C2374: “GUID_DEVINTERFACE_CDROM”: 重定义;多次初始化
1> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(40): note: 参见“GUID_DEVINTERFACE_CDROM”的声明
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(41): error C2374: “GUID_DEVINTERFACE_PARTITION”: 重定义;多次初始化
1> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(41): note: 参见“GUID_DEVINTERFACE_PARTITION”的声明
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(42): error C2374: “GUID_DEVINTERFACE_TAPE”: 重定义;多次初始化
1> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(42): note: 参见“GUID_DEVINTERFACE_TAPE”的声明
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(43): error C2374: “GUID_DEVINTERFACE_WRITEONCEDISK”: 重定义;多次初始化
1> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(43): note: 参见“GUID_DEVINTERFACE_WRITEONCEDISK”的声明
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(44): error C2374: “GUID_DEVINTERFACE_VOLUME”: 重定义;多次初始化
1> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winioctl.h(44): note: 参见“GUID_DEVINTERFACE_VOLUME”的声明

when i remove line 6~8
//#ifndef INITGUID
//#define INITGUID
//#endif

lib7zip is ok , but Test7Zip can not run ,error is
1>7zip.lib(7ZipOpenArchive.obj) : error LNK2001: 无法解析的外部符号 IID_IInStream
1>7zip.lib(7ZipInStreamWrapper.obj) : error LNK2001: 无法解析的外部符号 IID_IInStream
1>7zip.lib(7ZipOpenArchive.obj) : error LNK2001: 无法解析的外部符号 IID_IArchiveOpenVolumeCallback
1>7zip.lib(7ZipOpenArchive.obj) : error LNK2001: 无法解析的外部符号 IID_IInArchiveGetStream
1>7zip.lib(7ZipOpenArchive.obj) : error LNK2001: 无法解析的外部符号 IID_IArchiveOpenSetSubArchiveName
1>7zip.lib(7ZipOpenArchive.obj) : error LNK2001: 无法解析的外部符号 IID_IInArchive

how to run the code?

Not able to run the code on my local machine.
Can you please help with a step-by-step procedure to run the code on my machine. I am using Ubuntu 14.04 LTS

ubuntu18.04 build shared lib error

[ 30%] Built target lib7zip
[ 31%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7ZipArchive.cpp.o
[ 33%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7ZipCompressCodecsInfo.cpp.o
[ 35%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/OSFunctions_UnixLike.cpp.o
[ 36%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7ZipArchiveItem.cpp.o
[ 38%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7ZipInStreamWrapper.cpp.o
[ 40%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/HelperFuncs.cpp.o
[ 41%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7ZipArchiveOpenCallback.cpp.o
[ 43%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7ZipDllHandler.cpp.o
[ 45%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/OSFunctions_Win32.cpp.o
[ 46%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7ZipObjectPtrArray.cpp.o
[ 48%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7ZipCodecInfo.cpp.o
[ 50%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7ZipFormatInfo.cpp.o
[ 51%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7ZipOpenArchive.cpp.o
[ 53%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/OSFunctions_OS2.cpp.o
[ 55%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/7zipLibrary.cpp.o
[ 56%] Building CXX object src/CMakeFiles/lib7zip_shared.dir//third_party/p7zip/CPP/Common/MyWindows.cpp.o
[ 58%] Building CXX object src/CMakeFiles/lib7zip_shared.dir/
/third_party/p7zip/CPP/Windows/PropVariant.cpp.o
[ 60%] Linking CXX shared library lib7zip.so
CMakeFiles/lib7zip_shared.dir/OSFunctions_UnixLike.cpp.o: In function myselect(dirent const*)': /home/eninge/wy/lib7zip_newest-build/src/OSFunctions_UnixLike.cpp:104: undefined reference to dlopen'
CMakeFiles/lib7zip_shared.dir/OSFunctions_UnixLike.cpp.o: In function GetHandlerPath[abi:cxx11](void*)': /home/eninge/wy/lib7zip_newest-build/src/OSFunctions_UnixLike.cpp:143: undefined reference to dladdr'
CMakeFiles/lib7zip_shared.dir/OSFunctions_UnixLike.cpp.o: In function Load7ZLibrary(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)': /home/eninge/wy/lib7zip_newest-build/src/OSFunctions_UnixLike.cpp:165: undefined reference to dlopen'
/home/eninge/wy/lib7zip_newest-build/src/OSFunctions_UnixLike.cpp:193: undefined reference to dlopen' CMakeFiles/lib7zip_shared.dir/OSFunctions_UnixLike.cpp.o: In function Free7ZLibrary(void*)':
/home/eninge/wy/lib7zip_newest-build/src/OSFunctions_UnixLike.cpp:202: undefined reference to dlclose' CMakeFiles/lib7zip_shared.dir/7ZipDllHandler.cpp.o: In function C7ZipDllHandler::Initialize()':
/home/eninge/wy/lib7zip_newest-build/src/7ZipDllHandler.cpp:75: undefined reference to dlsym' /home/eninge/wy/lib7zip_newest-build/src/7ZipDllHandler.cpp:77: undefined reference to dlsym'
/home/eninge/wy/lib7zip_newest-build/src/7ZipDllHandler.cpp:79: undefined reference to dlsym' /home/eninge/wy/lib7zip_newest-build/src/7ZipDllHandler.cpp:81: undefined reference to dlsym'
/home/eninge/wy/lib7zip_newest-build/src/7ZipDllHandler.cpp:83: undefined reference to dlsym' CMakeFiles/lib7zip_shared.dir/7ZipDllHandler.cpp.o:/home/eninge/wy/lib7zip_newest-build/src/7ZipDllHandler.cpp:85: more undefined references to dlsym' follow
collect2: error: ld returned 1 exit status
src/CMakeFiles/lib7zip_shared.dir/build.make:352: recipe for target 'src/lib7zip.so' failed
make[2]: *** [src/lib7zip.so] Error 1
CMakeFiles/Makefile2:157: recipe for target 'src/CMakeFiles/lib7zip_shared.dir/all' failed
make[1]: *** [src/CMakeFiles/lib7zip_shared.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2

Can you tell me how to add ldl to CMakelist.txt

Memory leak?

Hi,
I'm opening an archive and then closing it, and when running the application in valgrind it reports this:

==14992== 1,134 bytes in 42 blocks are definitely lost in loss record 93 of 103
==14992==    at 0x4C2DB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14992==    by 0xC818DEF: ???
==14992==    by 0xC83429F: ???
==14992==    by 0x40B819: ReadProp(unsigned int (*)(unsigned int, tagPROPVARIANT*), unsigned int (*)(unsigned int, unsigned int, tagPROPVARIANT*), unsigned int, unsigned int, NWindows::NCOM::CPropVariant&) (HelperFuncs.cpp:49)
==14992==    by 0x40EBD7: LoadFormats(_union_7zip_functions*, C7ZipObjectPtrArray&) (7ZipFormatInfo.cpp:107)
==14992==    by 0x40D8BC: C7ZipDllHandler::Initialize() (7ZipDllHandler.cpp:92)
==14992==    by 0x40D608: C7ZipDllHandler::C7ZipDllHandler(C7ZipLibrary*, void*) (7ZipDllHandler.cpp:62)
==14992==    by 0x40893E: C7ZipLibrary::Initialize() (7zipLibrary.cpp:76)
==14992==    by 0x406A21: Fuse7z::ModulePrivate::initialize7zip() (module.cpp:88)
==14992==    by 0x406C83: Fuse7z::ModulePrivate::initialize() (module.cpp:109)
==14992==    by 0x407145: Fuse7z::Module::initialize() (module.cpp:172)
==14992==    by 0x4085B0: main (main.cpp:17)

When using file signature to ID file types, ran into a collision which mis-identified a file type.

I had a multifile RAR set that refused to decode. It failed while opening the first archive. I troubleshot it down to where it picked which codec to use. It found a "BD" in the data for a two character signature and then picked the wrong codec which failed to open the archive.

I changed the code to require that both the signature and extension match. It works but it defeats the purpose of using signature only. My suggestion is sort the signatures in "length of signature" order so the long signatures get checked before the short signatures. Every byte of additional signature that matches increases the confidence in the signature match.

Compilation Fails on Linux

Getting this error on linux:

7ZipArchive.cpp:8:34: fatal error: CPP/myWindows/StdAfx.h: No such file or directory
 #include "CPP/myWindows/StdAfx.h"
                                  ^
compilation terminated.

...can't figure out what flags to set to tell make that I'm not on WIN32

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.