Quiet mode, sometimes error messages arent wanted
This commit is contained in:
parent
c127008840
commit
3e94f729a5
@ -237,7 +237,8 @@ enum extract_functions_e {
|
|||||||
extract_control_tar_gz = 128,
|
extract_control_tar_gz = 128,
|
||||||
extract_unzip_only = 256,
|
extract_unzip_only = 256,
|
||||||
extract_unconditional = 512,
|
extract_unconditional = 512,
|
||||||
extract_create_leading_dirs = 1024
|
extract_create_leading_dirs = 1024,
|
||||||
|
extract_quiet = 2048
|
||||||
};
|
};
|
||||||
char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *),
|
char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *),
|
||||||
const int extract_function, const char *prefix, char **extract_names);
|
const int extract_function, const char *prefix, char **extract_names);
|
||||||
|
@ -237,7 +237,8 @@ enum extract_functions_e {
|
|||||||
extract_control_tar_gz = 128,
|
extract_control_tar_gz = 128,
|
||||||
extract_unzip_only = 256,
|
extract_unzip_only = 256,
|
||||||
extract_unconditional = 512,
|
extract_unconditional = 512,
|
||||||
extract_create_leading_dirs = 1024
|
extract_create_leading_dirs = 1024,
|
||||||
|
extract_quiet = 2048
|
||||||
};
|
};
|
||||||
char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *),
|
char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *),
|
||||||
const int extract_function, const char *prefix, char **extract_names);
|
const int extract_function, const char *prefix, char **extract_names);
|
||||||
|
@ -116,15 +116,19 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
|
|||||||
unlink(full_name); /* Directories might not be empty etc */
|
unlink(full_name); /* Directories might not be empty etc */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error_msg("%s not created: newer or same age file exists", file_entry->name);
|
if ((function & extract_quiet) != extract_quiet) {
|
||||||
seek_sub_file(src_stream, file_entry->size);
|
error_msg("%s not created: newer or same age file exists", file_entry->name);
|
||||||
|
}
|
||||||
|
seek_sub_file(src_stream, file_entry->size);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (function & extract_create_leading_dirs) { /* Create leading directories with default umask */
|
if (function & extract_create_leading_dirs) { /* Create leading directories with default umask */
|
||||||
char *parent = dirname(full_name);
|
char *parent = dirname(full_name);
|
||||||
if (make_directory (parent, -1, FILEUTILS_RECUR) != 0) {
|
if (make_directory (parent, -1, FILEUTILS_RECUR) != 0) {
|
||||||
error_msg("couldn't create leading directories");
|
if ((function & extract_quiet) != extract_quiet) {
|
||||||
|
error_msg("couldn't create leading directories");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free (parent);
|
free (parent);
|
||||||
}
|
}
|
||||||
@ -132,8 +136,10 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
|
|||||||
case S_IFREG:
|
case S_IFREG:
|
||||||
if (file_entry->link_name) { /* Found a cpio hard link */
|
if (file_entry->link_name) { /* Found a cpio hard link */
|
||||||
if (link(file_entry->link_name, full_name) != 0) {
|
if (link(file_entry->link_name, full_name) != 0) {
|
||||||
perror_msg("Cannot link from %s to '%s'",
|
if ((function & extract_quiet) != extract_quiet) {
|
||||||
file_entry->name, file_entry->link_name);
|
perror_msg("Cannot link from %s to '%s'",
|
||||||
|
file_entry->name, file_entry->link_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((dst_stream = wfopen(full_name, "w")) == NULL) {
|
if ((dst_stream = wfopen(full_name, "w")) == NULL) {
|
||||||
@ -148,13 +154,17 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
|
|||||||
case S_IFDIR:
|
case S_IFDIR:
|
||||||
if (stat_res != 0) {
|
if (stat_res != 0) {
|
||||||
if (mkdir(full_name, file_entry->mode) < 0) {
|
if (mkdir(full_name, file_entry->mode) < 0) {
|
||||||
perror_msg("extract_archive: ");
|
if ((function & extract_quiet) != extract_quiet) {
|
||||||
|
perror_msg("extract_archive: ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case S_IFLNK:
|
case S_IFLNK:
|
||||||
if (symlink(file_entry->link_name, full_name) < 0) {
|
if (symlink(file_entry->link_name, full_name) < 0) {
|
||||||
perror_msg("Cannot create symlink from %s to '%s'", file_entry->name, file_entry->link_name);
|
if ((function & extract_quiet) != extract_quiet) {
|
||||||
|
perror_msg("Cannot create symlink from %s to '%s'", file_entry->name, file_entry->link_name);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -163,7 +173,9 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
|
|||||||
case S_IFCHR:
|
case S_IFCHR:
|
||||||
case S_IFIFO:
|
case S_IFIFO:
|
||||||
if (mknod(full_name, file_entry->mode, file_entry->device) == -1) {
|
if (mknod(full_name, file_entry->mode, file_entry->device) == -1) {
|
||||||
perror_msg("Cannot create node %s", file_entry->name);
|
if ((function & extract_quiet) != extract_quiet) {
|
||||||
|
perror_msg("Cannot create node %s", file_entry->name);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user