]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Set proper the default compression type as appropriate according to the compressions...
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 19 Dec 2011 19:28:33 +0000 (14:28 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 19 Dec 2011 19:28:33 +0000 (14:28 -0500)
SVN-Revision: 3947

libarchive/archive_write_set_format_7zip.c
libarchive/test/test_write_format_7zip.c

index 9b714776ea605be6919bf442e47fc1de4ad1d147..a4b05cf5b1f804e79f82fecfb27d143fd1d455a3 100644 (file)
@@ -300,8 +300,16 @@ archive_write_set_format_7zip(struct archive *_a)
        file_init_register(zip);
        file_init_register_empty(zip);
 
-       /* Set default compression type and level. */
+       /* Set default compression type and its level. */
+#if HAVE_LZMA_H
        zip->opt_compression = _7Z_LZMA1;
+#elif defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR)
+       zip->opt_compression = _7Z_BZIP2;
+#elif defined(HAVE_ZLIB_H)
+       zip->opt_compression = _7Z_DEFLATE;
+#else
+       zip->opt_compression = _7Z_COPY;
+#endif
        zip->opt_compression_level = 6;
 
        a->format_data = zip;
index 57a22e6b6a4113b364faaf2bc5d5a190ceb0714a..28043af5d66fa418ddec3acc1a60c9a98dccd39d 100644 (file)
@@ -42,7 +42,8 @@ test_basic(const char *compression_type)
        /* Create a new archive in memory. */
        assert((a = archive_write_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_7zip(a));
-       if (ARCHIVE_OK != archive_write_set_format_option(a, "7zip",
+       if (compression_type != NULL &&
+           ARCHIVE_OK != archive_write_set_format_option(a, "7zip",
            "compression", compression_type)) {
                skipping("%s writing not fully supported on this platform",
                   compression_type);
@@ -583,6 +584,9 @@ test_only_empty_files(void)
 
 DEFINE_TEST(test_write_format_7zip)
 {
+       /* Test that making a 7-Zip archive file by default compression
+        * in whatever compressions are supported on the running platform. */
+       test_basic(NULL);
        /* Test that making a 7-Zip archive file without compression. */
        test_basic("copy");
        /* Test that making a 7-Zip archive file with deflate compression. */