diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -1618,3 +1618,21 @@ cpio_create_dir (struct cpio_file_stat *file_hdr, int existing_dir) return 0; } +void +change_dir () +{ + if (change_directory_option && chdir (change_directory_option)) + { + if (errno == ENOENT && create_dir_flag) + { + if (make_path (change_directory_option, -1, -1, + (warn_option & CPIO_WARN_INTERDIR) ? + _("Creating directory `%s'") : NULL)) + exit (PAXEXIT_FAILURE); + if (chdir (change_directory_option) == 0) + return; + } + error (PAXEXIT_FAILURE, errno, + _("cannot change to directory `%s'"), change_directory_option); + } +} |