SharpZipLib Documentation

repository·master·Indexed 26 days ago

https://github.com/icsharpcode/sharpziplib

A pure C# compression library providing support for Zip, Tar, GZip, BZip2, and various deflate/zlib implementations. It is a port of the GNU Classpath java.util.zip library designed for .NET projects. The library supports Zip64, PKZIP 2.0 and AES encryption, and GNU long filename extensions for Tar.

Tokens
3.2K
Snippets
5
Records
23
Agent score
87%

What's inside SharpZipLib

  1. Overview of SharpZipLib capabilities

    master

    SharpZipLib is a pure C# compression library that supports a wide range of archiving and compression formats. It is designed to be easily incorporated into any .NET project.

    Supported Formats and Methods:

    • Zip files: Supports both stored and deflate compression, PKZIP 2.0 style encryption, and AES encryption. Supports Zip64 (Deflate64 is not supported).
    • Tar: Supports tar archiving with GNU long filename extensions.
    • GZip: Full GZip support.
    • zlib / Deflate: Supports zlib and raw deflate.
    • BZip2: Full BZip2 support.
  2. Build API documentation with DocFx

    master

    To generate the API documentation (located in the /api folder), you must have DocFx installed. Run the following command from the documentation folder:

    docfx metadata

    Note: It is recommended to run this using the "Developer Command Prompt for VS 2017" (or a compatible Developer Command Prompt) to ensure all necessary environment paths are available.

    docfx metadata
  3. Identify and validate ARC archive files

    master

    ARC files are archive formats created by the SEA ARC program. Because other archivers like Hyper and ZOO also use the 01Ah byte at offset 0, you should perform additional checks to ensure you are processing a valid ARC file.

    Validation Steps:

    1. Check Offset 0: Must be 01Ah.
    2. Check for Hyper-archive: If the next two bytes are HP or ST (or if HYP is found below), it is a Hyper-archive, not ARC.
    3. Check for ZOO: ZOO also uses 01Ah at the start.
    4. Verify Signature: A valid ARC file contains the string SIZ at the end of the header structure (offset 0019h).
  4. LZH File Format Specification

    master

    The LZH (or LHArc) format is a multi-platform archive format. It uses various compression methods including LZW and Arithmetic Encoding. Supported file extensions are .LZH and .ICE.

    LHArc compression types:
      "0" - No compression
      "1" - LZW, 4K buffer, Huffman for upper 6 bits of position
      "2" - unknown
      "3" - unknown
      "4" - LZW, Arithmetic Encoding
      "5" - LZW, Arithmetic Encoding
      "s" - LHa 2.x archive?
      "\" - LHa 2.x archive?
      "d" - LHa 2.x archive?
  5. GZIP File Format Specification

    master

    The GZIP format (developed by the GNU project) uses the following structure for its header. This information is useful for understanding the byte offsets and flags used in GZIP archives.

    OFFSET              Count TYPE   Description
    0000h                   2 char   ID='!',139
    0002h                   1 byte   Method :
                                     0-7 - reserved
                                       8 - deflated
    0003h                   1 byte   File flags :
                                       0 - ASCII-text
                                       1 - Multi-part file
                                       2 - Name present
                                       3 - Comment present
                                       4 - Encrypted
                                       5-8 - reserved
    0004h                   1 dword  File date and time (see table 0009)
    0008h                   1 byte   Extra flags
    0009h                   1 byte   Target OS :
                                       0 - DOS
                                       1 - Amiga
                                       2 - VMS
                                       3 - Unix
                                       4 - ????
                                       5 - Atari
                                       6 - OS/2
                                       7 - MacOS
                                      10 - TOPS-20
                                      11 - Win/32
  6. LBR directory entry variations for LUPC and LU86

    master

    Depending on the specific LBR version/program used, the remaining 16 bytes of a directory entry are used for different metadata:

    LUPC Program

    • Creation Date (8 chars): ASCII format MM/DD/YY.
    • Creation Time (8 chars): ASCII format HH:MM:SS.

    LU86 Program

    • CRC-16 (1 word): Checksum or 0.
    • Creation Date (1 word): CP/M format.
    • Creation Time (1 word): DOS format.
    • Last Modification Date (1 word): CP/M format.
    • Last Modification Time (1 word): DOS format.
    • Bytes in last sector (1 byte).
    • Reserved (5 bytes): Set to 0.
  7. ARJ Compression Methods and File Types

    master

    ARJ supports several compression methods and file types within its header structure.

    Compression Methods:

    • 0: Stored
    • 1: Compressed most (Lempel-Ziv 77 + static Huffman)
    • 2: Compressed (Lempel-Ziv 77 + static Huffman)
    • 3: Compressed faster (Lempel-Ziv 77 + static Huffman)
    • 4: Compressed fastest (Lempel-Ziv 77 + pointer/length unary encoding)

    File Types:

    • 0: Binary
    • 1: 7-bit text
    • 2: Comment header
    • 3: Directory
    • 4: Volume label