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 *,
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");
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));
}
/*
}
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;
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");
}
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;
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);
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();
}