archive_read_support_filter_all() 允许代码在构建时没有合适的库时使用外部程序。 (参见 https://www.freebsd.org/cgi/man.cgi?query=archive_read_support_filter_all&sektion=3&apropos=0&manpath=FreeBSD%2B10.0-RELEASE)。
但是 libarchive ( https://github.com/libarchive/libarchive/wiki/Examples ) 本身可以从各种格式中提取数据,并且此功能是 libarchive 的一部分。那么什么时候应该使用它,它有什么作用呢?
有什么区别
- archive_read_support_format_all() ( https://manpages.debian.org/testing/libarchive-dev/archive_read_format.3.en.html )
- archive_read_support_filter_all()
我正在使用 Libarchive 从 ODF 文件中提取数据,我在 Libarchive 的文档和示例中遇到了这个函数,但我不确定这个函数有什么用。
最佳答案
这不是它说的。 archive_read_support_filter_all()
只是“启用所有可用的解压过滤器”。
此外,还有一个关于特定过滤器的注释:
These functions may fall back on external programs if an appropriate library was not available at build time.
因此,_all 只是所有其他(特定)过滤器的超集。
Q. But libarchive (https://github.com/libarchive/libarchive/wiki/Examples) itself extracts data from various formats and this function is a part of libarchive
好吧,这取决于它是如何构建的。如果周围有合适的库,将对 zip
存档的支持编译到库中,那么是的。否则上面的评论适用:libarchive “可能会退回到外部
程序”
Q. What is the difference between
archive_read_support_format_all()
archive_read_support_filter_all()
存档具有特定格式(cpio、tar、zip 等)。此外,它还可以被过滤(gzip、bzip2、lzop、xz 等)。
在一些文件中,过滤器总是相同的,但其他的可以混合和匹配(因此流行的传统扩展名如 .tgz 用于 .tar.gzip 和 .tbz2 用于 .tar.bz2)。
如果您只想使用 bzip2 启用 tar,请使用:
archive_read_support_format_tar(ar);
archive_read_support_filter_bzip2(ar);
如果你想要所有可能的压缩/其他编码过滤器,只要它是 tar:
archive_read_support_format_tar(ar);
archive_read_support_filter_all(ar);
如果你想要 cpio、ar、tar 存档,但前提是不压缩:
archive_read_support_format_ar(ar);
archive_read_support_format_cpio(ar);
archive_read_support_format_tar(ar);
关于c++ - archive_read_support_filter_all() 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62800252/