Skip to content

needle-mirror/com.unity.sharp-zip-lib

Repository files navigation

Latest official docs

ReleaseBadge ReleaseBadge

com.unity.sharp-zip-lib

com.unity.sharp-zip-lib is a package that wraps SharpZipLib to be used inside Unity, and provides various compression/uncompression utility functions.

Currently, this package uses SharpZipLib v1.3.3.
Please refer to the installation page to install this package.

The version numbering of this package itself and the version of SharpZipLib used in the package may look similar, but they are not related.

How to Use

  • All SharpZipLib APIs are available under Unity.SharpZipLib namespace. For example:

      using System.IO;
      using Unity.SharpZipLib.GZip;
    
      ...
    
      public void Foo() {
          MemoryStream ms = new MemoryStream();
          GZipOutputStream outStream = new GZipOutputStream(ms);
          ...
      }

    Please refer to the API documentation of the SharpZipLib version used in this package for more details.

  • In addition, com.unity.sharp-zip-lib also provides additional utility APIs:

    • ZipUtility.CompressFolderToZip(): Compresses the files in the nominated folder, and creates a zip file on disk.
    • ZipUtility.UncompressFromZip(): Uncompress the contents of a zip file into the specified folder.

    As an example:

    [Test]
    public void Foo() {
        //Compress 
        string tempZipPath = FileUtil.GetUniqueTempPathInProject();
        string folderToCompress ="Bar";
        ZipUtility.CompressFolderToZip(tempZipPath,null, folderToCompress);
    
        //Uncompress
        string tempExtractPath = FileUtil.GetUniqueTempPathInProject();
        Directory.CreateDirectory(tempExtractPath);
        ZipUtility.UncompressFromZip(tempZipPath, null, tempExtractPath);
    
    }

Supported Unity Versions

  • Unity 2018.4.36 or higher.

Steps to update SharpZipLib

Windows

Environment Prerequisites

  1. Visual Studio 2022 (17.19.1) or later
    • Check ".Net desktop development" during the installation of Visual Studio
  2. Make sure that .Net SDK 8.0 is installed as follows:
    • Open "Developer Command Prompt for VS 2022"
    • Type: dotnet --list-sdks

Steps

  1. Download the source from https://github.com/icsharpcode/SharpZipLib/releases
  2. Extract the source into a folder, e.g: Src/SharpZipLib-1.3.3
  3. Open "Developer Command Prompt for VS 2022"
  4. Execute update_sharp-zip-lib.cmd [src_folder]
    • E.g: update_sharp-zip-lib.cmd Src/SharpZipLib-1.3.3
    • Executing update_sharp-zip-lib.cmd without arguments will print the list of acceptable arguments
  5. Open SharpZipLib~ test project, ensure everything compiles and the tests are successful.
    • We may need to fix/remove some tests that were copied from the source.
      For example: async tests which are not supported in Unity 2018 and earlier.

Auto-generated on Wed Feb 28 05:29:40 UTC 2024

About

A package that wraps SharpZipLib (https://github.com/icsharpcode/SharpZipLib) to be used inside Unity 📦 [Mirrored from UPM, not affiliated with Unity Technologies.]

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages