summaryrefslogtreecommitdiff
path: root/archival/libunarchive/data_extract_all.c
diff options
context:
space:
mode:
authorGlenn L McGrath2003-08-28 19:12:23 +0000
committerGlenn L McGrath2003-08-28 19:12:23 +0000
commit4cee66d5a8a49f6bd6342923aff94262812fba73 (patch)
tree8523978e8159ce2569e02557fa2b6ced3030b39b /archival/libunarchive/data_extract_all.c
parent444566837c4b98f364fa486f9f288b0775ed3ed6 (diff)
downloadbusybox-4cee66d5a8a49f6bd6342923aff94262812fba73.zip
busybox-4cee66d5a8a49f6bd6342923aff94262812fba73.tar.gz
Dont unlink when testing !
Always preserve creation date Disable the -p option its for modification date Remove some cpio header debugging noise Syncronise file listing behaviour with upstream.
Diffstat (limited to 'archival/libunarchive/data_extract_all.c')
-rw-r--r--archival/libunarchive/data_extract_all.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index c6ace2c..05bd2f0 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -39,6 +39,31 @@ extern void data_extract_all(archive_handle_t *archive_handle)
free(name);
}
+ /* Check if the file already exists */
+ if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
+ /* Remove the existing entry if it exists */
+ if ((unlink(file_header->name) == -1) && (errno != ENOENT)) {
+ bb_perror_msg_and_die("Couldnt remove old file");
+ }
+ }
+ else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
+ /* Remove the existing entry if its older than the extracted entry */
+ struct stat statbuf;
+ if ((lstat(file_header->name, &statbuf) == -1) && (errno != ENOENT)) {
+ bb_perror_msg_and_die("Couldnt stat old file");
+ }
+ if (statbuf.st_mtime <= file_header->mtime) {
+ if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
+ bb_error_msg("%s not created: newer or same age file exists", file_header->name);
+ }
+ data_skip(archive_handle);
+ return;
+ }
+ if ((unlink(file_header->name) == -1) && (errno != ENOENT)) {
+ bb_perror_msg_and_die("Couldnt remove old file");
+ }
+ }
+
/* Handle hard links seperately */
if (!S_ISLNK(file_header->mode) && (file_header->link_name) && (file_header->size == 0)) {
/* hard link */