/* libzzutil
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2000-2006, Toni Thomsson <toni@tonjac.org> 
*/

#ifndef zz_zip_h
#define zz_zip_h

#pragma warning(disable:4786)

extern "C"
{
    #include <structs.h>
}

#include <windows.h>
#include <direct.h>
#include <map>
#include <string>
#include <zz_file.h>
#include <zz_exception.h>
#include <zz_string.h>

using namespace std;

extern "C"
{

// Description: callback, endast internt
typedef int ( __stdcall FUNC_ZPINIT )( ZIPUSERFUNCTIONS* );

// Description: callback, endast internt
typedef BOOL ( __stdcall FUNC_ZPSETOPTIONS )( ZPOPT );

// Description: callback, endast internt
typedef int ( __stdcall FUNC_ZPARCHIVE )( ZCL );

}



/*
    Description:
    Zip-arkiv

    Remarks:
    En "wrapper" kring ZIP-API:et från InfoZip

    Author: 
    Toni Thomsson, toni@tonjac.org

    Library:
    libzzutil.lib zip32.dll

    Platform:
    win32
*/
class ZZ_API CzzZip : public CzzFile
{
public:

    /*
        Description:
        Skapar ett ZIP-arkiv
        
        Throws:
        CzzException
    */
    CzzZip( const char* archive // IN, arkivnamn (sökväg)
                );

    virtual ~CzzZip();

    /*
        Description:
        Lägger till en fil till arkivet
        
        Throws:
        CzzException
    */
    void AddFile( const char* file // IN, sökväg till fil som skall arkiveras
                    );

    /*
        Description:
        Komprimerar arkivet
        
        Throws:
        CzzException
    */
    void Compress( void );

private:

    void InitOptions( void );

    map<int, string > m_Files;
    HINSTANCE m_hDLL;
    string m_Name;
    ZPOPT m_Options;
    ZCL m_Archive;
    ZIPUSERFUNCTIONS m_UserFuncs;
    FUNC_ZPSETOPTIONS* m_pfZpSetOptions;
    FUNC_ZPINIT* m_pfZpInit;
    FUNC_ZPARCHIVE* m_pfZpArchive;
};

#endif // zz_zip_h