]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Remove both MBS and WCS interfaces of archive_matching_pathname_newer_mtime.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Tue, 24 Jan 2012 10:00:59 +0000 (05:00 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Tue, 24 Jan 2012 10:00:59 +0000 (05:00 -0500)
I think them will not be used since archive_matching_pathname_newer_mtime is used for
matching entries that are already in an archive file being updated.
And rename archive_matching_pathname_newer_mtime_ae to archive_matching_pathname_newer_mtime.

SVN-Revision: 4204

libarchive/archive.h
libarchive/archive_matching.c
libarchive/test/test_archive_matching_time.c
tar/write.c

index 56d677f0a164f32da5c3e3b0208abcdb0d29e89d..3fb1076fdfcd43b057b0acd05461f4634b1e6bf0 100644 (file)
@@ -900,12 +900,6 @@ __LA_DECL int      archive_matching_older_ctime_than_w(struct archive *,
                    const wchar_t *_pathname);
 /* Add inclusion file times with its filename. */
 __LA_DECL int  archive_matching_pathname_newer_mtime(
-                   struct archive *, const char *_pathname,
-                   time_t _sec, long _nsec);
-__LA_DECL int  archive_matching_pathname_newer_mtime_w(
-                   struct archive *, const wchar_t *_pathname,
-                   time_t _sec, long _nsec);
-__LA_DECL int  archive_matching_pathname_newer_mtime_ae(
                    struct archive *, struct archive_entry *);
 
 /*
index 65a671c9a6bd165096146483e8f3ef6682fb28e8..eab4c36b7de2facbb99f0d5d96e1cbec5ae1b525 100644 (file)
@@ -125,8 +125,8 @@ struct archive_matching {
        struct match_list        inclusion_gnames;
 };
 
-static int     add_newer_mtime_pathname(struct archive_matching *, int,
-                   const void *, time_t sec, long nsec);
+static int     add_newer_mtime_pathname(struct archive_matching *,
+                   struct archive_entry *);
 static int     add_owner_id(struct archive_matching *, struct id_array *,
                    int64_t);
 static int     add_owner_name(struct archive_matching *, struct match_list *,
@@ -938,47 +938,9 @@ archive_matching_older_ctime_than_w(struct archive *_a, const wchar_t *pathname)
 
 int
 archive_matching_pathname_newer_mtime(struct archive *_a,
-    const char *pathname, time_t sec, long nsec)
-{
-       struct archive_matching *a;
-
-       archive_check_magic(_a, ARCHIVE_MATCHING_MAGIC,
-           ARCHIVE_STATE_NEW, "archive_matching_add_newer_mtime_pathname");
-       a = (struct archive_matching *)_a;
-
-       if (pathname == NULL || *pathname == '\0') {
-               archive_set_error(&(a->archive), EINVAL, "pathname is empty");
-               return (ARCHIVE_FAILED);
-       }
-       a->newer_tree.rbt_ops = &rb_ops_mbs;
-       return (add_newer_mtime_pathname(a, 1, pathname, sec, nsec));
-}
-
-int
-archive_matching_pathname_newer_mtime_w(struct archive *_a,
-    const wchar_t *pathname, time_t sec, long nsec)
-{
-       struct archive_matching *a;
-
-       archive_check_magic(_a, ARCHIVE_MATCHING_MAGIC,
-           ARCHIVE_STATE_NEW, "archive_matching_add_newer_mtime_pathname_w");
-       a = (struct archive_matching *)_a;
-
-       if (pathname == NULL || *pathname == '\0') {
-               archive_set_error(&(a->archive), EINVAL, "pathname is empty");
-               return (ARCHIVE_FAILED);
-       }
-       a->newer_tree.rbt_ops = &rb_ops_wcs;
-       return (add_newer_mtime_pathname(a, 0, pathname, sec, nsec));
-}
-
-int
-archive_matching_pathname_newer_mtime_ae(struct archive *_a,
     struct archive_entry *entry)
 {
        struct archive_matching *a;
-       const void *pathname;
-       int mbs;
 
        archive_check_magic(_a, ARCHIVE_MATCHING_MAGIC,
            ARCHIVE_STATE_NEW, "archive_matching_add_newer_mtime_ae");
@@ -988,21 +950,7 @@ archive_matching_pathname_newer_mtime_ae(struct archive *_a,
                archive_set_error(&(a->archive), EINVAL, "entry is NULL");
                return (ARCHIVE_FAILED);
        }
-#if defined(_WIN32) && !defined(__CYGWIN__)
-       a->newer_tree.rbt_ops = &rb_ops_wcs;
-       pathname = archive_entry_pathname_w(entry);
-       mbs = 0;
-#else
-       a->newer_tree.rbt_ops = &rb_ops_mbs;
-       pathname = archive_entry_pathname(entry);
-       mbs = 1;
-#endif
-       if (pathname == NULL) {
-               archive_set_error(&(a->archive), EINVAL, "pathname is NULL");
-               return (ARCHIVE_FAILED);
-       }
-       return (add_newer_mtime_pathname(a, mbs, pathname,
-               archive_entry_mtime(entry), archive_entry_mtime_nsec(entry)));
+       return (add_newer_mtime_pathname(a, entry));
 }
 
 /*
@@ -1248,21 +1196,38 @@ newer_file_list_add(struct newer_file_list *list, struct newer_file *file)
 }
 
 static int
-add_newer_mtime_pathname(struct archive_matching *a, int mbs,
-    const void *pathname, time_t sec, long nsec)
+add_newer_mtime_pathname(struct archive_matching *a,
+    struct archive_entry *entry)
 {
        struct newer_file *f;
+       const void *pathname;
        int r;
 
        f = calloc(1, sizeof(*f));
        if (f == NULL)
                return (error_nomem(a));
-       if (mbs)
-               archive_mstring_copy_mbs(&(f->pathname), pathname);
-       else
-               archive_mstring_copy_wcs(&(f->pathname), pathname);
-       f->mtime_sec = sec;
-       f->mtime_nsec = nsec;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       pathname = archive_entry_pathname_w(entry);
+       if (pathname == NULL) {
+               free(f);
+               archive_set_error(&(a->archive), EINVAL, "pathname is NULL");
+               return (ARCHIVE_FAILED);
+       }
+       archive_mstring_copy_wcs(&(f->pathname), pathname);
+       a->newer_tree.rbt_ops = &rb_ops_wcs;
+#else
+       pathname = archive_entry_pathname(entry);
+       if (pathname == NULL) {
+               free(f);
+               archive_set_error(&(a->archive), EINVAL, "pathname is NULL");
+               return (ARCHIVE_FAILED);
+       }
+       archive_mstring_copy_mbs(&(f->pathname), pathname);
+       a->newer_tree.rbt_ops = &rb_ops_mbs;
+#endif
+       f->mtime_sec = archive_entry_mtime(entry);
+       f->mtime_nsec = archive_entry_mtime_nsec(entry);
        r = __archive_rb_tree_insert_node(&(a->newer_tree), &(f->node));
        if (!r) {
                struct newer_file *f2;
index 667a39fe96f4b7d0021ea7348c98b4f33c64d521..1f6724c4ae215e611ccb75a283c123d01adf6de1 100644 (file)
@@ -618,6 +618,10 @@ excluded(struct archive *m)
        assertEqualInt(1, archive_matching_time_excluded(m, ae));
        assertEqualInt(1, archive_matching_excluded(m, ae));
 
+       /*
+        * "file4" is not registered, that sort of a file should not be
+        * excluded with any mtime.
+        */
        archive_entry_copy_pathname(ae, "file4");
        archive_entry_set_mtime(ae, 7879, 999);
        failure("It should not be excluded");
@@ -638,49 +642,7 @@ excluded(struct archive *m)
 }
 
 static void
-test_newer_pathname_mbs(void)
-{
-       struct archive *m;
-
-       if (!assert((m = archive_matching_new()) != NULL))
-               return;
-
-       assertEqualIntA(m, 0,
-           archive_matching_pathname_newer_mtime(m, "file1", 7880, 0));
-       assertEqualIntA(m, 0,
-           archive_matching_pathname_newer_mtime(m, "file2", 1, 0));
-       assertEqualIntA(m, 0,
-           archive_matching_pathname_newer_mtime(m, "file3", 99999, 0));
-
-       excluded(m);
-
-       /* Clean up. */
-       archive_matching_free(m);
-}
-
-static void
-test_newer_pathname_wcs(void)
-{
-       struct archive *m;
-
-       if (!assert((m = archive_matching_new()) != NULL))
-               return;
-
-       assertEqualIntA(m, 0,
-           archive_matching_pathname_newer_mtime_w(m, L"file1", 7880, 0));
-       assertEqualIntA(m, 0,
-           archive_matching_pathname_newer_mtime_w(m, L"file2", 1, 0));
-       assertEqualIntA(m, 0,
-           archive_matching_pathname_newer_mtime_w(m, L"file3", 99999, 0));
-
-       excluded(m);
-
-       /* Clean up. */
-       archive_matching_free(m);
-}
-
-static void
-test_newer_archive_entry(void)
+test_pathname_newer_mtime(void)
 {
        struct archive_entry *ae;
        struct archive *m;
@@ -694,13 +656,13 @@ test_newer_archive_entry(void)
 
        archive_entry_copy_pathname(ae, "file1");
        archive_entry_set_mtime(ae, 7880, 0);
-       assertEqualIntA(m, 0, archive_matching_pathname_newer_mtime_ae(m, ae));
+       assertEqualIntA(m, 0, archive_matching_pathname_newer_mtime(m, ae));
        archive_entry_copy_pathname(ae, "file2");
        archive_entry_set_mtime(ae, 1, 0);
-       assertEqualIntA(m, 0, archive_matching_pathname_newer_mtime_ae(m, ae));
+       assertEqualIntA(m, 0, archive_matching_pathname_newer_mtime(m, ae));
        archive_entry_copy_pathname(ae, "file3");
        archive_entry_set_mtime(ae, 99999, 0);
-       assertEqualIntA(m, 0, archive_matching_pathname_newer_mtime_ae(m, ae));
+       assertEqualIntA(m, 0, archive_matching_pathname_newer_mtime(m, ae));
 
        excluded(m);
 
@@ -717,7 +679,5 @@ DEFINE_TEST(test_archive_matching_time)
        test_older_time();
        test_older_than_file_mbs();
        test_older_than_file_wcs();
-       test_newer_pathname_mbs();
-       test_newer_pathname_wcs();
-       test_newer_archive_entry();
+       test_pathname_newer_mtime();
 }
index d6ba06a24da0d01eebdfadf7c738da1b41274b68..b177e7eca7d59da31bced8fcb769fc59e2d6a361 100644 (file)
@@ -342,7 +342,7 @@ tar_mode_u(struct bsdtar *bsdtar)
                        lafe_errc(1, 0,
                            "Cannot append to compressed archive.");
                }
-               if (archive_matching_pathname_newer_mtime_ae(bsdtar->matching,
+               if (archive_matching_pathname_newer_mtime(bsdtar->matching,
                    entry) != ARCHIVE_OK)
                        lafe_errc(1, 0, "Error : %s",
                            archive_error_string(bsdtar->matching));