summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2008-03-12 16:34:01 +0000
committerAlexander Larsson <alexl@src.gnome.org>2008-03-12 16:34:01 +0000
commitfd54a5bf754c1895a238a93be7bc4b03ac1de11c (patch)
tree116e4aca007065a257678242dd0226902b144a40
parent24672e3dd455c3ad8c603fb935408add1578a8d1 (diff)
downloadgvfs-fd54a5bf754c1895a238a93be7bc4b03ac1de11c.tar.gz
Added archive backend from Benjamin Otte Requires libarchive
2008-03-12 Alexander Larsson <alexl@redhat.com> * configure.ac: * daemon/Makefile.am: * daemon/gvfsbackendarchive.[ch]: Added archive backend from Benjamin Otte Requires libarchive svn path=/trunk/; revision=1649
-rw-r--r--ChangeLog8
-rw-r--r--configure.ac63
-rw-r--r--daemon/gvfsbackendarchive.c44
-rw-r--r--po/ChangeLog5
-rw-r--r--po/POTFILES.in1
5 files changed, 108 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 87f00893..3117cb2b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-03-12 Alexander Larsson <alexl@redhat.com>
+
+ * configure.ac:
+ * daemon/Makefile.am:
+ * daemon/gvfsbackendarchive.[ch]:
+ Added archive backend from Benjamin Otte
+ Requires libarchive
+
2008-03-12 Benjamin Otte <otte@gnome.org>
* daemon/gvfsbackendftp.c:
diff --git a/configure.ac b/configure.ac
index e7bf3beb..0fecdc02 100644
--- a/configure.ac
+++ b/configure.ac
@@ -401,7 +401,69 @@ fi
AM_CONDITIONAL(HAVE_SAMBA, test "$msg_samba" = "yes")
AC_SUBST(SAMBA_CFLAGS)
AC_SUBST(SAMBA_LIBS)
+
+dnl ==========================================================================
+
+dnl ****************************
+dnl *** Check for libarchive ***
+dnl ****************************
+
+AC_ARG_ENABLE(archive, [ --disable-archive build without archive support])
+msg_archive="no"
+if test "x$enable_archive" != "xno"; then
+ AC_ARG_WITH(archive-includes, [ --with-archive-includes=PREFIX Location of archive includes.],
+ with_archive_includes="$withval", with_archive_includes="/usr/include")
+ have_archive_includes="no"
+ if test "x${with_archive_includes}" != "xno"; then
+ CPPFLAGS_save="$CPPFLAGS"
+
+ CPPFLAGS="$CPPFLAGS -I$with_archive_includes"
+ AC_CHECK_HEADER(archive.h, [ archive_includes="yes" ])
+ CPPFLAGS="$CPPFLAGS_save"
+ if test "x{archive_includes}" != "xno" -a "x${archive_includes}" != "x"; then
+ have_archive_includes="yes"
+ if test "${with_archive_includes}" != "/usr/include" ; then
+ ARCHIVE_CFLAGS="-I$with_archive_includes"
+ else
+ ARCHIVE_CFLAGS=""
+ fi
+ else
+ ARCHIVE_CFLAGS=""
+ fi
+ fi
+ AC_ARG_WITH(archive-libs, [ --with-archive-libs=PREFIX Location of Archive libs.],
+ with_archive_libs="$withval", with_archive_libs="/usr/lib")
+ if test "x${with_archive_libs}" != "xno" -a "x${have_archive_includes}" != "xno"; then
+ LDFLAGS_save="$LDFLAGS"
+
+ LDFLAGS="$LDFLAGS -L$with_archive_libs"
+ AC_CHECK_LIB(archive, archive_read_open, archive_libs="yes", archive_libs="no")
+ LDFLAGS="$LDFLAGS_save"
+ if test "x${archive_libs}" != "xno"; then
+ AC_DEFINE(HAVE_ARCHIVE,, [Define to 1 if you have the libarchive library])
+ msg_archive="yes"
+ if test x$with_archive_libs != x/usr/lib; then
+ ARCHIVE_LIBS="-L$with_archive_libs -larchive"
+ else
+ ARCHIVE_LIBS="-larchive"
+ fi
+ else
+ AC_CHECK_LIB(archive, archive_read_open, archive_old_libs="yes", archive_old_libs="no")
+ if test "x${archive_old_libs}" != "xno"; then
+ msg_archive="Too old, need at least archive 3.0.22"
+ fi
+ ARCHIVE_CFLAGS=""
+ ARCHIVE_LIBS=""
+ fi
+ fi
+ AC_MSG_CHECKING(for Archive 3.libraries)
+ AC_MSG_RESULT($msg_archive)
+fi
+AM_CONDITIONAL(HAVE_ARCHIVE, test "$msg_archive" = "yes")
+AC_SUBST(ARCHIVE_CFLAGS)
+AC_SUBST(ARCHIVE_LIBS)
+
dnl ==========================================================================
dnl Globally define_GNU_SOURCE and therefore enable the GNU extensions
@@ -478,6 +540,7 @@ echo "
FUSE support: $msg_fuse
CDDA support: $msg_cdda
Gphoto2 support: $msg_gphoto2
+ archive support: $msg_archive
GConf support: $msg_gconf
DNS-SD support: $msg_avahi
Use HAL for volume monitor: $msg_hal (with fast init path: $have_hal_fast_init)
diff --git a/daemon/gvfsbackendarchive.c b/daemon/gvfsbackendarchive.c
index f89928ee..e7e03c11 100644
--- a/daemon/gvfsbackendarchive.c
+++ b/daemon/gvfsbackendarchive.c
@@ -25,6 +25,7 @@
#include <config.h>
#include <glib/gi18n.h>
+#include <string.h>
#include <archive.h>
#include <archive_entry.h>
@@ -472,14 +473,16 @@ do_mount (GVfsBackend *backend,
gboolean is_automount)
{
GVfsBackendArchive *archive = G_VFS_BACKEND_ARCHIVE (backend);
- const char *host;
+ const char *host, *file;
GFileInfo *info;
GIcon *icon;
char *filename, *s;
GError *error = NULL;
host = g_mount_spec_get (mount_spec, "host");
- if (host == NULL)
+ file = g_mount_spec_get (mount_spec, "file");
+ if (host == NULL &&
+ file == NULL)
{
g_vfs_job_failed (G_VFS_JOB (job),
G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
@@ -487,20 +490,25 @@ do_mount (GVfsBackend *backend,
return;
}
- filename = g_uri_unescape_string (host, NULL);
- if (filename == NULL)
+ if (host != NULL)
{
- g_vfs_job_failed (G_VFS_JOB (job),
- G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Invalid mount spec"));
- return;
+ filename = g_uri_unescape_string (host, NULL);
+ if (filename == NULL)
+ {
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ _("Invalid mount spec"));
+ return;
+ }
+
+ archive->file = g_file_new_for_uri (filename);
+ g_free (filename);
}
- DEBUG ("Trying to mount %s\n", filename);
-
- archive->file = g_file_new_for_uri (filename);
- g_free (filename);
+ else
+ archive->file = g_file_new_for_uri (file);
+
+ DEBUG ("Trying to mount %s\n", g_file_get_uri (archive->file));
- /* FIXME: check if this file is an archive */
info = g_file_query_info (archive->file,
"*",
G_FILE_QUERY_INFO_NONE,
@@ -514,6 +522,16 @@ do_mount (GVfsBackend *backend,
return;
}
+ if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
+ {
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ _("Invalid mount spec"));
+ return;
+ }
+
+ /* FIXME: check if this file is an archive */
+
filename = g_file_get_uri (archive->file);
DEBUG ("mounted %s\n", filename);
s = g_uri_escape_string (filename, NULL, FALSE);
diff --git a/po/ChangeLog b/po/ChangeLog
index dd754fb1..3916771f 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,8 @@
+2008-03-12 Alexander Larsson <alexl@redhat.com>
+
+ * POTFILES.in:
+ Added gvfsbackenddaemon.c
+
2008-03-10 Stéphane Raimbault <stephane.raimbault@gmail.com>
* fr.po: Updated French translation.
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e9d2fc61..0b804b9b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,6 +11,7 @@ common/gsysutils.c
common/gvfsdaemonprotocol.c
daemon/daemon-main.c
daemon/gvfsbackend.c
+daemon/gvfsbackendarchive.c
daemon/gvfsbackendburn.c
daemon/gvfsbackendcdda.c
daemon/gvfsbackendcomputer.c