From d0caac91ac0a03e021d50d1de978733e11ba2ccd Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 5 Oct 2008 11:04:26 +0200 Subject: VFS API break: Introduce FDisplayName property --- common/treepath_vfs.c | 9 +-- common/treepathutils.c | 15 +++-- common/vfs_types.h | 5 +- common/vfsutils.c | 3 +- gvfs/gvfs.c | 17 +++--- libarchive/libarchive.c | 98 +++++++++++++++++---------------- unrar/unrar.c | 142 ++++++++++++++++++++++++------------------------ zip/zip.cpp | 10 ++-- 8 files changed, 157 insertions(+), 142 deletions(-) diff --git a/common/treepath_vfs.c b/common/treepath_vfs.c index cdea20c..a1c6e91 100644 --- a/common/treepath_vfs.c +++ b/common/treepath_vfs.c @@ -127,8 +127,9 @@ TVFSResult vfs_filelist_file_info(struct VfsFilelistData *data, char *AFileName, if (node) { if (node->data) { copy_vfs_item(node->data, Item); - Item->sFileName = strdup(AFileName); - printf("(II) VFSFileInfo: found file: '%s'\n", Item->sFileName); + Item->FName = strdup(AFileName); + Item->FDisplayName = strdup(AFileName); + printf("(II) VFSFileInfo: found file: '%s'\n", Item->FName); return cVFS_OK; } else { printf("(EE) VFSFileInfo: node->data == NULL! \n"); @@ -167,7 +168,7 @@ TVFSResult vfs_filelist_list_first(struct VfsFilelistData *data, char *sDir, str struct PathTree* node = filelist_tree_get_item_by_index(data->list_dir_node, data->list_dir_index); if (node) { copy_vfs_item(node->data, Item); - printf("(II) VFSListFirst: found file: %s\n", Item->sFileName); + printf("(II) VFSListFirst: found file: %s\n", Item->FName); return cVFS_OK; } else { printf("(II) VFSListFirst: no more files\n"); @@ -190,7 +191,7 @@ TVFSResult vfs_filelist_list_next(struct VfsFilelistData *data, char *sDir, stru struct PathTree* node = filelist_tree_get_item_by_index(data->list_dir_node, data->list_dir_index); if (node) { copy_vfs_item(node->data, Item); - printf("(II) VFSListNext: found file: %s\n", Item->sFileName); + printf("(II) VFSListNext: found file: %s\n", Item->FName); return cVFS_OK; } else { printf("(II) VFSListNext: no more files\n"); diff --git a/common/treepathutils.c b/common/treepathutils.c index d249444..d8a5f10 100644 --- a/common/treepathutils.c +++ b/common/treepathutils.c @@ -46,7 +46,8 @@ struct PathTree* filelist_tree_new() // create placeholder data tree->data = (struct TVFSItem*)malloc(sizeof(struct TVFSItem)); memset(tree->data, 0, sizeof(struct TVFSItem)); - tree->data->sFileName = strdup(tree->node); + tree->data->FName = strdup(tree->node); + tree->data->FDisplayName = strdup(tree->node); tree->data->ItemType = vDirectory; tree->data->iMode = S_IRWXO + S_IRWXG + S_IRWXU; tree->data->iUID = geteuid(); @@ -75,7 +76,8 @@ void filelist_tree_free(struct PathTree *tree) if (tree->items) g_ptr_array_free(tree->items, TRUE); if (tree->data) { - if (tree->data->sFileName) free(tree->data->sFileName); + if (tree->data->FName) free(tree->data->FName); + if (tree->data->FDisplayName) free(tree->data->FDisplayName); if (tree->data->sLinkTo) free(tree->data->sLinkTo); free(tree->data); } @@ -206,7 +208,8 @@ void filelist_tree_add_item_recurr(struct PathTree *tree, const char *path, stru t->data = item; t->index = index; t->node = strdup(path); - if (t->data) t->data->sFileName = strdup(path); + if (t->data) t->data->FName = strdup(path); + if (t->data) t->data->FDisplayName = strdup(path); // create new list of subitems and add new item if (! tree->items) tree->items = g_ptr_array_new(); g_ptr_array_add(tree->items, t); @@ -241,7 +244,8 @@ void filelist_tree_add_item_recurr(struct PathTree *tree, const char *path, stru // create placeholder data node->data = (struct TVFSItem*)malloc(sizeof(struct TVFSItem)); memset(node->data, 0, sizeof(struct TVFSItem)); - node->data->sFileName = strdup(node->node); + node->data->FName = strdup(node->node); + node->data->FDisplayName = strdup(node->node); node->data->ItemType = vDirectory; node->data->iMode = S_IRWXO + S_IRWXG + S_IRWXU; node->data->iUID = geteuid(); @@ -298,7 +302,8 @@ gboolean filelist_tree_add_item(struct PathTree *tree, const char *path, struct // free old data if (found->data) free_vfs_item(found->data); found->data = item; - if (found->data) found->data->sFileName = strdup(found->node); + if (found->data) found->data->FName = strdup(found->node); + if (found->data) found->data->FDisplayName = strdup(found->node); } else // create new item recursively filelist_tree_add_item_recurr(tree, pp, item, index); diff --git a/common/vfs_types.h b/common/vfs_types.h index 609a78b..753f5c5 100644 --- a/common/vfs_types.h +++ b/common/vfs_types.h @@ -35,7 +35,7 @@ typedef void (* TVFSLogFunc)(char *s); typedef int (* TVFSCopyCallBackFunc)(u_int64_t iPos, u_int64_t iMax, void *data); typedef void *TVFSFileDes; -static const int cVFSVersion = 3; // current version of the VFS API +static const int cVFSVersion = 4; // current version of the VFS API // Capabilities static const int capVFS_nil = 0; @@ -91,7 +91,8 @@ enum TVFSItemType { struct TVFSItem { - char *sFileName; + char *FName; + char *FDisplayName; u_int64_t iSize; __time_t m_time; // numbers should be located before the other variables (bug?) __time_t a_time; diff --git a/common/vfsutils.c b/common/vfsutils.c index cc54828..71080eb 100644 --- a/common/vfsutils.c +++ b/common/vfsutils.c @@ -48,7 +48,8 @@ void copy_vfs_item(struct TVFSItem *src, struct TVFSItem *dst) void free_vfs_item(struct TVFSItem *item) { if (item) { - if (item->sFileName) free(item->sFileName); + if (item->FName) free(item->FName); + if (item->FDisplayName) free(item->FDisplayName); if (item->sLinkTo) free(item->sLinkTo); free(item); } diff --git a/gvfs/gvfs.c b/gvfs/gvfs.c index 54ff29f..c9a8a7e 100644 --- a/gvfs/gvfs.c +++ b/gvfs/gvfs.c @@ -31,8 +31,8 @@ -#define VERSION "0.0.5" -#define BUILD_DATE "2008-09-03" +#define VERSION "0.1.0" +#define BUILD_DATE "2008-10-05" #define DEFAULT_BLOCK_SIZE 0x10000 /* 64kB */ #define CONST_DEFAULT_QUERY_INFO_ATTRIBUTES G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_NAME "," \ @@ -167,7 +167,7 @@ mount_done_cb (GObject *object, globs = (struct TVFSGlobs*) user_data; g_assert (globs != NULL); - + succeeded = g_file_mount_enclosing_volume_finish (G_FILE (object), res, &error); if (! succeeded) { @@ -326,7 +326,7 @@ VFSOpen (struct TVFSGlobs *globs, char *sName) if (seg == 4 && uri_schema && uri_username && uri_password && uri_service) uri = g_strdup_printf ("%s://%s@%s", uri_schema, uri_username, uri_service); } - + // g_print ("uri_schema = '%s', uri_username = '%s', uri_password = '%s', uri_service = '%s'\n", uri_schema, uri_username, uri_password, uri_service); // g_print ("uri = '%s'\n", uri); if (uri_schema) @@ -338,7 +338,7 @@ VFSOpen (struct TVFSGlobs *globs, char *sName) if (uri_service) free (uri_service); } - + g_print ("(II) VFSOpen: opening URI '%s'\n", uri ? uri : sName); f = g_file_new_for_commandline_arg (uri ? uri : sName); @@ -418,7 +418,7 @@ VFSGetPath (struct TVFSGlobs *globs) g_free (path); g_object_unref (root); return s; - } + } else return NULL; } @@ -557,7 +557,8 @@ g_file_info_to_TVFSItem (GFileInfo *info, struct TVFSItem *Item) g_assert (info != NULL); g_assert (Item != NULL); - Item->sFileName = g_strdup (g_file_info_get_name (info)); + Item->FName = g_strdup (g_file_info_get_name (info)); + Item->FDisplayName = g_strdup (g_file_info_get_display_name (info)); Item->sLinkTo = g_file_info_get_symlink_target (info) == NULL ? NULL : g_strdup (g_file_info_get_symlink_target (info)); Item->iSize = g_file_info_get_size (info); Item->iMode = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE); @@ -595,7 +596,7 @@ g_file_info_to_TVFSItem (GFileInfo *info, struct TVFSItem *Item) default: Item->ItemType = vRegular; } } - + /* fallback to default file mode if read fails */ if (Item->iMode == 0) { if (Item->ItemType == vDirectory) diff --git a/libarchive/libarchive.c b/libarchive/libarchive.c index ae7409e..dac84d4 100644 --- a/libarchive/libarchive.c +++ b/libarchive/libarchive.c @@ -1,12 +1,12 @@ /* libarchive plugin for Tux Commander - * version 0.0.7, designed for libarchive 2.5.5 + * version 0.1.0, designed for libarchive 2.5.5 * Copyright (C) 2008 Tomas Bzatek * Check for updates on tuxcmd.sourceforge.net * * Uses libarchive library * Copyright (c) 2003-2007 Tim Kientzle - * - * + * + * * This program is free software; you can redistribute it and/or modify @@ -47,8 +47,8 @@ -#define VERSION "0.0.7" -#define BUILD_DATE "2008-09-15" +#define VERSION "0.1.0" +#define BUILD_DATE "2008-10-05" #define DEFAULT_BLOCK_SIZE 65536 @@ -57,7 +57,7 @@ /******************************************************************************************************/ /** Auxiliary classes */ -/************** ****************/ +/************** ****************/ @@ -68,10 +68,10 @@ struct TVFSGlobs { char *archive_path; unsigned long block_size; - + struct PathTree *files; struct VfsFilelistData *vfs_filelist; - + u_int64_t total_size; }; @@ -102,7 +102,7 @@ void VFSDestroy(struct TVFSGlobs *globs) int VFSVersion() { - return 3; + return cVFSVersion; } struct TVFSInfo VFSGetInfo() @@ -111,7 +111,7 @@ struct TVFSInfo VFSGetInfo() module_info.Name = "libarchive plugin"; module_info.Description = "libarchive archiving plugin"; char *s = (char*)malloc(255); - snprintf(s, 255, "version %s, build date: %s\nusing %s\n", + snprintf(s, 255, "version %s, build date: %s\nusing %s\n", VERSION, BUILD_DATE, ARCHIVE_LIBRARY_VERSION); module_info.About = strdup(s); free(s); @@ -178,14 +178,14 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) globs->archive_path = strdup(sName); globs->total_size = 0; fprintf(stderr, "(--) VFSOpen: trying to open archive '%s'...\n", globs->archive_path); - + TVFSResult Result; struct archive *a; struct archive_entry *entry; int r; - + Result = libarchive_open(&a, globs->archive_path, globs->block_size); - if (Result == cVFS_OK) + if (Result == cVFS_OK) { for (;;) { entry = NULL; @@ -201,16 +201,16 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) Result = cVFS_Failed; break; } - + log("found file: %s, mode = %x\n", archive_entry_pathname(entry), archive_entry_mode(entry)); - + // Create a TVFSItem entry and fill all info struct TVFSItem *item = (struct TVFSItem*)malloc(sizeof(struct TVFSItem)); memset(item, 0, sizeof(struct TVFSItem)); - + item->iSize = (u_int64_t)archive_entry_size(entry); globs->total_size += item->iSize; - + mode_t mode = archive_entry_mode(entry); item->iMode = archive_entry_mode(entry); if (S_ISREG(mode)) item->ItemType = vRegular; @@ -223,14 +223,14 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) if (item->ItemType == vSymlink) item->sLinkTo = strdup(archive_entry_symlink(entry)); - + item->iUID = geteuid(); item->iGID = getegid(); item->m_time = archive_entry_mtime(entry); item->c_time = archive_entry_ctime(entry); item->a_time = archive_entry_atime(entry); - - // Add item to the global list and continue with next file + + // Add item to the global list and continue with next file filelist_tree_add_item(globs->files, archive_entry_pathname(entry), item, 0); } archive_read_close(a); @@ -238,12 +238,12 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) archive_read_finish(a); fprintf(stderr, "(II) VFSOpen: done. \n"); - /* FIXME: temporarily disabled */ + /* FIXME: temporarily disabled */ // filelist_tree_resolve_symlinks(globs->files); printf("\n\nList of items:\n"); filelist_tree_print(globs->files); - + return Result; } @@ -256,7 +256,7 @@ TVFSResult VFSClose(struct TVFSGlobs *globs) if (globs->files) filelist_tree_free(globs->files); if (globs->archive_path) free(globs->archive_path); if (globs->curr_dir) free(globs->curr_dir); - } + } return cVFS_OK; } @@ -286,7 +286,7 @@ TVFSResult VFSChangeDir(struct TVFSGlobs *globs, char *NewPath) printf("(EE) VFSChangeDir: NewPath is NULL!\n"); return cVFS_Failed; } - + globs->curr_dir = vfs_filelist_change_dir(globs->vfs_filelist, NewPath); if (globs->curr_dir) return cVFS_OK; else return cVFS_Failed; @@ -319,26 +319,26 @@ TVFSResult VFSListFirst(struct TVFSGlobs *globs, char *sDir, struct TVFSItem *It return cVFS_Failed; } printf ("(--) VFSListFirst: Going to list all items in '%s'\n", sDir); - - return vfs_filelist_list_first(globs->vfs_filelist, sDir, Item); + + return vfs_filelist_list_first(globs->vfs_filelist, sDir, Item); } TVFSResult VFSListNext(struct TVFSGlobs *globs, char *sDir, struct TVFSItem *Item) { - return vfs_filelist_list_next(globs->vfs_filelist, sDir, Item); + return vfs_filelist_list_next(globs->vfs_filelist, sDir, Item); } TVFSResult VFSListClose(struct TVFSGlobs *globs) { - return vfs_filelist_list_close(globs->vfs_filelist); + return vfs_filelist_list_close(globs->vfs_filelist); } /******************************************************************************************************/ long VFSFileExists(struct TVFSGlobs *globs, const char *FileName, const long Use_lstat) { - if (! globs) return FALSE; - return vfs_filelist_file_exists(globs->vfs_filelist, FileName, Use_lstat); + if (! globs) return FALSE; + return vfs_filelist_file_exists(globs->vfs_filelist, FileName, Use_lstat); } TVFSResult VFSFileInfo(struct TVFSGlobs *globs, char *AFileName, struct TVFSItem *Item) @@ -351,7 +351,7 @@ TVFSResult VFSFileInfo(struct TVFSGlobs *globs, char *AFileName, struct TVFSItem /******************************************************************************************************/ /** Recursive tree size counting */ -/************** ****************/ +/************** ****************/ u_int64_t VFSGetDirSize(struct TVFSGlobs *globs, char *APath) { @@ -368,7 +368,7 @@ void VFSBreakGetDirSize(struct TVFSGlobs *globs) /******************************************************************************************************/ /** Methods modifying the archive */ -/************** ****************/ +/************** ****************/ TVFSResult VFSMkDir(struct TVFSGlobs *globs, const char *sDirName) { @@ -486,18 +486,18 @@ my_archive_read_data_into_fd(struct archive *a, struct archive_entry *entry, con off_t output_offset; u_int64_t file_size; gboolean cancel = FALSE; - - + + printf("(II) my_archive_read_data_into_fd: extracting to '%s', Append = %d\n", sDstName, Append); if (Append) fd = open(sDstName, O_APPEND | O_WRONLY); - else fd = open(sDstName, O_CREAT | O_WRONLY | O_TRUNC, + else fd = open(sDstName, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { fprintf(stderr, "(EE) my_archive_read_data_into_fd: error occured while extracting data: %s\n", strerror(errno)); return cVFS_Failed; } - + total_written = 0; output_offset = 0; file_size = (u_int64_t)archive_entry_size(entry); @@ -522,7 +522,7 @@ my_archive_read_data_into_fd(struct archive *a, struct archive_entry *entry, con total_written += bytes_written; p += bytes_written; size -= bytes_written; - + log(" (II) my_archive_read_data_into_fd: bytes_written = %u, total_written = %u\n", bytes_written, total_written); if (pCallBackProgress) { if (! pCallBackProgress(total_written, file_size, data)) { @@ -547,14 +547,14 @@ my_archive_read_data_into_fd(struct archive *a, struct archive_entry *entry, con return cVFS_OK; } - + TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, TVFSCopyCallBackFunc pCallBackProgress, void *data, int Append) { if ((sSrcName == NULL) || (sDstName == NULL) || (strlen(sSrcName) < 1) || (strlen(sDstName) < 1)) { printf("(EE) VFSCopyOut: The value of 'sSrcName' or 'sDstName' is NULL or empty\n"); return cVFS_Failed; } - + printf("(II) VFSCopyOut: copying file '%s' out to '%s'\n", sSrcName, sDstName); char *src; @@ -562,14 +562,14 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char else src = g_strdup(sSrcName); printf("(II) VFSCopyOut: new src path: '%s'\n", src); - + TVFSResult Result; struct archive *a; struct archive_entry *entry; int r; - + Result = libarchive_open(&a, globs->archive_path, globs->block_size); - if (Result == cVFS_OK) + if (Result == cVFS_OK) { for (;;) { entry = NULL; @@ -585,18 +585,18 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char Result = cVFS_Failed; break; } - + // printf ("found file: %s, mode = %x\n", archive_entry_pathname(entry), archive_entry_mode(entry)); - char *ssrc = src; + char *ssrc = src; const char *asrc = archive_entry_pathname(entry); if (IS_DIR_SEP(*ssrc)) ssrc++; - if (IS_DIR_SEP(*asrc)) asrc++; + if (IS_DIR_SEP(*asrc)) asrc++; // printf ("strcmp: '%s' vs. '%s'\n", ssrc, asrc); 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)); - + Result = my_archive_read_data_into_fd(a, entry, sDstName, globs->block_size, pCallBackProgress, data, Append); break; } @@ -605,7 +605,7 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char } archive_read_finish(a); g_free(src); - + fprintf(stderr, "(II) VFSCopyOut: finished. \n"); return Result; } @@ -621,8 +621,10 @@ TVFSResult VFSCopyIn(struct TVFSGlobs *globs, const char *sSrcName, const char * /********** * TODO: + * + * - UTF-8, FName/FDisplayName and absolute/relative paths revision needed! * - archive testing (needs new VFS API) * - write support * - support creating new archives (needs new VFS API) - * + * ***/ diff --git a/unrar/unrar.c b/unrar/unrar.c index 8a725f6..5468b94 100644 --- a/unrar/unrar.c +++ b/unrar/unrar.c @@ -1,28 +1,28 @@ /* UNRAR plugin for Tux Commander - * version 0.2.3, designed for unrar v3.8.2 + * version 0.3.0, designed for unrar v3.8.2 * Copyright (C) 2008 Tomas Bzatek * Check for updates on tuxcmd.sourceforge.net * * Uses UNRAR sources - * UnRAR - free utility for RAR archives + * UnRAR - free utility for RAR archives * Copyright (C) Alexander L. Roshal * http://www.rarlab.com/ - * - - - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -55,8 +55,8 @@ enum HOST_SYSTEM { }; -#define VERSION "0.2.3" -#define BUILD_DATE "2008-08-21" +#define VERSION "0.3.0" +#define BUILD_DATE "2008-10-05" #define DEFAULT_BLOCK_SIZE 65536 @@ -65,7 +65,7 @@ enum HOST_SYSTEM { /******************************************************************************************************/ /** Auxiliary classes */ -/************** ****************/ +/************** ****************/ @@ -74,18 +74,18 @@ struct TVFSGlobs { TVFSLogFunc log_func; char *curr_dir; char *archive_path; - + gboolean need_password; gboolean passwd_callback; char *password; unsigned long block_size; - + struct PathTree *files; struct VfsFilelistData *vfs_filelist; - + u_int64_t total_size; - + void *extract_callback_data; TVFSCopyCallBackFunc extract_callback_func; u_int64_t extract_file_size; @@ -125,7 +125,7 @@ void VFSDestroy(struct TVFSGlobs *globs) int VFSVersion() { - return 3; + return cVFSVersion; } struct TVFSInfo VFSGetInfo() @@ -134,7 +134,7 @@ struct TVFSInfo VFSGetInfo() module_info.Name = "UNRAR plugin"; module_info.Description = "RAR archiving plugin"; char *s = (char*)malloc(255); - snprintf(s, 255, "version %s, build date: %s\nusing unrar sources v%d.%d [%d-%.2d-%.2d]\n", + snprintf(s, 255, "version %s, build date: %s\nusing unrar sources v%d.%d [%d-%.2d-%.2d]\n", VERSION, BUILD_DATE, RARVER_MAJOR, RARVER_MINOR, RARVER_YEAR, RARVER_MONTH, RARVER_DAY); module_info.About = strdup(s); free(s); @@ -163,7 +163,7 @@ int unrar_callback(UINT msg, LONG UserData, LONG P1, LONG P2) { // fprintf(stderr, "(II) unrar_callback called: msg = %d, UserData = %lx, sizeof(UserData) = %ld, P1 = %ld, P2 = %ld\n", msg, UserData, sizeof(UserData), P1, P2); - // >= 0 => Weiter, -1 => Stop + // >= 0 => Weiter, -1 => Stop switch(msg) { case UCM_CHANGEVOLUME: { @@ -191,14 +191,14 @@ int unrar_callback(UINT msg, LONG UserData, LONG P1, LONG P2) globs->extract_done += P2; int res = globs->extract_callback_func(globs->extract_done, globs->extract_file_size, globs->extract_callback_data); - + // fprintf(stderr, " (II) unrar_callback: res = %d \n", res); if (! res ) { globs->extract_cancelled = TRUE; fprintf(stderr, "(WW) unrar_callback: received cancellation result\n"); return -1; // Cancel operation } - } + } break; } @@ -208,7 +208,7 @@ int unrar_callback(UINT msg, LONG UserData, LONG P1, LONG P2) if (globs) globs->passwd_callback = TRUE; break; } - } + } return 0; } @@ -261,16 +261,16 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) archive_data = (struct RAROpenArchiveDataEx*) malloc(sizeof(struct RAROpenArchiveDataEx)); memset(archive_data, 0, sizeof(struct RAROpenArchiveDataEx)); archive_data->ArcName = globs->archive_path; - archive_data->CmtBuf = NULL; + archive_data->CmtBuf = NULL; archive_data->CmtBufSize = 0; archive_data->OpenMode = RAR_OM_LIST; - + handle = RAROpenArchiveEx(archive_data); // printf(" handle = %lu \n", (unsigned long int)handle); // printf(" archive_data->OpenResult = %d \n", archive_data->OpenResult); // printf(" archive_data->CmtState = %d \n", archive_data->CmtState); // printf(" archive_data->CmtSize = %d \n", archive_data->CmtSize); - + if ((handle) && (! archive_data->OpenResult)) { // Set callbacks @@ -282,7 +282,7 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) fprintf(stderr, "(II) VFSOpen: Setting password... \n"); RARSetPassword(handle, globs->password); } - + struct RARHeaderDataEx *header; header = (struct RARHeaderDataEx*) malloc(sizeof(struct RARHeaderDataEx)); memset(header, 0, sizeof(struct RARHeaderDataEx)); @@ -290,7 +290,7 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) header->CmtBufSize = 0; int PASCAL res = 0; - while ((res = RARReadHeaderEx(handle, header)) == 0) + while ((res = RARReadHeaderEx(handle, header)) == 0) { printf(" header->FileName = '%s', Flags = 0x%x\n", header->FileName, header->Flags); @@ -299,7 +299,7 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) memset(item, 0, sizeof(struct TVFSItem)); item->iSize = (u_int64_t)((u_int64_t)(header->UnpSizeHigh * 0x100000000) + (u_int64_t)header->UnpSize); - globs->total_size += item->iSize; + globs->total_size += item->iSize; if ((header->Flags & 0x00e0 /* LHD_WINDOWMASK */ ) == 0x00e0 /* LHD_DIRECTORY */) item->ItemType = vDirectory; else item->ItemType = vRegular; @@ -316,17 +316,17 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) else header->FileAttr = 0x81b6 | header->FileAttr; break; } - + item->iMode = header->FileAttr; item->iUID = geteuid(); item->iGID = getegid(); item->m_time = rar_time_to_unix(header->FileTime); item->c_time = item->m_time; item->a_time = item->m_time; - - // Add item to the global list and continue with next file + + // Add item to the global list and continue with next file filelist_tree_add_item(globs->files, header->FileName, item, 0); - int PASCAL res2 = RARProcessFile(handle, RAR_SKIP, NULL, NULL); + int PASCAL res2 = RARProcessFile(handle, RAR_SKIP, NULL, NULL); if (res2) printf("RARProcessFile result = %d\n", res2); } // printf("\nRARReadHeader result = %d\n", res); @@ -346,13 +346,13 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) fprintf(stderr, "(EE) VFSOpen: error occured when opening archive: OpenResult = %d\n", archive_data->OpenResult); Result = cVFS_Failed; } - + free(archive_data); fprintf(stderr, "(II) VFSOpen: done. \n"); if (globs->need_password) printf("Password present.\n"); printf("\n\nList of items:\n"); filelist_tree_print(globs->files); - + return Result; } @@ -366,7 +366,7 @@ TVFSResult VFSClose(struct TVFSGlobs *globs) if (globs->archive_path) free(globs->archive_path); if (globs->curr_dir) free(globs->curr_dir); if (globs->password) free(globs->password); - } + } return cVFS_OK; } @@ -396,7 +396,7 @@ TVFSResult VFSChangeDir(struct TVFSGlobs *globs, char *NewPath) printf("(EE) VFSChangeDir: NewPath is NULL!\n"); return cVFS_Failed; } - + globs->curr_dir = vfs_filelist_change_dir(globs->vfs_filelist, NewPath); if (globs->curr_dir) return cVFS_OK; else return cVFS_Failed; @@ -432,26 +432,26 @@ TVFSResult VFSListFirst(struct TVFSGlobs *globs, char *sDir, struct TVFSItem *It return cVFS_Failed; } printf ("(--) VFSListFirst: Going to list all items in '%s'\n", sDir); - - return vfs_filelist_list_first(globs->vfs_filelist, sDir, Item); + + return vfs_filelist_list_first(globs->vfs_filelist, sDir, Item); } TVFSResult VFSListNext(struct TVFSGlobs *globs, char *sDir, struct TVFSItem *Item) { - return vfs_filelist_list_next(globs->vfs_filelist, sDir, Item); + return vfs_filelist_list_next(globs->vfs_filelist, sDir, Item); } TVFSResult VFSListClose(struct TVFSGlobs *globs) { - return vfs_filelist_list_close(globs->vfs_filelist); + return vfs_filelist_list_close(globs->vfs_filelist); } /******************************************************************************************************/ long VFSFileExists(struct TVFSGlobs *globs, const char *FileName, const long Use_lstat) { - if (! globs) return FALSE; - return vfs_filelist_file_exists(globs->vfs_filelist, FileName, Use_lstat); + if (! globs) return FALSE; + return vfs_filelist_file_exists(globs->vfs_filelist, FileName, Use_lstat); } TVFSResult VFSFileInfo(struct TVFSGlobs *globs, char *AFileName, struct TVFSItem *Item) @@ -464,7 +464,7 @@ TVFSResult VFSFileInfo(struct TVFSGlobs *globs, char *AFileName, struct TVFSItem /******************************************************************************************************/ /** Recursive tree size counting */ -/************** ****************/ +/************** ****************/ u_int64_t VFSGetDirSize(struct TVFSGlobs *globs, char *APath) { @@ -481,7 +481,7 @@ void VFSBreakGetDirSize(struct TVFSGlobs *globs) /******************************************************************************************************/ /** Methods modifying the archive */ -/************** ****************/ +/************** ****************/ TVFSResult VFSMkDir(struct TVFSGlobs *globs, const char *sDirName) { @@ -587,17 +587,17 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char printf("(EE) VFSCopyOut: The value of 'sSrcName' or 'sDstName' is NULL or empty\n"); return cVFS_Failed; } - + printf("(II) VFSCopyOut: copying file '%s' out to '%s'\n", sSrcName, sDstName); TVFSResult Result = cVFS_OK; - + char *src; if (! IS_DIR_SEP(*sSrcName)) src = g_build_path("/", globs->curr_dir, sSrcName, NULL); else src = g_strdup(sSrcName); printf("(II) VFSCopyOut: new src path: '%s'\n", src); - + // printf("(II) VFSCopyOut: pCallBackProgress = 0x%lX, data = 0x%lX\n", (unsigned long int)pCallBackProgress, (unsigned long int)data); globs->extract_callback_data = data; globs->extract_callback_func = pCallBackProgress; @@ -608,17 +608,17 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char archive_data = (struct RAROpenArchiveDataEx*) malloc(sizeof(struct RAROpenArchiveDataEx)); memset(archive_data, 0, sizeof(struct RAROpenArchiveDataEx)); archive_data->ArcName = globs->archive_path; - archive_data->CmtBuf = NULL; + archive_data->CmtBuf = NULL; archive_data->CmtBufSize = 0; archive_data->OpenMode = RAR_OM_EXTRACT; - + handle = RAROpenArchiveEx(archive_data); // printf(" handle = %lu \n", (unsigned long int)handle); // printf(" archive_data->OpenResult = %d \n", archive_data->OpenResult); // printf(" archive_data->CmtState = %d \n", archive_data->CmtState); // printf(" archive_data->CmtSize = %d \n", archive_data->CmtSize); // printf("sizeof(TVFSResult) = %ld \n", sizeof(TVFSResult)); - + if ((handle) && (! archive_data->OpenResult)) { // Set callbacks @@ -639,12 +639,12 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char header->CmtBufSize = 0; int res = 0; - while ((res = RARReadHeaderEx(handle, header)) == 0) + while ((res = RARReadHeaderEx(handle, header)) == 0) { - char *ssrc = src; + char *ssrc = src; char *asrc = header->FileName; if (IS_DIR_SEP(*ssrc)) ssrc++; - if (IS_DIR_SEP(*asrc)) asrc++; + if (IS_DIR_SEP(*asrc)) asrc++; if (strcmp(ssrc, asrc) == 0) { // fprintf(stderr, "(II) VFSCopyOut: extract_file_path(sDstName) = '%s', extract_file_name(sDstName) = '%s' \n", extract_file_path(sDstName), extract_file_name(sDstName)); globs->extract_done = 0; @@ -652,16 +652,16 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char globs->extract_cancelled = FALSE; int res2 = RARProcessFile(handle, RAR_EXTRACT, NULL, (char *)sDstName); - + if (globs->extract_cancelled) Result = cVFS_Cancelled; - else + else if (res2) { fprintf(stderr, "(EE) VFSCopyOut: RARProcessFile result = %d\n", res2); Result = cVFS_ReadErr; } break; } else { - int res2 = RARProcessFile(handle, RAR_SKIP, NULL, NULL); + int res2 = RARProcessFile(handle, RAR_SKIP, NULL, NULL); if (res2) { fprintf(stderr, "(EE) VFSCopyOut: RARProcessFile result = %d\n", res2); Result = cVFS_ReadErr; @@ -692,12 +692,12 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char Result = cVFS_BadPassword; break; case ERAR_UNKNOWN: - default: + default: Result = cVFS_WriteErr; break; } } - + free(header); res = RARCloseArchive(handle); @@ -709,10 +709,10 @@ TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char fprintf(stderr, "(EE) VFSCopyOut: error occured when opening archive: OpenResult = %d\n", archive_data->OpenResult); Result = cVFS_ReadErr; } - + free(archive_data); g_free(src); - + fprintf(stderr, "(II) VFSCopyOut: finished. \n"); return Result; } @@ -728,7 +728,9 @@ TVFSResult VFSCopyIn(struct TVFSGlobs *globs, const char *sSrcName, const char * /********** * TODO: + * + * - UTF-8, FName/FDisplayName and absolute/relative paths revision needed! * - no error reporting when archive is corrupted * - archive testing (needs new VFS API) - * + * ***/ diff --git a/zip/zip.cpp b/zip/zip.cpp index 76e2513..dc52c05 100644 --- a/zip/zip.cpp +++ b/zip/zip.cpp @@ -1,5 +1,5 @@ /* ZIP plugin for Tux Commander - * version 0.4.5, designed for ZipArchive v3.2.0 + * version 0.5.0, designed for ZipArchive v3.2.0 * Copyright (C) 2008 Tomas Bzatek * Check for updates on tuxcmd.sourceforge.net * @@ -47,8 +47,8 @@ -#define VERSION "0.4.5" -#define BUILD_DATE "2008-02-09" +#define VERSION "0.5.0" +#define BUILD_DATE "2008-10-05" #define DEFAULT_BLOCK_SIZE 65536 @@ -251,7 +251,7 @@ void VFSDestroy(struct TVFSGlobs *globs) int VFSVersion() { - return 3; + return cVFSVersion; } TVFSInfo VFSGetInfo() @@ -969,6 +969,8 @@ TVFSResult VFSCopyIn(struct TVFSGlobs *globs, const char *sSrcName, const char * /*** * Todo: * +* - UTF-8, FName/FDisplayName and absolute/relative paths revision needed! +* (check http://www.artpol-software.com/ZipArchive/KB/0610051525.aspx ) * - implement an "opened" flag - is it really needed? + add tests to all functions * - readonly checking IsReadOnly() + add tests to all functions modifying the archive * - after VFS API update implement archive testing, compression level setting, retrieving compression info for each file and archive, readonly flags, begin-action, end-action (no refresh, faster operations) ... -- cgit v1.2.3