c++ - LIBZIP 是否提供了一种方法来检查 zip_file 是否是目录?

标签 c++ ubuntu zip libzip

由于兼容性问题,我使用的是相当旧的 libzip 版本 (0.10.1-1.2)。

通常我们通过统计结果来检查文件类型(符号链接(symbolic link)、目录、文件等)。类似地,在 libzip 上我们 zip_stat,但它的结构不包含文件系统 STAT 中的 ST_MOD 之类的任何内容。

struct zip_stat {
    zip_uint64_t valid;         /* which fields have valid values */
    const char *name;           /* name of the file */
    zip_uint64_t index;         /* index within archive */
    zip_uint64_t size;          /* size of file (uncompressed) */
    zip_uint64_t comp_size;     /* size of file (compressed) */
    time_t mtime;           /* modification time */
    zip_uint32_t crc;           /* crc of file data */
    zip_uint16_t comp_method;       /* compression method used */
    zip_uint16_t encryption_method; /* encryption method used */
    zip_uint32_t flags;         /* reserved for future use */
};

有没有办法检查条目是否是DIR?

最佳答案

是的。检查name的最后一个字符是否为'/'。只有目录以 '/' 结尾。

来源:

关于c++ - LIBZIP 是否提供了一种方法来检查 zip_file 是否是目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56480947/

相关文章:

php - 配置 Varnish 后如何将网页缓存 2 分钟。 (Ubuntu 14.04,Apache,PHP)

linux - 创建一个在压缩时会失败的文件

windows - 解压缩大型 zst 文件

ubuntu - zip 存档中是否可以使用硬链接(hard link)?

c++ - 极快is_iequal? (不区分大小写的相等比较)

c++ - 在 Clion : "Target not found" 中构建 C++ 程序

c++ - 加载 vector 中的所有元素

postgresql - 连接本地 postgres 数据库时,docker pgAdmin4 连接被拒绝

android - CrystaX 与 clang++ 和 libc++ 与 boost 和 icu 发生链接错误

java - 在 Ubuntu 上安装 Tomcat 5.5(使用 apt)导致 CATALINA_HOME 未设置