From: Michihiro NAKAJIMA Date: Tue, 24 Jan 2012 10:00:59 +0000 (-0500) Subject: Remove both MBS and WCS interfaces of archive_matching_pathname_newer_mtime. X-Git-Tag: v3.0.4~2^2~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7810b9419c9ec96a0f4a3d329ec4f4ecfb85a129;p=thirdparty%2Flibarchive.git Remove both MBS and WCS interfaces of archive_matching_pathname_newer_mtime. 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 --- diff --git a/libarchive/archive.h b/libarchive/archive.h index 56d677f0a..3fb1076fd 100644 --- a/libarchive/archive.h +++ b/libarchive/archive.h @@ -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 *); /* diff --git a/libarchive/archive_matching.c b/libarchive/archive_matching.c index 65a671c9a..eab4c36b7 100644 --- a/libarchive/archive_matching.c +++ b/libarchive/archive_matching.c @@ -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; diff --git a/libarchive/test/test_archive_matching_time.c b/libarchive/test/test_archive_matching_time.c index 667a39fe9..1f6724c4a 100644 --- a/libarchive/test/test_archive_matching_time.c +++ b/libarchive/test/test_archive_matching_time.c @@ -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(); } diff --git a/tar/write.c b/tar/write.c index d6ba06a24..b177e7eca 100644 --- a/tar/write.c +++ b/tar/write.c @@ -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));