LIBZIP 是否提供了一种检查zip_file是否是目录的方法?
Does LIBZIP provides a way to check if zip_file is a DIRECTORY?
由于兼容性问题,我使用的是相当旧版本的libzip(0.10.1-1.2(。
通常我们会通过其统计结果检查文件类型(符号链接、目录、文件等(。类似地,在libzip上我们zip_stat,但它的结构不包含文件系统STA中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
的最终字符是否'/'
。只有目录以 '/'
结尾。
来源:
- https://libzip.org/documentation/zip_file_rename.html#ZIP_ER_INVAL
- libzip 源代码中的许多地方都使用此规则。格雷普
'/'
去看他们。
相关文章:
- C++LDAP检查用户是否是特定组的成员
- 检查某些类型是否是模板类 std::optional 的实例化
- 将错误返回给调用方而不是立即在 C++ 中抛出错误是否是一种好的做法
- 如何检查模板专用化是否是基本模板的子类?
- 如何检查变量是否是C++中的地图?
- C++ Chrono 确定一天是否是周末?
- 将相同共享指针的副本存储在不同的向量中是否是一种好的做法?
- 使用类在C++中存储和列出变量/方法是否是一种好的做法
- 代码在 CodeSignal 中工作不正确。不确定这是否是我的代码缺陷
- 如果 C 函数仍然可以间接执行(通过回调函数),那么将它声明为静态函数是否是一种不好的做法?
- MFC 中的窗口消息管理:添加基类调用是否是强制性的?
- 检查 n2 是否是 n1 的倍数后结果错误,但根本没有错误
- C ++:检查它是否是类中的数字
- 传递给放置 new 的指针是否是指向其对象表示形式的非 UB 指针?
- 使用 SET(C++) 检查两个给定字符串是否是字谜时出现运行时错误
- 从 std::string 到 std::array<char,size> 的 memcopy 额外数据是否是一种未定义的行为?
- 有没有办法检查发送到变量的值是否是正确的类型,而它已经在该变量下?
- 如何检查一个模板是否是另一个模板的类成员
- 有没有办法检查用户输入是否是数字?
- 如何知道文本文件中的输入是否是 C++ 中的有效数字