Compress-Deflate7

 view release on metacpan or  search on metacpan

7zip/DOC/7zC.txt  view on Meta::CPAN



How To Use
----------

You must download 7-Zip program from www.7-zip.org.

You can create .7z archive with 7z.exe or 7za.exe:

  7za.exe a archive.7z *.htm -r -mx -m0fb=255

If you have big number of files in archive, and you need fast extracting, 
you can use partly-solid archives:
  
  7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K

In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only 
512KB for extracting one file from such archive.


Limitations of current version of 7z ANSI-C Decoder
---------------------------------------------------

 - It reads only "FileName", "Size", "LastWriteTime" and "CRC" information for each file in archive.
 - It supports only LZMA and Copy (no compression) methods with BCJ or BCJ2 filters.
 - It converts original UTF-16 Unicode file names to UTF-8 Unicode file names.
 
These limitations will be fixed in future versions.


Using 7z ANSI-C Decoder Test application:
-----------------------------------------

Usage: 7zDec <command> <archive_name>

<Command>:
  e: Extract files from archive
  l: List contents of archive
  t: Test integrity of archive

Example: 

  7zDec l archive.7z

lists contents of archive.7z

  7zDec e archive.7z

extracts files from archive.7z to current folder.


How to use .7z Decoder
----------------------

Memory allocation
~~~~~~~~~~~~~~~~~

7z Decoder uses two memory pools:
1) Temporary pool
2) Main pool
Such scheme can allow you to avoid fragmentation of allocated blocks.


Steps for using 7z decoder
--------------------------

Use code at 7zMain.c as example.

1) Declare variables:
  inStream                 /* implements ILookInStream interface */
  CSzArEx db;              /* 7z archive database structure */
  ISzAlloc allocImp;       /* memory functions for main pool */
  ISzAlloc allocTempImp;   /* memory functions for temporary pool */

2) call CrcGenerateTable(); function to initialize CRC structures.

3) call SzArEx_Init(&db); function to initialize db structures.

4) call SzArEx_Open(&db, inStream, &allocMain, &allocTemp) to open archive

This function opens archive "inStream" and reads headers to "db".
All items in "db" will be allocated with "allocMain" functions.
SzArEx_Open function allocates and frees temporary structures by "allocTemp" functions.

5) List items or Extract items

  Listing code:
  ~~~~~~~~~~~~~
    {
      UInt32 i;
      for (i = 0; i < db.db.NumFiles; i++)
      {
        CFileItem *f = db.db.Files + i;
        printf("%10d  %s\n", (int)f->Size, f->Name);
      }
    }

  Extracting code:
  ~~~~~~~~~~~~~~~~

  SZ_RESULT SzAr_Extract(
    CArchiveDatabaseEx *db,
    ILookInStream *inStream, 
    UInt32 fileIndex,         /* index of file */
    UInt32 *blockIndex,       /* index of solid block */
    Byte **outBuffer,         /* pointer to pointer to output buffer (allocated with allocMain) */
    size_t *outBufferSize,    /* buffer size for output buffer */
    size_t *offset,           /* offset of stream for required file in *outBuffer */
    size_t *outSizeProcessed, /* size of file in *outBuffer */
    ISzAlloc *allocMain,
    ISzAlloc *allocTemp);

  If you need to decompress more than one file, you can send these values from previous call:
    blockIndex, 
    outBuffer, 
    outBufferSize,
  You can consider "outBuffer" as cache of solid block. If your archive is solid, 
  it will increase decompression speed.

  After decompressing you must free "outBuffer":
  allocImp.Free(outBuffer);



( run in 1.219 second using v1.01-cache-2.11-cpan-364913b4093 )