LIBZIP 是否提供了检查 zip_file 是否为目录的方法?

Rod*_*rba 2 c++ ubuntu zip libzip

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

通常我们通过统计结果来检查文件类型(符号链接、目录、文件等)。类似地,在 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 */
};
Run Code Online (Sandbox Code Playgroud)

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

Rya*_*nCu 6

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

资料来源: