Libarchive解压到指定的文件夹? [英] Libarchive to extract to a specified folder?

查看:1786
本文介绍了Libarchive解压到指定的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助使用 libarchive 以ZIP文件解压到指定的文件夹?它看起来像提供的示例程序( untar.c tarfilter.c minitar )的所有提取归档到当前工作目录。有没有办法说解压到这个文件夹及以下,以 libarchive ,并且不会影响该计划的活动文件夹?

Anybody can help show examples of using libarchive to extract ZIP files to a specified folder? It looks like the sample programs provided (untar.c, tarfilter.c and minitar) all extracts the archive to the current working directory. Is there a way to say "extract to this folder and below" to libarchive and not clobber the program's active folder?

一个主要驱动因素是,提取code将在后台线程中运行,从而改变程序的工作目录可能产生问题。这也将在iOS应用程序(iPhone,iPad的),这是什么文件夹,应用程序可以写入挑剔的使用。

One of the main drivers is that the extraction code will be run in a background thread, and thus changing the program working directory may create problems. Also this will be used in an iOS application (iPhone, iPad), which is picky on what folders that the application can write to.

先谢谢了。

推荐答案

您可以致电archive_read_extract之前重写每一个archive_entry的路径名。例如:

You can rewrite each archive_entry's pathname before calling archive_read_extract. For example:

const char* path = archive_entry_pathname( entry );
char newPath[PATH_MAX + 1];
snprintf( newPath, PATH_MAX, "/SomeOtherDirectory/%s", path );
archive_entry_set_pathname( entry, newPath );

这篇关于Libarchive解压到指定的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆