⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pkzipcoder.h

📁 ZIP压缩代码:基于开源ZipArchive和zlib
💻 H
字号:
// PKZipCoder.h: interface for the CPKZipCoder class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PKZIPCODER_H__D6C509E0_0F6E_4B69_8C44_BFF42B7CF0D4__INCLUDED_)
#define AFX_PKZIPCODER_H__D6C509E0_0F6E_4B69_8C44_BFF42B7CF0D4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ZipArchive/ZipArchive.h"

class CPKZipCoder
{
public:
    // Create a zip archive with name lpszFileName
    BOOL FileCreate(const char *lpszFileName);

    // Open an existing zip archive named lpszFileName
    BOOL FileOpen(const char *lpszFileName);

    // Add a file to current zip archive
    BOOL FileAdd(const char *lpszFileName);

    // Extract a file to disk from the current zip archive
    BOOL FileExtract(int nFileIndex,
        const char *lpszPath,
        char *lpszOriginalFileName, // [out] the original zipped file name
        long nNameBuffSize);                // [in] the buffer size of lpszOriginalFileName

    // Create a memory based zip archive
    BOOL MemCreate();

    // Open a zip archive in memory
    BOOL MemOpen(const void *pMemFileData, long nDataSize);

    // Add a memory file to current zip archive
    BOOL MemAdd(const char *lpszDumbFileName, // [in] the stored filename in zip
        const void *pFileData,
        long nDataSize);

    // Extract a file from current archive to memory
    BOOL MemExtract(int nFileIndex,
        void *pFileData,                        // [out] buffer to retrieve the memory file
        long nBuffSize,                         // [in] size of pFileData buffer in bytes
        char *lpszOriginalFileName, // [out] the original filename
        long nNameBuffSize);                // [in] size of lpszOriginalFileName buffer

    // Get the file count in the current zip archive
    int GetFileCount();

    // Get the file size of the file nFileIndex in zip archive
    long GetFileSize(int nFileIndex);

    // Close the zip archive. If it is on disk, save it.
    BOOL Close();

    // Get the whole archive size in bytes
    long GetArchiveSize();

    // Get the memory data of the whole archive
    BOOL MemGetArchive(void *pArchiveData, // [out] data buffer
        long nBuffSize);                                         // [in] buffer size of pArchiveData

private:
    CZipArchive m_zipArchive;
    CZipMemFile m_zipMemFile;

    // Is the file exists?
    BOOL FileExists(const char *lpszFileName);

    // Load memory data to CZipMemFile
    BOOL GetDataFromMem(const void *pData, long nDataSize, CZipMemFile &memfile);

    // Save CZipMemFile to memory buffer
    BOOL SetDataToMem(void *pData, long nDataSize, CZipMemFile &memfile);
};

#endif // !defined(AFX_PKZIPCODER_H__D6C509E0_0F6E_4B69_8C44_BFF42B7CF0D4__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -