Fix libarchive problems
authorColin Clark <colin.clark@cclark.uk>
Fri, 17 Sep 2021 15:37:10 +0000 (16:37 +0100)
committerColin Clark <colin.clark@cclark.uk>
Fri, 17 Sep 2021 15:37:10 +0000 (16:37 +0100)
libarchive 3.4.0 is required for Ubuntu 20.04 LTS.

Include ifdefs for when the library is not included.

configure.ac
src/layout_util.c
src/misc.c

index c4c1bcd..41b1f9b 100644 (file)
@@ -668,7 +668,7 @@ AC_ARG_ENABLE([archive],
     [libarchive=$enableval], [libarchive=auto])
 
 if test "x${libarchive}" != "xno"; then
-  PKG_CHECK_MODULES(ARCHIVE, libarchive >= 3.4.3,
+  PKG_CHECK_MODULES(ARCHIVE, libarchive >= 3.4.0,
     [
       HAVE_ARCHIVE=yes
       AC_DEFINE(HAVE_ARCHIVE, 1, [define to enable archive support])
index 9ed0e3b..d23c8ec 100644 (file)
@@ -903,9 +903,16 @@ static void layout_menu_open_archive_cb(GtkAction *action, gpointer data)
        if (fd->format_class == FORMAT_CLASS_ARCHIVE)
                {
                dest_dir = open_archive(layout_image_get_fd(lw));
-               lw_new = layout_new_from_default();
-               layout_set_path(lw_new, dest_dir);
-               g_free(dest_dir);
+               if (dest_dir)
+                       {
+                       lw_new = layout_new_from_default();
+                       layout_set_path(lw_new, dest_dir);
+                       g_free(dest_dir);
+                       }
+               else
+                       {
+                       warning_dialog(_("Cannot open archive file"), _("See the Log Window"), GTK_STOCK_DIALOG_WARNING, NULL);
+                       }
                }
 }
 
index 50a0a6b..418f26b 100644 (file)
@@ -22,8 +22,6 @@
 #include "misc.h"
 #include "ui_fileops.h"
 
-#include <archive.h>
-#include <archive_entry.h>
 #include <langinfo.h>
 #include <locale.h>
 
@@ -412,6 +410,17 @@ void tree_path_free_wrapper(void *data, void *useradata)
 
 /* Copied from the libarchive .repo. examples */
 
+#ifndef HAVE_ARCHIVE
+gchar *open_archive(FileData *fd)
+{
+       return NULL;
+}
+
+#else
+
+#include <archive.h>
+#include <archive_entry.h>
+
 static void errmsg(const char *);
 static gboolean extract(const char *filename, int do_extract, int flags);
 static int copy_data(struct archive *, struct archive *);
@@ -526,8 +535,7 @@ static gboolean extract(const char *filename, int do_extract, int flags)
        return(TRUE);
 }
 
-static int
-copy_data(struct archive *ar, struct archive *aw)
+static int copy_data(struct archive *ar, struct archive *aw)
 {
        int r;
        const void *buff;
@@ -566,5 +574,5 @@ static void errmsg(const char *m)
                }
        log_printf("%s \n", m);
 }
-
+#endif
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */