• Stars
    star
    220
  • Rank 180,422 (Top 4 %)
  • Language
    C++
  • License
    Other
  • Created almost 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fork of SevenZip++ for modern builds.

Build status

7zip-cpp

A fork of SevenZip++ for modern builds. Uses cmake to generate build files for desired Visual Studio version, see setup section for instructions.

Uses latest lzma1801 SDK

Notes

Originally from: http://bitbucket.org/cmcnab/sevenzip/wiki/Home

This is a C++ wrapper for accessing the 7-zip COM-like API in 7z.dll and 7za.dll. This code is heavily based off of the Client7z sample found in the LZMA SDK.

The project itself is a static library.

Basic Usage

To use, first load the 7z DLL into memory:

#include <7zpp/7zpp.h>

SevenZip::SevenZipLibrary lib;
lib.Load();

If the appropriate 7z DLL is not in your path you may wish to specify it explicitly in the call to load. Note you may have the 64-bit version installed but are trying to load it from a 32-bit executable; keep that in mind if you encounter errors.

lib.Load(_T("path\\to\\7za.dll"));

Then create and use a compressor:

SevenZip::SevenZipCompressor compressor(lib, archiveName);
compressor.SetCompressionFormat(SevenZip::CompressionFormat::Zip);
compressor.UseAbsolutePaths(false);
compressor.AddFile(targetFile);
compressor.AddDirectory(targetDir);
compressor.DoCompress(callbackfunc);

Or an extractor:

SevenZip::SevenZipExtractor extractor(lib, archiveName);

// Try to detect compression type
if (!extractor.DetectCompressionFormat())
{
	extractor.SetCompressionFormat(SevenZip::CompressionFormat::Zip);
}

...

// Change this function to suit
SevenZip::ProgressCallBack *extractcallbackfunc = nullptr;

...

extractor.ExtractArchive(destination, extractcallbackfunc);

Or a lister:

class ListCallBackOutput : SevenZip::ListCallback
{
	virtual void OnFileFound(WCHAR* path, ULONGLONG size)
	{
		std::wcout
			<< path
			<< L" "
			<< size
			<< std::endl;
	}
};

...

SevenZip::SevenZipLister lister(lib, archiveName);

// Try to detect compression type
if (!lister.DetectCompressionFormat())
{
	lister.SetCompressionFormat(SevenZip::CompressionFormat::Zip);
}

ListCallBackOutput myListCallBack;


lister.ListArchive((SevenZip::ListCallback *)&myListCallBack);

Note: Most of the functions now return a boolean to indicate if it worked instead of throwing an exception.

Otherwise, don't forget to wrap the operations in a try/catch block to handle errors:

...
catch (SevenZip::SevenZipException& ex)
{
    std::cerr << ex.GetMessage() << std::endl;
}
...

Setup and Installation

Using git and cmake

  1. Ensure you have cmake and git installed. Navigate to folder of choice.
  2. Open a powershell window and type git clone https://github.com/getnamo/7zip-cpp.git --recursive
  3. Navigate into the newly cloned project cd 7zip-cpp
  4. (Optional for Test app only) Download and build Boost
  5. Example build with cmake using powershell
cd build
cmake -G "Visual Studio 15 2017 Win64" ../
cmake --build ../build --config Release
  1. Commands from 5 will build win64 Release target and output will be found in build/Release/7zpp.lib

How to use this library in my project

Add project into your cmakelists

add_subdirectory(${pathto7zip-cpp} ${PROJECT_SOURCE_DIR}/build/build7zpp)
target_include_directories(${my_project} INTERFACE ${pathto7zip-cpp}/Include)
target_link_libraries(${my_project} 7zpp)
add_dependencies(${my_project}  7zpp) #might not be necessary

Test Requirements

In order to compile the tests,you must have boost libraries in your path or specify the location where cmake can find them

  1. Assuming you're in the project directory
  2. Download and build Boost
cd build
cmake ../ -DBOOST_ROOT="My boost location"
  1. Then finally cmake --build ../build to build

Known Issues

Only 1 test unit is failing.

Contributing

Read Contributing.md

Branches

  • Devel branch is the bleeding edge, but it should still work.
  • Devel-XXX branches are current topics.
  • Master branch is the latest stable version.
  • More branch information is in Contributing.md.

More Repositories

1

TensorFlow-Unreal

TensorFlow plugin for the Unreal Engine.
C++
1,158
star
2

SocketIOClient-Unreal

Socket.IO client plugin for the Unreal Engine.
C++
888
star
3

UDP-Unreal

Convenience UDP wrapper for the Unreal Engine.
C++
329
star
4

GlobalEventSystem-Unreal

Loosely coupled internal event system plugin for the Unreal Engine.
C++
272
star
5

NodeJs-Unreal

Embed node.js as an Unreal Engine plugin.
C++
242
star
6

TensorFlow-Unreal-Examples

Drag and drop Unreal Engine TensorFlow examples repository.
Python
220
star
7

ZipUtility-Unreal

Event driven 7zip utility plugin for the Unreal Engine.
C++
205
star
8

MachineLearningRemote-Unreal

Machine Learning plugin for the Unreal Engine, encapsulating calls to remote python servers running e.g. Tensorflow/Pytorch.
C++
138
star
9

TCP-Unreal

Convenience TCP wrapper for Unreal Engine
C++
107
star
10

SocketIOClient-Unreal-Example

sample project using the socketio-client-ue4
HTML
91
star
11

hydra-ue4

Hydra Plugin for Unreal Engine 4
C++
75
star
12

myo-ue4

Myo Plugin for Unreal Engine 4
C++
51
star
13

TensorFlowNative-Unreal

Tensorflow Plugin for Unreal Engine using C API for inference focus.
C#
42
star
14

realsense-ue4

RealSense plugin for Unreal Engine 4
C++
40
star
15

RuntimeGeometryUtils

Fork of https://github.com/gradientspace/UnrealRuntimeToolsFrameworkDemo plugin for inclusion as submodule
C++
24
star
16

ml-remote-server

Server component of https://github.com/getnamo/machine-learning-remote-ue4
Python
23
star
17

WeaponTrace-Unreal

WeaponTracing plugin for reliable melee combat.
20
star
18

CIMPlugin

Custom Input Mapping Plugin for the Unreal Engine 4
C++
19
star
19

UE4-MouseIKThirdPerson

Simple Unreal Engine third person template project with mouse click left arm movement.
16
star
20

VRArmIK-ue4

UE4 port of https://github.com/dabeschte/VRArmIK
C++
12
star
21

RVD-Unreal

Real-time Value Debugger for the Unreal Engine.
C++
12
star
22

BodyState-Unreal

An abstract skeleton target for body tracking input devices
C++
10
star
23

TensorFlowJs-Unreal

Tensorflow.js Plugin for Unreal Engine using Node.js plugin.
C#
8
star
24

socketio-client-prebuild

socket io client static library builds for UE4
Batchfile
7
star
25

BulkManager-Unreal

Plugin for managing a bulk of actors with data through programmatic relevancy.
C++
7
star
26

EnvCommand-Unreal

Access environment commands from bps
C++
6
star
27

SIONetworking-Unreal

simple echo networking using socket.io and ges
JavaScript
6
star
28

mnist-draw-server

server counterpart for drawing on webclients and sending via socket.io to ue4 mnist classifier client
JavaScript
3
star
29

clean-ue4

Simple npm script to clean Intermediate, Saved folders, and .pdbs from unreal projects and plugins for release prep.
JavaScript
2
star
30

BasicDatabase-Unreal

Simple wrapped DB API for json flatfile database & potentially more backends.
C++
2
star
31

PiperCLI-Unreal

Experimental Piper plugin for Unreal via CLI wrapper.
C++
2
star
32

AnswerHubMisc

Various answer/example projects
1
star
33

batch-resizer

Batch resize images using npm sharp and exif-parser
JavaScript
1
star