summaryrefslogtreecommitdiff
path: root/libarchive/libarchive.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-11-15 22:14:21 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-11-15 22:14:21 +0100
commitf1ef4efb60e341a2a8ec72560071656b9d8b927d (patch)
tree71ea4544495fca2a82f78e31beb81b83453e7cef /libarchive/libarchive.c
parent1c50d6836601b8a6258dd6e299b3f299aa8d4a0f (diff)
downloadtuxcmd-modules-f1ef4efb60e341a2a8ec72560071656b9d8b927d.tar.xz
Encoding revision
Diffstat (limited to 'libarchive/libarchive.c')
-rw-r--r--libarchive/libarchive.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/libarchive/libarchive.c b/libarchive/libarchive.c
index efdf379..00f49a1 100644
--- a/libarchive/libarchive.c
+++ b/libarchive/libarchive.c
@@ -260,8 +260,34 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName)
item->c_time = archive_entry_ctime(entry);
item->a_time = archive_entry_atime(entry);
+#if 0
+ char *s;
+ if (! archive_entry_pathname_w(entry)) {
+ if (g_utf8_validate (archive_entry_pathname(entry), -1, NULL))
+ s = g_strdup (archive_entry_pathname(entry));
+ else
+ s = g_filename_display_name (archive_entry_pathname(entry));
+ }
+ else
+ s = wide_to_utf8 (archive_entry_pathname_w(entry));
+#endif
+
+ char *s;
+ if (g_utf8_validate (archive_entry_pathname(entry), -1, NULL))
+ s = g_strdup (archive_entry_pathname(entry));
+ else {
+ if (archive_entry_pathname_w(entry))
+ s = wide_to_utf8 (archive_entry_pathname_w(entry));
+ else
+ s = g_filename_display_name (archive_entry_pathname(entry));
+ }
+
+
+// g_print("file = '%s', wide = '%ls'\n", archive_entry_pathname(entry), archive_entry_pathname_w(entry));
+
// Add item to the global list and continue with next file
- filelist_tree_add_item(globs->files, archive_entry_pathname(entry), item, 0);
+ filelist_tree_add_item(globs->files, s, archive_entry_pathname(entry), item, 0);
+ g_free (s);
}
archive_read_close(a);
}
@@ -575,9 +601,17 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char
printf("(II) VFSCopyOut: copying file '%s' out to '%s'\n", sSrcName, sDstName);
- char *src;
- if (! IS_DIR_SEP(*sSrcName)) src = g_build_path("/", globs->curr_dir, sSrcName, NULL);
- else src = g_strdup(sSrcName);
+ struct PathTree *node = filelist_tree_find_node_by_path(globs->files, sSrcName);
+ if (! node) {
+ fprintf(stderr, "(EE) VFSCopyOut: cannot find file '%s'\n", sSrcName);
+ return cVFS_ReadErr;
+ }
+
+ const char *src = node->original_pathstr;
+ if (! src) {
+ fprintf(stderr, "(WW) VFSCopyOut: cannot determine original filename\n");
+ src = sSrcName;
+ }
printf("(II) VFSCopyOut: new src path: '%s'\n", src);
@@ -585,6 +619,7 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char
struct archive *a;
struct archive_entry *entry;
int r;
+ gboolean found = FALSE;
Result = libarchive_open(&a, globs->archive_path, globs->block_size);
if (Result == cVFS_OK)
@@ -605,7 +640,7 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char
}
// printf ("found file: %s, mode = %x\n", archive_entry_pathname(entry), archive_entry_mode(entry));
- char *ssrc = src;
+ const char *ssrc = src;
const char *asrc = archive_entry_pathname(entry);
if (IS_DIR_SEP(*ssrc)) ssrc++;
if (IS_DIR_SEP(*asrc)) asrc++;
@@ -614,6 +649,7 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char
if (strcmp(ssrc, asrc) == 0) {
// printf("--> found file, extracting\n");
fprintf(stderr, "(II) VFSCopyOut: extract_file_path(sDstName) = '%s', extract_file_name(sDstName) = '%s' \n", extract_file_path(sDstName), extract_file_name(sDstName));
+ found = TRUE;
Result = my_archive_read_data_into_fd(globs, a, entry, sDstName, globs->block_size, Append);
break;
@@ -622,7 +658,11 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char
archive_read_close(a);
}
archive_read_finish(a);
- g_free(src);
+
+ if ((! found) && Result == cVFS_OK) {
+ fprintf(stderr, "(EE) VFSCopyOut: file not found in archive.\n");
+ Result = cVFS_ReadErr;
+ }
fprintf(stderr, "(II) VFSCopyOut: finished. \n");
return Result;