+void unpack_members(struct archive *a, char *dest) {
- int restore = 0;
- char prevcwd[PATH_MAX];
- struct archive_entry *e = NULL;
- if (getcwd(prevcwd, PATH_MAX) == NULL)
logMessage(ERROR, "unable to getcwd() (%s:%d): %m", __func__,__LINE__);- else
restore = 1;- if (dest != NULL && access(dest, R_OK|W_OK|X_OK)) {
if (g_mkdir_with_parents(dest, 0755) == -1)logMessage(ERROR, "unable to mkdir %s (%s:%d): %m",dest, __func__, __LINE__);- } else if (chdir(dest) == -1) {
logMessage(ERROR, "unable to chdir %s (%s:%d): %m",dest, __func__, __LINE__);- }
If either of these things fail, you should return instead of blasting the archive members into wherever the current directory may be. Perhaps unpack_members should return a value to indicate this.
- Chris