Code Monkey home page Code Monkey logo

lazy-seven-zip's Introduction

Lazy Seven Zip

Lazy Seven Zip is a wrapper for the popular SevenZipSharp library.
It provides an easy to use set of methods to easily create and extract archives in Unity within the Editor or at Runtime.

For the benefit of the user, the source code is easy to follow and can be modified without must difficulty.

Please note!
This library does not include creating or extracting archives via Stream.

Lazy Archive Class

The Lazy Archive Wrapper Class consists of 4 methods, 2 Synchronous and 2 Asynchronous methods.
This allows you to create standard or encrypted archives using the Files and Folders in your current Unity Project.

The methods in the class are shown below.

Synchronous Methods

public static void Archive(string outArchive, 
                           string[] inFiles, 
                           OutArchiveFormat archiveFormat, 
                           CompressionLevel compressionLevel = CompressionLevel.Normal)
{
...
}

public static void Archive(string outArchive,
                           string[] inFiles,
                           string password,
                           OutArchiveFormat archiveFormat,
                           bool encryptHeaders = false,
                           ZipEncryptionMethod encryptionMethod = ZipEncryptionMethod.Aes128,
                           CompressionLevel compressionLevel = CompressionLevel.Normal)
{
...
}

Asynchronous Methods

public static async Task Archive(string outArchive, 
                           string[] inFiles, 
                           OutArchiveFormat archiveFormat, 
                           CompressionLevel compressionLevel = CompressionLevel.Normal)
{
...
}

public static async Task Archive(string outArchive,
                           string[] inFiles,
                           string password,
                           OutArchiveFormat archiveFormat,
                           bool encryptHeaders = false,
                           ZipEncryptionMethod encryptionMethod = ZipEncryptionMethod.Aes128,
                           CompressionLevel compressionLevel = CompressionLevel.Normal)
{
...
}

Lazy Extractor Class

The Lazy Extractor Wrapper Class consists of 2 Extraction methods, 1 Synchronous and 1 Asynchronous method.
This allows you to extract standard or encrypted archives anywhere within the Unity Editor or on your Local Machine.

The methods in the class are shown below.

Synchronous

public static void Extract(string outPath, string inArchive, string password = "")
{
...
}

Asynchronous

public static async Task ExtractAsync(string outPath, string inArchive, string password = "")
{
...
}

Examples - Creating an Archive

Method 1 - Archive no Password

public void ArchiveTest(string[] filesToArchive)
{
    LazyArchiver.ArchiveAsync(@"Assets/test.7z", filesToArchive , OutArchiveFormat.SevenZip);
}

public async Task ArchiveTestAsync(string[] filesToArchive)
{
    await LazyArchiver.ArchiveAsync(@"Assets/test.7z", filesToArchive, OutArchiveFormat.SevenZip);
}

Method 2 - Archive with Password

public void ArchivePasswordTest(string password, string[] filesToArchive)
{
    LazyArchiver.ArchiveAsync(@"Assets/test.7z", filesToArchive , password, OutArchiveFormat.SevenZip);
}

public async Task ArchivePasswordTestAsync(string password, string[] filesToArchive)
{
    await LazyArchiver.ArchiveAsync(@"Assets/test.7z", filesToArchive, password, OutArchiveFormat.SevenZip);
}

Examples - Extracting an Archive

Method 1 - Extract an Archive with no Password

public void ExtractArchiveTest(string outputPath)
{
    LazyExtractor.Extract(outputPath, @"Assets/test.7z");
}

public async Task ExtractArchiveTestAsync(string outputPath)
{
    await LazyExtractor.ExtractAsync(outputPath, @"Assets/test.7z");
}

Method 2 - Extract an Archive with a Password

public void ExtractArchivePasswordTest(string outputPath, string password)
{
    LazyExtractor.Extract(outputPath, @"Assets/test.7z", password);
}

public async Task ExtractArchivePasswordTestAsync(string outputPath, string password)
{
    await LazyExtractor.ExtractAsync(outputPath, @"Assets/test.7z", password);
}

Work In Progress

  • Editor Window to Create Archives similar to the 7zip Archive Creator Window

Credits

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.