/* Request that the access time of the entry visited by travesal be restored. */
__LA_DECL int archive_read_disk_set_atime_restored(struct archive *);
__LA_DECL int archive_read_disk_honor_nodump(struct archive *);
+__LA_DECL int archive_read_disk_disable_mac_copyfile(struct archive *);
__LA_DECL int archive_read_disk_set_name_filter_callback(struct archive *,
int (*_name_filter_func)(struct archive *, void *,
/*-
* Copyright (c) 2003-2009 Tim Kientzle
- * Copyright (c) 2010,2011 Michihiro NAKAJIMA
+ * Copyright (c) 2010-2012 Michihiro NAKAJIMA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
{
struct archive_read_disk *a;
- a = (struct archive_read_disk *)malloc(sizeof(*a));
+ a = (struct archive_read_disk *)calloc(1, sizeof(*a));
if (a == NULL)
return (NULL);
- memset(a, 0, sizeof(*a));
a->archive.magic = ARCHIVE_READ_DISK_MAGIC;
a->archive.state = ARCHIVE_STATE_NEW;
a->archive.vtable = archive_read_disk_vtable();
a->lookup_uname = trivial_lookup_uname;
a->lookup_gname = trivial_lookup_gname;
+ a->enable_copyfile = 1;
a->entry_wd_fd = -1;
return (&a->archive);
}
return (ARCHIVE_OK);
}
+int
+archive_read_disk_disable_mac_copyfile(struct archive *_a)
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+ archive_check_magic(_a, ARCHIVE_READ_DISK_MAGIC,
+ ARCHIVE_STATE_ANY, "archive_read_disk_disable_mac_copyfile");
+ a->enable_copyfile = 0;
+ return (ARCHIVE_OK);
+}
+
/*
* Trivial implementations of gname/uname lookup functions.
* These are normally overridden by the client, but these stub
}
} while (lst == NULL);
+#ifdef __APPLE__
+ if (a->enable_copyfile) {
+ /* If we're using copyfile(), ignore "._XXX" files. */
+ const char *bname = strrchr(tree_current_path(t), '/');
+ if (bname == NULL)
+ bname = tree_current_path(t);
+ else
+ ++bname;
+ if (bname[0] == '.' && bname[1] == '_')
+ goto next_entry;
+ }
+#endif
archive_entry_copy_pathname(entry, tree_current_path(t));
if (a->name_filter_func) {
if (!a->name_filter_func(_a, a->name_filter_data, entry))
}
}
#endif
+#ifdef __APPLE__
+ if (!a->enable_copyfile) {
+ /* If we aren't using copyfile, drop the copyfile() data. */
+ archive_entry_copy_mac_metadata(entry, NULL, 0);
+ }
+#endif
/* Return to the initial directory. */
tree_enter_initial_dir(t);
return (ARCHIVE_OK);
}
+int
+archive_read_disk_disable_mac_copyfile(struct archive *_a)
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+ archive_check_magic(_a, ARCHIVE_READ_DISK_MAGIC,
+ ARCHIVE_STATE_ANY, "archive_read_disk_disable_mac_copyfile");
+ a->enable_copyfile = 0;
+ return (ARCHIVE_OK);
+}
+
/*
* Trivial implementations of gname/uname lookup functions.
* These are normally overridden by the client, but these stub
/* Skip a file if it has nodump flag. */
if (bsdtar->option_honor_nodump)
archive_read_disk_honor_nodump(bsdtar->diskreader);
+ if (!bsdtar->enable_copyfile)
+ archive_read_disk_disable_mac_copyfile(bsdtar->diskreader);
archive_read_disk_set_standard_lookup(bsdtar->diskreader);
if (bsdtar->names_from_file != NULL)
*/
if (lafe_excluded(bsdtar->matching, archive_entry_pathname(entry)))
return (0);
-
-#ifdef __APPLE__
- if (bsdtar->enable_copyfile) {
- /* If we're using copyfile(), ignore "._XXX" files. */
- const char *bname = strrchr(
- archive_entry_pathname(entry), '/');
- if (bname == NULL)
- bname = name;
- else
- ++bname;
- if (bname[0] == '.' && bname[1] == '_')
- return (0);
- }
-#endif
return (1);
}
if (bsdtar->gname)
archive_entry_set_gname(entry, bsdtar->gname);
-#ifdef __APPLE__
- if (!bsdtar->enable_copyfile) {
- /* If we aren't using copyfile, drop the copyfile()
- * data. */
- archive_entry_copy_mac_metadata(entry, NULL, 0);
- }
-#endif
-
/*
* Rewrite the pathname to be archived. If rewrite
* fails, skip the entry.