# ZIP Library

This library can be used to create simple uncompressed ZIP files.

## File information

File | common/ilib/zip.h
Classes | Zip
Examples | Creating a ZIP file

# Classes

## zip

    class Zip {
    public:
        Zip();
        void Init(byte * out, byte * temp);
        void AddFile(const char * filename, const byte * data, unsigned len);
        unsigned Final();
    };

### Public functions

Init
  Initializes the internal state of the object and sets the output and a temporary buffer.

  #### Parameters

  byte * out | The buffer that shall be used to write the encoded ZIP file. Note that the buffer must be big enough to hold the entire ZIP file.
  byte * temp | A temporary buffer that is used to cache the directory information created at each call to AddFile. Note that the buffer must be big enough to hold the CDH structure of the ZIP file.

  #### Remarks

  The Init function has to be called before using any other functions of the object.
AddFile
  Adds a file.

  #### Parameters

  const char * filename | The filename.
  const byte * data | The content data of the file.
  unsigned len | The size of the file.

  #### Remarks

  This function can be called mupltiple times.
Final
  Finalizes the ZIP file and writes it to the output buffer given with the Init function.

  #### Parameters

  void * out | The output buffer to write the hash value in binary form. The buffer size must match the hash size defined by the algorithm.

  #### Remarks

  The size function can be used to determine the needed output buffer size.

# Code Example

## Creating a ZIP file.

    byte zipFile[2048];
    byte tmp[1024];

    Zip zip;
    zip.Init(zipFile, tmp);
    zip.AddFile("manifest.json", manifestData, manifestLen);
    zip.AddFile("icon.png", iconData, iconLen);
    unsigned zipFileLen = zip.Final();