libzip開發筆記(一):libzip庫介紹、編譯和工程模板

紅胖子(紅模仿)發表於2020-12-30
 

前言

  Qt使用一些壓縮解壓功能,選擇libzip庫,libzip庫比較原始,也是很多其他庫的基礎支撐庫。

 

libzip

  libzip是一個C庫,用於讀取,建立和修改zip檔案。可以從資料緩衝區,檔案或直接從其他zip歸檔檔案直接複製的壓縮資料中新增檔案。在不關閉存檔的情況下所做的更改可以還原。
  當前版本是1.7.3,於2020年7月15日釋出。
  官網:https://libzip.org/
  QQ群:1047134658(點選“檔案”搜尋“libzip”,群內與博文同步更新)

 

libzip編譯

步驟一:解壓

在這裡插入圖片描述

步驟二:Cmake配置(vs2017 x64版本)

在這裡插入圖片描述

  需要zlib,之前已經編譯過vs2017 x64版本的zlib了,匯入再配置
在這裡插入圖片描述

步驟三:生成工程

在這裡插入圖片描述

步驟四:開啟VS2017編譯

在這裡插入圖片描述

步驟五:安裝install

在這裡插入圖片描述

 

模組化

在這裡插入圖片描述

 

補充:檢視命令列工具幫助和原始碼輔助開發

ziptool.exe -h
usage: ziptool.exe [-ceghnrst] [-l len] [-o offset] archive command1 [args] [command2 [args] ...]

Supported options are:
        -c              check consistency
        -e              error if archive already exists (only useful with -n)
        -g              guess file name encoding (for stat)
        -h              display this usage
        -l len          only use len bytes of file
        -n              create archive if it doesn't exist
        -o offset       start reading file at offset
        -r              print raw file name encoding without translation (for stat)
        -s              follow file name convention strictly (for stat)
        -t              disregard current archive contents, if any

Supported commands and arguments are:
        add name content
            add file called name using content

        add_dir name
            add directory

        add_file name file_to_add offset len
            add file to archive, len bytes starting from offset

        add_from_zip name archivename index offset len
            add file from another archive, len bytes starting from offset

        cat index
            output file contents to stdout

        count_extra index flags
            show number of extra fields for archive entry

        count_extra_by_id index extra_id flags
            show number of extra fields of type extra_id for archive entry

        delete index
            remove entry

        delete_extra index extra_idx flags
            remove extra field

        delete_extra_by_id index extra_id extra_index flags
            remove extra field of type extra_id

        get_archive_comment
            show archive comment

        get_extra index extra_index flags
            show extra field

        get_extra_by_id index extra_id extra_index flags
            show extra field of type extra_id

        get_file_comment index
            get file comment

        get_num_entries flags
            get number of entries in archive

        name_locate name flags
            find entry in archive

        print_progress
            print progress during zip_close()

        rename index name
            rename entry

        replace_file_contents index data
            replace entry with data

        set_archive_comment comment
            set archive comment

        set_extra index extra_id extra_index flags value
            set extra field

        set_file_comment index comment
            set file comment

        set_file_compression index method compression_flags
            set file compression method

        set_file_dostime index time date
            set file modification time and date (DOS format)

        set_file_encryption index method password
            set file encryption method

        set_file_mtime index timestamp
            set file modification time

        set_file_mtime_all timestamp
            set file modification time for all files

        set_password password
            set default password for encryption

        stat index
            print information about entry


Supported flags are:
        0       (no flags)
        C       ZIP_FL_NOCASE
        c       ZIP_FL_CENTRAL
        d       ZIP_FL_NODIR
        l       ZIP_FL_LOCAL
        u       ZIP_FL_UNCHANGED

Supported compression methods are:
        default
        deflate
        store

Supported encryption methods are:
        none
        AES-128
        AES-192
        AES-256
        PKWARE

The index is zero-based.
 
 
 

相關文章