summaryrefslogtreecommitdiff
path: root/libarchive
diff options
context:
space:
mode:
Diffstat (limited to 'libarchive')
-rw-r--r--libarchive/Makefile34
l---------libarchive/filelist-vfs-intf.c1
l---------libarchive/filelist-vfs-intf.h1
l---------libarchive/filelist.c1
l---------libarchive/filelist.h1
-rw-r--r--libarchive/libarchive.c688
l---------libarchive/treepath_vfs.c1
l---------libarchive/treepath_vfs.h1
l---------libarchive/treepathutils.c1
l---------libarchive/treepathutils.h1
l---------libarchive/tuxcmd-vfs.h1
l---------libarchive/vfs_types.h1
12 files changed, 382 insertions, 350 deletions
diff --git a/libarchive/Makefile b/libarchive/Makefile
index 595cd5f..26b4502 100644
--- a/libarchive/Makefile
+++ b/libarchive/Makefile
@@ -1,30 +1,26 @@
# path definitions
DESTDIR = /usr
-INSTALL=install -c
+INSTALL = install -c
INSTALL_DATA = ${INSTALL} -m 644
-DIR_COMMON=../common/
-DIR_LIBARCHIVE=./libarchive-2.7.1
+DIR_LIBARCHIVE = ./libarchive-2.7.1
# compiler options
CC = gcc
-CPP = g++
-CFLAGS =-I. -I/usr/include -I$(DIR_COMMON) \
- -Wall -fPIC -O2 -g \
- -DG_DISABLE_DEPRECATED -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE \
- -D__VERBOSE_DEBUGx
+CFLAGS = -I. -I/usr/include \
+ -Wall -fPIC -O2 -g \
+ -DG_DISABLE_DEPRECATED -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE \
+ -D__VERBOSE_DEBUGx
-LIB_SUFFIX=`if test \`uname -m\` = x86_64 -o \`uname -m\` = ppc64; then echo 64; fi`
+LIB_SUFFIX = `if test \`uname -m\` = x86_64 -o \`uname -m\` = ppc64; then echo 64; fi`
-VFS_COMMON_OBJECTS=strutils.o treepathutils.o treepath_vfs.o vfsutils.o
+VFS_COMMON_OBJECTS = filelist.o filelist-vfs-intf.o strutils.o vfsutils.o
+
+VFS_OBJECTS = libarchive.o
-VFS_OBJECTS=libarchive.o
-
-.SUFFIXES: .c .cpp
+.SUFFIXES: .c
.c.o:
$(CC) $(CFLAGS) `pkg-config glib-2.0 --cflags` -c $<
-.cpp.o:
- $(CPP) $(CFLAGS) `pkg-config glib-2.0 --cflags` -c $<
all: static
@@ -48,10 +44,10 @@ lib_libarchive_compile:
fi;
-strutils.o: strutils.c strutils.h
-treepathutils.o: treepathutils.c treepathutils.h
-vfsutils.o: vfsutils.c vfsutils.h
-treepath_vfs.o: treepath_vfs.c treepath_vfs.h
+filelist.o: filelist.h filelist.c
+filelist-vfs-intf.o: filelist-vfs-intf.h filelist-vfs-intf.c
+strutils.o: strutils.h strutils.c
+vfsutils.o: vfsutils.h vfsutils.c
install::
$(INSTALL) ./libarchive_plugin.so $(DESTDIR)/lib$(LIB_SUFFIX)/tuxcmd/
diff --git a/libarchive/filelist-vfs-intf.c b/libarchive/filelist-vfs-intf.c
new file mode 120000
index 0000000..68d7a7c
--- /dev/null
+++ b/libarchive/filelist-vfs-intf.c
@@ -0,0 +1 @@
+../common/filelist-vfs-intf.c \ No newline at end of file
diff --git a/libarchive/filelist-vfs-intf.h b/libarchive/filelist-vfs-intf.h
new file mode 120000
index 0000000..f7afe49
--- /dev/null
+++ b/libarchive/filelist-vfs-intf.h
@@ -0,0 +1 @@
+../common/filelist-vfs-intf.h \ No newline at end of file
diff --git a/libarchive/filelist.c b/libarchive/filelist.c
new file mode 120000
index 0000000..9504563
--- /dev/null
+++ b/libarchive/filelist.c
@@ -0,0 +1 @@
+../common/filelist.c \ No newline at end of file
diff --git a/libarchive/filelist.h b/libarchive/filelist.h
new file mode 120000
index 0000000..90a52e1
--- /dev/null
+++ b/libarchive/filelist.h
@@ -0,0 +1 @@
+../common/filelist.h \ No newline at end of file
diff --git a/libarchive/libarchive.c b/libarchive/libarchive.c
index e9ecfc0..13039f2 100644
--- a/libarchive/libarchive.c
+++ b/libarchive/libarchive.c
@@ -1,5 +1,5 @@
/* libarchive plugin for Tux Commander
- * version 0.1.7, designed for libarchive v2.5.5 - v2.7.1 (recommended)
+ * version 0.2.0, designed for libarchive v2.5.5 - v2.7.1 (recommended)
* Copyright (C) 2008-2009 Tomas Bzatek <tbzatek@users.sourceforge.net>
* Check for updates on tuxcmd.sourceforge.net
*
@@ -27,21 +27,15 @@
#include <string.h>
#include <stdlib.h>
-#include <stdint.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
-#include <dirent.h>
-#include <fnmatch.h>
-#include <unistd.h>
#include <glib.h>
-#include "vfs_types.h"
+#include "tuxcmd-vfs.h"
#include "vfsutils.h"
#include "strutils.h"
-#include "treepathutils.h"
-#include "treepath_vfs.h"
+#include "filelist.h"
+#include "filelist-vfs-intf.h"
#include <archive.h>
#include <archive_entry.h>
@@ -58,8 +52,8 @@
#endif
-#define MODULE_VERSION "0.1.7"
-#define MODULE_BUILD_DATE "2009-11-17"
+#define MODULE_VERSION "0.2.0"
+#define MODULE_BUILD_DATE "2009-11-26"
#define DEFAULT_BLOCK_SIZE 65536
@@ -70,20 +64,18 @@
/** Auxiliary classes */
/************** ****************/
-
-
-// Declaration of the global plugin object
+/* declaration of the global plugin object */
struct TVFSGlobs {
TVFSLogFunc log_func;
char *curr_dir;
char *archive_path;
- unsigned long block_size;
+ guint32 block_size;
struct PathTree *files;
struct VfsFilelistData *vfs_filelist;
- u_int64_t total_size;
+ guint64 total_size;
TVFSAskQuestionCallback callback_ask_question;
TVFSAskPasswordCallback callback_ask_password;
@@ -94,18 +86,16 @@ struct TVFSGlobs {
+/******************************************************************************************************/
+/** Basic initialization functions */
+/************** ****************/
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////
-// Basic initialization functions
struct TVFSGlobs *
VFSNew (TVFSLogFunc log_func)
{
struct TVFSGlobs * globs;
- globs = (struct TVFSGlobs *) malloc (sizeof (struct TVFSGlobs));
- memset (globs, 0, sizeof (struct TVFSGlobs));
+ globs = g_malloc0 (sizeof (struct TVFSGlobs));
globs->block_size = DEFAULT_BLOCK_SIZE;
@@ -115,17 +105,28 @@ VFSNew (TVFSLogFunc log_func)
globs->callback_progress = NULL;
globs->log_func = log_func;
- if (globs->log_func != NULL) globs->log_func("libarchive plugin: VFSInit");
+ if (globs->log_func != NULL)
+ globs->log_func ("libarchive plugin: VFSInit");
return globs;
}
+
void
-VFSSetCallbacks (struct TVFSGlobs *globs,
- TVFSAskQuestionCallback ask_question_callback,
- TVFSAskPasswordCallback ask_password_callback,
- TVFSProgressCallback progress_func,
- void *data)
+VFSFree (struct TVFSGlobs *globs)
+{
+ if (globs->log_func != NULL)
+ globs->log_func ("libarchive plugin: VFSDestroy");
+ g_free (globs);
+}
+
+
+void
+VFSSetCallbacks (struct TVFSGlobs *globs,
+ TVFSAskQuestionCallback ask_question_callback,
+ TVFSAskPasswordCallback ask_password_callback,
+ TVFSProgressCallback progress_func,
+ void *data)
{
globs->callback_ask_question = ask_question_callback;
globs->callback_ask_password = ask_password_callback;
@@ -133,18 +134,13 @@ VFSSetCallbacks (struct TVFSGlobs *globs,
globs->callback_data = data;
}
-void
-VFSFree (struct TVFSGlobs *globs)
-{
- if (globs->log_func != NULL) globs->log_func("libarchive plugin: VFSDestroy");
- free (globs);
-}
int VFSVersion()
{
return cVFSVersion;
}
+
struct TVFSInfo *
VFSGetInfo()
{
@@ -164,15 +160,16 @@ VFSGetInfo()
return module_info;
}
+
char *
VFSGetArchiveExts ()
{
/* Make sure these end with a semicolon */
-#define BASIC_FORMATS "tar;cpio;iso;a;shar;"
-#define BZIP_FORMATS "tar.bz2;tbz2;"
-#define ZLIB_FORMATS "tar.gz;tgz;tar.z;deb;"
-#define XZ_FORMATS "tar.lzma;tar.xz;"
-#define LZMA_FORMATS "tar.lzma;"
+#define BASIC_FORMATS "tar;cpio;iso;a;shar;"
+#define BZIP_FORMATS "tar.bz2;tbz2;"
+#define ZLIB_FORMATS "tar.gz;tgz;tar.z;deb;"
+#define XZ_FORMATS "tar.lzma;tar.xz;"
+#define LZMA_FORMATS "tar.lzma;"
char *formats;
@@ -248,172 +245,207 @@ char *formats;
/**************************************************************************************************************************************/
/**************************************************************************************************************************************/
-static TVFSResult libarchive_open(struct archive **a, const char *filename, size_t block_size)
+static TVFSResult
+libarchive_open (struct archive **a, const char *filename, guint32 block_size)
{
int r;
- *a = archive_read_new();
+ *a = archive_read_new ();
- // Register supported formats
+ /* Register supported formats */
+ archive_read_support_compression_all (*a);
+ archive_read_support_format_all (*a);
- archive_read_support_compression_all(*a);
- archive_read_support_format_all(*a);
-
- r = archive_read_open_file(*a, filename, block_size);
+ r = archive_read_open_file (*a, filename, block_size);
if (r) {
- fprintf(stderr, "(EE) libarchive_open: error occured when opening archive: %s\n", archive_error_string(*a));
+ fprintf (stderr, "(EE) libarchive_open: error occured when opening archive: %s\n", archive_error_string (*a));
return cVFS_Failed;
}
return cVFS_OK;
}
-
-
-TVFSResult VFSOpenArchive(struct TVFSGlobs *globs, char *sName)
+TVFSResult
+VFSOpenArchive (struct TVFSGlobs *globs, const char *sName)
{
- globs->files = filelist_tree_new();
- globs->vfs_filelist = vfs_filelist_new(globs->files);
- globs->curr_dir = NULL;
- globs->archive_path = strdup(sName);
- globs->total_size = 0;
- fprintf(stderr, "(--) VFSOpenArchive: trying to open archive '%s'...\n", globs->archive_path);
-
TVFSResult Result;
struct archive *a;
struct archive_entry *entry;
+ struct TVFSItem *item;
int r;
+ char *s;
- Result = libarchive_open(&a, globs->archive_path, globs->block_size);
- if (Result == cVFS_OK)
- {
- for (;;) {
- entry = NULL;
- r = archive_read_next_header(a, &entry);
- if (r == ARCHIVE_EOF) {
- break;
- } else
- if (r == ARCHIVE_WARN) {
- log("(WW) VFSOpenArchive: file '%s' - libarchive warning: '%s'\n", archive_entry_pathname(entry), archive_error_string(a));
- } else
- if (r != ARCHIVE_OK) {
- fprintf(stderr, "(EE) VFSOpenArchive: error occured while reading archive: '%s'\n", archive_error_string(a));
- 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 = (int64_t)archive_entry_size(entry);
- item->iPackedSize = -1; /* no support */
- 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;
- else if (S_ISDIR(mode)) item->ItemType = vDirectory;
- else if (S_ISCHR(mode)) item->ItemType = vChardev;
- else if (S_ISBLK(mode)) item->ItemType = vBlockdev;
- else if (S_ISFIFO(mode)) item->ItemType = vFifo;
- else if (S_ISLNK(mode)) item->ItemType = vSymlink;
- else if (S_ISSOCK(mode)) item->ItemType = vSock;
-
- 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);
-
- 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, s, archive_entry_pathname(entry), item, 0);
- g_free (s);
- }
- archive_read_close(a);
+ globs->files = filelist_tree_new ();
+ globs->vfs_filelist = vfs_filelist_new (globs->files);
+ globs->curr_dir = NULL;
+ globs->archive_path = g_strdup (sName);
+ globs->total_size = 0;
+ fprintf (stderr, "(--) VFSOpenArchive: trying to open archive '%s'...\n", globs->archive_path);
+
+ Result = libarchive_open (&a, globs->archive_path, globs->block_size);
+ if (Result == cVFS_OK) {
+ for (;;) {
+ entry = NULL;
+ r = archive_read_next_header (a, &entry);
+ if (r == ARCHIVE_EOF) {
+ break;
+ } else
+ if (r == ARCHIVE_WARN) {
+ log ("(WW) VFSOpenArchive: file '%s' - libarchive warning: '%s'\n", archive_entry_pathname (entry), archive_error_string (a));
+ } else
+ if (r != ARCHIVE_OK) {
+ fprintf (stderr, "(EE) VFSOpenArchive: error occured while reading archive: '%s'\n", archive_error_string (a));
+ 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 */
+ item = g_malloc0 (sizeof (struct TVFSItem));
+
+ item->iSize = (guint64) archive_entry_size (entry);
+ item->iPackedSize = -1; /* no support */
+ globs->total_size += item->iSize;
+
+ item->iMode = archive_entry_mode (entry);
+ item->ItemType = vRegular; /* fallback */
+ item->IsLink = FALSE;
+ switch (archive_entry_filetype (entry)) {
+ case AE_IFDIR:
+ item->ItemType = vDirectory;
+ break;
+ case AE_IFIFO:
+ item->ItemType = vFifo;
+ break;
+ case AE_IFCHR:
+ item->ItemType = vChardev;
+ break;
+ case AE_IFBLK:
+ item->ItemType = vBlockdev;
+ break;
+ case AE_IFSOCK:
+ item->ItemType = vSock;
+ break;
+ case AE_IFLNK:
+ item->IsLink = TRUE;
+ break;
+ case AE_IFMT:
+ item->ItemType = vOther;
+ break;
+ case AE_IFREG:
+ default:
+ item->ItemType = vRegular;
+ break;
+ }
+
+ if (item->IsLink)
+ item->sLinkTo = g_strdup (archive_entry_symlink (entry));
+
+/* item->iUID = geteuid();
+ item->iGID = getegid(); */
+ item->iUID = archive_entry_uid (entry);
+ item->iGID = archive_entry_gid (entry);
+ item->m_time = archive_entry_mtime (entry);
+ item->c_time = archive_entry_ctime (entry);
+ item->a_time = archive_entry_atime (entry);
+
+ /* Create valid UTF-8 filename */
+ 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));
+ }
+
+ /* Add item to the global tree and continue with next file */
+ filelist_tree_add_item (globs->files, s, item, archive_entry_pathname (entry), 0);
+ g_free (s);
+ }
+ archive_read_close (a);
}
- archive_read_finish(a);
- fprintf(stderr, "(II) VFSOpenArchive: done. \n");
+ archive_read_finish (a);
+ fprintf (stderr, "(II) VFSOpenArchive: done. \n");
- /* FIXME: temporarily disabled */
-// filelist_tree_resolve_symlinks(globs->files);
+ /* Resolve symlinks */
+ GTimer *timer = g_timer_new ();
+ filelist_tree_resolve_symlinks (globs->files);
+ g_print (" filelist_tree_resolve_symlinks: elapsed %d ms\n", (int) (g_timer_elapsed (timer, NULL) * 1000));
+ g_timer_destroy (timer);
- printf("\n\nList of items:\n");
- filelist_tree_print(globs->files);
+ printf ("\n\nList of items:\n");
+ filelist_tree_print (globs->files);
return Result;
}
-TVFSResult VFSClose(struct TVFSGlobs *globs)
+TVFSResult
+VFSClose (struct TVFSGlobs *globs)
{
if (globs) {
- fprintf(stderr, "(II) VFSClose: Freeing objects...\n");
- if (globs->vfs_filelist) vfs_filelist_free(globs->vfs_filelist);
- if (globs->files) filelist_tree_free(globs->files);
- if (globs->archive_path) free(globs->archive_path);
- if (globs->curr_dir) free(globs->curr_dir);
+ fprintf (stderr, "(II) VFSClose: Freeing objects...\n");
+ if (globs->vfs_filelist)
+ vfs_filelist_free (globs->vfs_filelist);
+ if (globs->files)
+ filelist_tree_free (globs->files);
+ g_free (globs->archive_path);
+ g_free (globs->curr_dir);
}
return cVFS_OK;
}
+
char *
VFSGetPath (struct TVFSGlobs *globs)
{
return include_trailing_path_sep (globs->curr_dir);
}
-u_int64_t VFSGetFileSystemFree(struct TVFSGlobs *globs, char *APath)
-{
- return 0;
-}
-u_int64_t VFSGetFileSystemSize(struct TVFSGlobs *globs, char *APath)
+TVFSResult
+VFSGetFileSystemInfo (struct TVFSGlobs *globs, const char *APath, gint64 *FSSize, gint64 *FSFree, char **FSLabel)
{
- return globs->total_size;
+ if (FSSize)
+ *FSSize = globs->total_size;
+ if (FSFree)
+ *FSFree = 0;
+ if (FSLabel)
+ *FSLabel = NULL;
+ return cVFS_OK;
}
-
-
-
/******************************************************************************************************/
-TVFSResult VFSChangeDir(struct TVFSGlobs *globs, char *NewPath)
+TVFSResult
+VFSChangeDir (struct TVFSGlobs *globs, const char *NewPath)
{
if (NewPath == NULL) {
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;
+ globs->curr_dir = vfs_filelist_change_dir (globs->vfs_filelist, NewPath);
+ if (globs->curr_dir)
+ return cVFS_OK;
+ else
+ return cVFS_Failed;
}
-int VFSGetPasswordRequired(struct TVFSGlobs *globs)
+
+gboolean
+VFSGetPasswordRequired (struct TVFSGlobs *globs)
{
+ /* no support for encrypted archives in libarchive */
return FALSE;
}
/******************************************************************************************************/
-TVFSResult VFSListFirst(struct TVFSGlobs *globs, char *sDir, struct TVFSItem *Item)
+TVFSResult
+VFSListFirst (struct TVFSGlobs *globs, const char *sDir, struct TVFSItem *Item, gboolean FollowSymlinks, gboolean AddFullPath)
{
if (sDir == NULL) {
printf("(EE) VFSListFirst: sDir is NULL!\n");
@@ -421,32 +453,32 @@ TVFSResult VFSListFirst(struct TVFSGlobs *globs, char *sDir, struct TVFSItem *It
}
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, FollowSymlinks, AddFullPath);
}
-TVFSResult VFSListNext(struct TVFSGlobs *globs, char *sDir, struct TVFSItem *Item)
+TVFSResult
+VFSListNext (struct TVFSGlobs *globs, struct TVFSItem *Item)
{
- return vfs_filelist_list_next(globs->vfs_filelist, sDir, Item);
+ return vfs_filelist_list_next (globs->vfs_filelist, Item);
}
-TVFSResult VFSListClose(struct TVFSGlobs *globs)
+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);
-}
-TVFSResult VFSFileInfo(struct TVFSGlobs *globs, char *AFileName, struct TVFSItem *Item)
+TVFSResult
+VFSFileInfo (struct TVFSGlobs *globs, const char *AFileName, struct TVFSItem *Item, gboolean FollowSymlinks, gboolean AddFullPath)
{
- printf("(--) VFSFileInfo: requested info for object '%s'\n", AFileName);
- if (!globs) return cVFS_Failed;
- return vfs_filelist_file_info(globs->vfs_filelist, AFileName, Item);
+ printf ("(--) VFSFileInfo: requested info for object '%s'\n", AFileName);
+ if (! globs)
+ return cVFS_Failed;
+
+ return vfs_filelist_file_info (globs->vfs_filelist, AFileName, Item, FollowSymlinks, AddFullPath);
}
@@ -454,16 +486,22 @@ TVFSResult VFSFileInfo(struct TVFSGlobs *globs, char *AFileName, struct TVFSItem
/** Recursive tree size counting */
/************** ****************/
-u_int64_t VFSGetDirSize(struct TVFSGlobs *globs, char *APath)
+guint64
+VFSGetDirSize (struct TVFSGlobs *globs, const char *APath)
{
- if (! globs) return 0;
- return vfs_filelist_get_dir_size(globs->vfs_filelist, APath);
+ if (! globs)
+ return 0;
+
+ return vfs_filelist_get_dir_size (globs->vfs_filelist, APath);
}
-void VFSBreakGetDirSize(struct TVFSGlobs *globs)
+void
+VFSBreakGetDirSize (struct TVFSGlobs *globs)
{
- printf("(WW) VFSBreakGetDirSize: calling break\n");
- if (globs) vfs_filelist_get_dir_size_break(globs->vfs_filelist);
+ printf ("(WW) VFSBreakGetDirSize: calling break\n");
+
+ if (globs)
+ vfs_filelist_get_dir_size_break (globs->vfs_filelist);
}
@@ -471,52 +509,52 @@ void VFSBreakGetDirSize(struct TVFSGlobs *globs)
/** Methods modifying the archive */
/************** ****************/
-TVFSResult VFSMkDir(struct TVFSGlobs *globs, const char *sDirName)
+TVFSResult VFSMkDir (struct TVFSGlobs *globs, const char *sDirName)
{
- printf("(WW) VFSMkDir: Not supported in libarchive plugin.\n");
+ printf ("(WW) VFSMkDir: Not supported in libarchive plugin.\n");
return cVFS_Not_Supported;
}
-TVFSResult VFSRemove(struct TVFSGlobs *globs, const char *APath)
+TVFSResult VFSRemove (struct TVFSGlobs *globs, const char *APath)
{
- printf("(WW) VFSRemove: Not supported in libarchive plugin.\n");
+ printf ("(WW) VFSRemove: Not supported in libarchive plugin.\n");
return cVFS_Not_Supported;
}
-TVFSResult VFSRename(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName)
+TVFSResult VFSRename (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName)
{
- printf("(WW) VFSRename: Not supported in libarchive plugin.\n");
+ printf ("(WW) VFSRename: Not supported in libarchive plugin.\n");
return cVFS_Not_Supported;
}
-TVFSResult VFSMakeSymLink(struct TVFSGlobs *globs, const char *NewFileName, const char *PointTo)
+TVFSResult VFSMakeSymLink (struct TVFSGlobs *globs, const char *NewFileName, const char *PointTo)
{
- printf("(WW) VFSMakeSymLink: Not supported in libarchive plugin.\n");
+ printf ("(WW) VFSMakeSymLink: Not supported in libarchive plugin.\n");
return cVFS_Not_Supported;
}
-TVFSResult VFSChmod(struct TVFSGlobs *globs, const char *FileName, const uint Mode)
+TVFSResult VFSChmod (struct TVFSGlobs *globs, const char *FileName, guint32 Mode)
{
- printf("(WW) VFSChmod: Not supported in libarchive plugin.\n");
+ printf ("(WW) VFSChmod: Not supported in libarchive plugin.\n");
return cVFS_Not_Supported;
}
-TVFSResult VFSChown(struct TVFSGlobs *globs, const char *FileName, const uint UID, const uint GID)
+TVFSResult VFSChown (struct TVFSGlobs *globs, const char *FileName, guint32 UID, guint32 GID)
{
- printf("(WW) VFSChown: Not supported in libarchive plugin.\n");
+ printf ("(WW) VFSChown: Not supported in libarchive plugin.\n");
return cVFS_Not_Supported;
}
-TVFSResult VFSChangeTimes(struct TVFSGlobs *globs, char *APath, long mtime, long atime)
+TVFSResult VFSChangeTimes (struct TVFSGlobs *globs, char *APath, guint32 mtime, guint32 atime)
{
- printf("(WW) VFSChangeTimes: Not supported in libarchive plugin.\n");
+ printf ("(WW) VFSChangeTimes: Not supported in libarchive plugin.\n");
return cVFS_Not_Supported;
}
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////
+/******************************************************************************************************/
+/************** **/
TVFSFileDes VFSOpenFile(struct TVFSGlobs *globs, const char *APath, int Mode, int *Error)
{
@@ -547,27 +585,30 @@ int VFSWriteFile(struct TVFSGlobs *globs, TVFSFileDes FileDescriptor, void *Buff
return 0;
}
-void VFSSetBlockSize(struct TVFSGlobs *globs, int Value)
+void
+VFSSetBlockSize (struct TVFSGlobs *globs, guint32 Value)
{
- globs->block_size = Value;
+ if (globs)
+ globs->block_size = Value;
}
-int VFSIsOnSameFS(struct TVFSGlobs *globs, const char *Path1, const char *Path2)
+gboolean
+VFSIsOnSameFS (struct TVFSGlobs *globs, const char *Path1, const char *Path2, gboolean FollowSymlinks)
{
- printf("(WW) VFSIsOnSameFS: Not supported in libarchive plugin.\n");
+ printf ("(WW) VFSIsOnSameFS: Not supported in libarchive plugin.\n");
return TRUE;
}
-int VFSTwoSameFiles(struct TVFSGlobs *globs, const char *Path1, const char *Path2)
+gboolean
+VFSTwoSameFiles (struct TVFSGlobs *globs, const char *Path1, const char *Path2, gboolean FollowSymlinks)
{
- printf("(WW) VFSTwoSameFiles: Not supported in libarchive, comparing by paths.\n");
- return compare_two_same_files(Path1, Path2);
+ printf ("(WW) VFSTwoSameFiles: Not supported in libarchive, comparing by paths.\n");
+ return compare_two_same_files (Path1, Path2);
}
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////
-
+/******************************************************************************************************/
+/************** **/
@@ -576,158 +617,154 @@ int VFSTwoSameFiles(struct TVFSGlobs *globs, const char *Path1, const char *Path
* Quote: "This implementation minimizes copying of data and is sparse-file aware."
**/
static TVFSResult
-my_archive_read_data_into_fd(struct TVFSGlobs *globs, struct archive *a, struct archive_entry *entry, const char *sDstName, size_t max_block, int Append)
-{
- int r;
- int fd;
- const void *buff;
- size_t size, bytes_to_write;
- ssize_t bytes_written, total_written;
- off_t offset;
- 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,
- 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);
-
- while ((r = archive_read_data_block(a, &buff, &size, &offset)) == ARCHIVE_OK) {
- const char *p = buff;
- if (offset > output_offset) {
- lseek(fd, offset - output_offset, SEEK_CUR);
- output_offset = offset;
- }
- while (size > 0) {
- if (cancel) break;
- bytes_to_write = size;
- if (bytes_to_write > max_block)
- bytes_to_write = max_block;
- bytes_written = write(fd, p, bytes_to_write);
- if (bytes_written < 0) {
- fprintf(stderr, "(EE) my_archive_read_data_into_fd: error occured while extracting data: %s\n", strerror(errno));
- return cVFS_Failed;
- }
- output_offset += bytes_written;
- total_written += bytes_written;
- p += bytes_written;
- size -= bytes_written;
-
- log(" (II) my_archive_read_data_into_fd: bytes_written = %zd, total_written = %zd\n", bytes_written, total_written);
- if (globs->callback_progress) {
- if (! globs->callback_progress(total_written, file_size, globs->callback_data)) {
- cancel = TRUE;
- break;
- }
-// usleep(100000);
- }
- }
- }
-
- if ((close(fd)) || ((r != ARCHIVE_OK) && (r != ARCHIVE_EOF))) {
- fprintf(stderr, "(EE) my_archive_read_data_into_fd: error closing extracted file: %s\n", strerror(errno));
- return cVFS_WriteErr;
- }
- if (cancel) {
- if (unlink(sDstName))
- fprintf(stderr, "(EE) my_archive_read_data_into_fd: error unlinking cancelled extraction: %s\n", strerror(errno));
- return cVFS_Cancelled;
- }
- printf("(II) my_archive_read_data_into_fd: done.\n");
- return cVFS_OK;
-}
-
-
-TVFSResult VFSCopyToLocal(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, int Append)
-{
- if ((sSrcName == NULL) || (sDstName == NULL) || (strlen(sSrcName) < 1) || (strlen(sDstName) < 1)) {
- printf("(EE) VFSCopyToLocal: The value of 'sSrcName' or 'sDstName' is NULL or empty\n");
+my_archive_read_data_into_fd (struct TVFSGlobs *globs, struct archive *a, struct archive_entry *entry, const char *sDstName, size_t max_block, gboolean Append)
+{
+ int r;
+ int fd;
+ const void *buff;
+ size_t size, bytes_to_write;
+ ssize_t bytes_written, total_written;
+ off_t offset;
+ off_t output_offset;
+ guint64 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,
+ 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;
}
- printf("(II) VFSCopyToLocal: copying file '%s' out to '%s'\n", sSrcName, sDstName);
-
- struct PathTree *node = filelist_tree_find_node_by_path(globs->files, sSrcName);
- if (! node) {
- fprintf(stderr, "(EE) VFSCopyToLocal: cannot find file '%s'\n", sSrcName);
- return cVFS_ReadErr;
+ total_written = 0;
+ output_offset = 0;
+ file_size = (guint64) archive_entry_size (entry);
+
+ while ((r = archive_read_data_block (a, &buff, &size, &offset)) == ARCHIVE_OK) {
+ const char *p = buff;
+ if (offset > output_offset) {
+ lseek (fd, offset - output_offset, SEEK_CUR);
+ output_offset = offset;
+ }
+ while (size > 0) {
+ if (cancel)
+ break;
+ bytes_to_write = size;
+ if (bytes_to_write > max_block)
+ bytes_to_write = max_block;
+ bytes_written = write (fd, p, bytes_to_write);
+ if (bytes_written < 0) {
+ fprintf (stderr, "(EE) my_archive_read_data_into_fd: error occured while extracting data: %s\n", strerror (errno));
+ return cVFS_Failed;
+ }
+ output_offset += bytes_written;
+ total_written += bytes_written;
+ p += bytes_written;
+ size -= bytes_written;
+
+ log (" (II) my_archive_read_data_into_fd: bytes_written = %zd, total_written = %zd\n", bytes_written, total_written);
+ if (globs->callback_progress)
+ if (! globs->callback_progress (total_written, file_size, globs->callback_data)) {
+ cancel = TRUE;
+ break;
+ }
+ }
}
- const char *src = node->original_pathstr;
- if (! src) {
- fprintf(stderr, "(WW) VFSCopyToLocal: cannot determine original filename\n");
- src = sSrcName;
+ if (close (fd) || (r != ARCHIVE_OK && r != ARCHIVE_EOF)) {
+ fprintf (stderr, "(EE) my_archive_read_data_into_fd: error closing extracted file: %s\n", strerror (errno));
+ return cVFS_WriteErr;
+ }
+ if (cancel) {
+ if (unlink (sDstName))
+ fprintf (stderr, "(EE) my_archive_read_data_into_fd: error unlinking cancelled extraction: %s\n", strerror (errno));
+ return cVFS_Cancelled;
}
- printf("(II) VFSCopyToLocal: new src path: '%s'\n", src);
+ printf ("(II) my_archive_read_data_into_fd: done.\n");
+ return cVFS_OK;
+}
+TVFSResult
+VFSCopyToLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, gboolean Append)
+{
+ struct PathTree *node;
+ const char *src;
TVFSResult Result;
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)
- {
- for (;;) {
- entry = NULL;
- r = archive_read_next_header(a, &entry);
- if (r == ARCHIVE_EOF) {
- break;
- } else
- if (r == ARCHIVE_WARN) {
- log("(WW) VFSOpen: file '%s' - libarchive warning: '%s'\n", archive_entry_pathname(entry), archive_error_string(a));
- } else
- if (r != ARCHIVE_OK) {
- fprintf(stderr, "(EE) VFSCopyToLocal: error occured while reading archive: '%s'\n", archive_error_string(a));
- Result = cVFS_Failed;
- break;
- }
-
-// printf ("found file: %s, mode = %x\n", archive_entry_pathname(entry), archive_entry_mode(entry));
- const char *ssrc = src;
- const char *asrc = archive_entry_pathname(entry);
- if (IS_DIR_SEP(*ssrc)) ssrc++;
- 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) VFSCopyToLocal: 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;
- }
- }
- archive_read_close(a);
+ gboolean found;
+
+ if (sSrcName == NULL || sDstName == NULL || strlen (sSrcName) < 1 || strlen (sDstName) < 1) {
+ printf ("(EE) VFSCopyToLocal: The value of 'sSrcName' or 'sDstName' is NULL or empty\n");
+ return cVFS_Failed;
+ }
+
+ printf ("(II) VFSCopyToLocal: copying file '%s' out to '%s'\n", sSrcName, sDstName);
+
+ node = filelist_tree_find_node_by_path (globs->files, sSrcName);
+ if (! node) {
+ fprintf (stderr, "(EE) VFSCopyToLocal: cannot find file '%s'\n", sSrcName);
+ return cVFS_ReadErr;
}
- archive_read_finish(a);
- if ((! found) && Result == cVFS_OK) {
- fprintf(stderr, "(EE) VFSCopyToLocal: file not found in archive.\n");
+ src = node->original_pathstr;
+ if (! src) {
+ fprintf (stderr, "(WW) VFSCopyToLocal: cannot determine original filename\n");
+ src = sSrcName;
+ }
+ printf ("(II) VFSCopyToLocal: new src path: '%s'\n", src);
+
+
+ found = FALSE;
+ Result = libarchive_open (&a, globs->archive_path, globs->block_size);
+ if (Result == cVFS_OK) {
+ for (;;) {
+ entry = NULL;
+ r = archive_read_next_header (a, &entry);
+ if (r == ARCHIVE_EOF) {
+ break;
+ } else
+ if (r == ARCHIVE_WARN) {
+ log("(WW) VFSOpen: file '%s' - libarchive warning: '%s'\n", archive_entry_pathname (entry), archive_error_string (a));
+ } else
+ if (r != ARCHIVE_OK) {
+ fprintf (stderr, "(EE) VFSCopyToLocal: error occured while reading archive: '%s'\n", archive_error_string (a));
+ Result = cVFS_Failed;
+ break;
+ }
+
+ if (g_strcmp0 (src, archive_entry_pathname (entry)) == 0) {
+ found = TRUE;
+ Result = my_archive_read_data_into_fd (globs, a, entry, sDstName, globs->block_size, Append);
+ break;
+ }
+ }
+ archive_read_close (a);
+ }
+ archive_read_finish (a);
+
+ if (! found && Result == cVFS_OK) {
+ fprintf (stderr, "(EE) VFSCopyToLocal: file not found in archive.\n");
Result = cVFS_ReadErr;
}
- fprintf(stderr, "(II) VFSCopyToLocal: finished. \n");
+ fprintf (stderr, "(II) VFSCopyToLocal: finished. \n");
return Result;
}
-TVFSResult VFSCopyFromLocal(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, int Append)
+
+TVFSResult
+VFSCopyFromLocal (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, gboolean Append)
{
- printf("(WW) VFSCopyFromLocal: Not supported in libarchive plugin.\n");
+ printf ("(WW) VFSCopyFromLocal: Not supported in libarchive plugin.\n");
return cVFS_Not_Supported;
}
@@ -737,7 +774,6 @@ TVFSResult VFSCopyFromLocal(struct TVFSGlobs *globs, const char *sSrcName, const
/**********
* 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/libarchive/treepath_vfs.c b/libarchive/treepath_vfs.c
deleted file mode 120000
index f4b41b3..0000000
--- a/libarchive/treepath_vfs.c
+++ /dev/null
@@ -1 +0,0 @@
-../common/treepath_vfs.c \ No newline at end of file
diff --git a/libarchive/treepath_vfs.h b/libarchive/treepath_vfs.h
deleted file mode 120000
index a1e19e7..0000000
--- a/libarchive/treepath_vfs.h
+++ /dev/null
@@ -1 +0,0 @@
-../common/treepath_vfs.h \ No newline at end of file
diff --git a/libarchive/treepathutils.c b/libarchive/treepathutils.c
deleted file mode 120000
index ae760bc..0000000
--- a/libarchive/treepathutils.c
+++ /dev/null
@@ -1 +0,0 @@
-../common/treepathutils.c \ No newline at end of file
diff --git a/libarchive/treepathutils.h b/libarchive/treepathutils.h
deleted file mode 120000
index 4e3c904..0000000
--- a/libarchive/treepathutils.h
+++ /dev/null
@@ -1 +0,0 @@
-../common/treepathutils.h \ No newline at end of file
diff --git a/libarchive/tuxcmd-vfs.h b/libarchive/tuxcmd-vfs.h
new file mode 120000
index 0000000..b7f193e
--- /dev/null
+++ b/libarchive/tuxcmd-vfs.h
@@ -0,0 +1 @@
+../common/tuxcmd-vfs.h \ No newline at end of file
diff --git a/libarchive/vfs_types.h b/libarchive/vfs_types.h
deleted file mode 120000
index c2235a2..0000000
--- a/libarchive/vfs_types.h
+++ /dev/null
@@ -1 +0,0 @@
-../common/vfs_types.h \ No newline at end of file