- name_length = strlen (CURRENT_FILE_NAME);
-
- really_dir:
- /* Remove trailing "/" and "/.", unless that would result in the
- empty string. */
- for (;;)
- {
- if (1 < name_length && CURRENT_FILE_NAME[name_length - 1] == '/')
- CURRENT_FILE_NAME[--name_length] = '\0';
- else if (2 < name_length
- && CURRENT_FILE_NAME[name_length - 1] == '.'
- && CURRENT_FILE_NAME[name_length - 2] == '/')
- CURRENT_FILE_NAME[name_length -= 2] = '\0';
- else
- break;
- }
-
- if (incremental_option)
- {
- /* Read the entry and delete files that aren't listed in the
- archive. */
-
- gnu_restore (skipcrud);
- }
- else if (typeflag == GNUTYPE_DUMPDIR)
- skip_file (current_stat.st_size);
-
- if (! prepare_to_extract (CURRENT_FILE_NAME))
- break;
-
- mode = ((current_stat.st_mode
- | (we_are_root ? 0 : MODE_WXUSR))
- & MODE_RWX);
-
- again_dir:
- status = mkdir (CURRENT_FILE_NAME, mode);
- if (status != 0)
- {
- if (errno == EEXIST && interdir_made
- && contains_dot_dot (CURRENT_FILE_NAME))
- {
- int e = errno;
- struct stat st;
- if (stat (CURRENT_FILE_NAME, &st) == 0)
- {
- repair_delayed_set_stat (CURRENT_FILE_NAME, &st);
- break;
- }
- e = errno;
- }
-
- if (maybe_recoverable (CURRENT_FILE_NAME, &interdir_made))
- goto again_dir;
-
- if (errno != EEXIST || old_files_option == KEEP_OLD_FILES)
- {
- mkdir_error (CURRENT_FILE_NAME);
- if (backup_option)
- undo_last_backup ();
- break;
- }
- }
-
- if (status == 0
- || old_files_option == OVERWRITE_OLD_FILES)
- delay_set_stat (CURRENT_FILE_NAME, ¤t_stat,
- mode & ~ current_stat.st_mode,
- (status == 0
- ? ARCHIVED_PERMSTATUS
- : UNKNOWN_PERMSTATUS));