Finish 439a5cffca5bcdefc6d4d552af64aa2e10c5ab5d
[claws.git] / src / plugins / archive / libarchive_archive.c
index e4d7cb3816faf974f92295c4cdfbab6d10c5afac..8266c002caa90f36e2a2d73f7c5ae5153e3a67c6 100644 (file)
@@ -33,7 +33,7 @@
 #      include "archiver.h"
 #      include "utils.h"
 #      include "mainwindow.h"
-#       include "folder.h"
+#   include "folder.h"
 #endif
 
 #include <sys/types.h>
@@ -198,9 +198,6 @@ gboolean before_date(time_t msg_mtime, const gchar* before) {
     GDate*      date;
     GDate*      file_t;
     gboolean    res;
-#if !GLIB_CHECK_VERSION(2,10,0)
-    GTime       gtime;
-#endif
 
     debug_print("Cut-off date: %s\n", before);
     if ((date = iso2GDate(before)) == NULL) {
@@ -209,12 +206,7 @@ gboolean before_date(time_t msg_mtime, const gchar* before) {
     }
 
     file_t = g_date_new();
-#if GLIB_CHECK_VERSION(2,10,0)
     g_date_set_time_t(file_t, msg_mtime);
-#else
-    gtime = (GTime) msg_mtime;
-    g_date_set_time(file_t, gtime);
-#endif
 
     if (debug_get_mode()) {
         pos = g_new0(char, 100);
@@ -397,7 +389,11 @@ const gchar* archive_extract(const char* archive_name, int flags) {
        in = archive_read_new();
        if ((res = archive_read_support_format_tar(in)) == ARCHIVE_OK) {
                if ((res = archive_read_support_compression_gzip(in)) == ARCHIVE_OK) {
+#if ARCHIVE_VERSION_NUMBER < 3000000
                        if ((res = archive_read_open_file(
+#else
+                       if ((res = archive_read_open_filename(
+#endif
                                in, archive_name, READ_BLOCK_SIZE)) != ARCHIVE_OK) {
                                buf = g_strdup_printf(
                                                "%s: %s\n", archive_name, archive_error_string(in));
@@ -452,7 +448,11 @@ const gchar* archive_extract(const char* archive_name, int flags) {
                                        result = archive_error_string(out);
                                archive_read_close(in);
                        }
+#if ARCHIVE_VERSION_NUMBER < 3000000
                        archive_read_finish(in);
+#else
+                       archive_read_free(in);
+#endif
                }
                else
                        result = archive_error_string(in);
@@ -486,21 +486,35 @@ const gchar* archive_create(const char* archive_name, GSList* files,
        arch = archive_write_new();
        switch (method) {
                case ZIP:
+#if ARCHIVE_VERSION_NUMBER < 3000000
                        if (archive_write_set_compression_gzip(arch) != ARCHIVE_OK)
+#else
+                       if (archive_write_add_filter_gzip(arch) != ARCHIVE_OK)
+#endif
                                return archive_error_string(arch);
                        break;
                case BZIP2:
+#if ARCHIVE_VERSION_NUMBER < 3000000
                        if (archive_write_set_compression_bzip2(arch) != ARCHIVE_OK)
+#else
+                       if (archive_write_add_filter_bzip2(arch) != ARCHIVE_OK)
+#endif
                                return archive_error_string(arch);
                        break;
-#if NEW_ARCHIVE_API
                case COMPRESS:
+#if ARCHIVE_VERSION_NUMBER < 3000000
                        if (archive_write_set_compression_compress(arch) != ARCHIVE_OK)
+#else
+                       if (archive_write_add_filter_compress(arch) != ARCHIVE_OK)
+#endif
                                return archive_error_string(arch);
                        break;
-#endif
                case NO_COMPRESS:
+#if ARCHIVE_VERSION_NUMBER < 3000000
                        if (archive_write_set_compression_none(arch) != ARCHIVE_OK)
+#else
+                       if (archive_write_add_filter_none(arch) != ARCHIVE_OK)
+#endif
                                return archive_error_string(arch);
                        break;
        }
@@ -524,7 +538,11 @@ const gchar* archive_create(const char* archive_name, GSList* files,
                case NO_FORMAT:
                        return "Missing archive format";
        }
+#if ARCHIVE_VERSION_NUMBER < 3000000
        if (archive_write_open_file(arch, archive_name) != ARCHIVE_OK)
+#else
+       if (archive_write_open_filename(arch, archive_name) != ARCHIVE_OK)
+#endif
                return archive_error_string(arch);
 
        while (files && ! stop_action) {
@@ -600,13 +618,17 @@ const gchar* archive_create(const char* archive_name, GSList* files,
        stop_action = FALSE;
 #endif
        archive_write_close(arch);
+#if ARCHIVE_VERSION_NUMBER < 3000000
        archive_write_finish(arch);
+#else
+       archive_write_free(arch);
+#endif
        return NULL;
 }
 
 #ifdef _TEST
 void archive_scan_folder(const char* dir) {
-       struct stat st;
+       GStatBuf st;
        DIR* root;
        struct dirent* ent;
        gchar cwd[PATH_MAX];