X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fextract.c;h=2a3f9bf944bcc33ac0a6b4671cda76a38680b664;hb=fb1c65e512181db1c43c19c708a8e1c795cbd31c;hp=eac86ccedfa7c8e3ee6b15d84fd9d290c998f2a5;hpb=95dda72cc6231e3966fcaeaa16d6b55a45f602ed;p=chaz%2Ftar diff --git a/src/extract.c b/src/extract.c index eac86cc..2a3f9bf 100644 --- a/src/extract.c +++ b/src/extract.c @@ -454,6 +454,7 @@ maybe_recoverable (char *file_name, int *interdir_made) return 0; case DEFAULT_OLD_FILES: + case OVERWRITE_OLD_DIRS: case OVERWRITE_OLD_FILES: { int r = remove_any_file (file_name, 0); @@ -549,10 +550,11 @@ apply_nonancestor_delayed_set_stat (char const *file_name, bool after_symlinks) { struct delayed_set_stat *data = delayed_set_stat_head; bool skip_this_one = 0; - check_for_renamed_directories |= data->after_symlinks; struct stat st; struct stat const *current_stat_info = 0; + check_for_renamed_directories |= data->after_symlinks; + if (after_symlinks < data->after_symlinks || (data->file_name_len < file_name_len && file_name[data->file_name_len] @@ -971,15 +973,19 @@ extract_archive (void) && (base_name (CURRENT_FILE_NAME) == CURRENT_FILE_NAME + h->file_name_len + 1)) { - h->after_symlinks = 1; - - if (stat (h->file_name, &st) != 0) - stat_error (h->file_name); - else + do { - h->stat_info.st_dev = st.st_dev; - h->stat_info.st_ino = st.st_ino; + h->after_symlinks = 1; + + if (stat (h->file_name, &st) != 0) + stat_error (h->file_name); + else + { + h->stat_info.st_dev = st.st_dev; + h->stat_info.st_ino = st.st_ino; + } } + while ((h = h->next) && ! h->after_symlinks); } status = 0; @@ -1143,7 +1149,9 @@ extract_archive (void) if (status != 0) { if (errno == EEXIST - && (interdir_made || old_files_option == OVERWRITE_OLD_FILES)) + && (interdir_made + || old_files_option == OVERWRITE_OLD_DIRS + || old_files_option == OVERWRITE_OLD_FILES)) { struct stat st; if (stat (CURRENT_FILE_NAME, &st) == 0) @@ -1176,6 +1184,7 @@ extract_archive (void) directory_exists: if (status == 0 + || old_files_option == OVERWRITE_OLD_DIRS || old_files_option == OVERWRITE_OLD_FILES) delay_set_stat (CURRENT_FILE_NAME, ¤t_stat, MODE_RWX & (mode ^ current_stat.st_mode),