Use xstat() instead of if(stat()) die()
This commit is contained in:
parent
fd8409f8c5
commit
c4b673994e
@ -50,10 +50,7 @@ int bunzip2_main(int argc, char **argv)
|
|||||||
if (strcmp(extension, ".bz2") != 0) {
|
if (strcmp(extension, ".bz2") != 0) {
|
||||||
bb_error_msg_and_die("Invalid extension");
|
bb_error_msg_and_die("Invalid extension");
|
||||||
}
|
}
|
||||||
/* TODO: xstat */
|
xstat(filename, &stat_buf);
|
||||||
if (stat(filename, &stat_buf) < 0) {
|
|
||||||
bb_error_msg_and_die("Couldn't stat file %s", filename);
|
|
||||||
}
|
|
||||||
*extension=0;
|
*extension=0;
|
||||||
dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
|
dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
|
||||||
} else dst_fd = STDOUT_FILENO;
|
} else dst_fd = STDOUT_FILENO;
|
||||||
|
@ -61,11 +61,9 @@ int uncompress_main(int argc, char **argv)
|
|||||||
*extension = '\0';
|
*extension = '\0';
|
||||||
|
|
||||||
/* Open output file */
|
/* Open output file */
|
||||||
dst_fd = bb_xopen(uncompressed_file, O_WRONLY | O_CREAT);
|
xstat(compressed_file, &stat_buf);
|
||||||
|
dst_fd = bb_xopen3(uncompressed_file, O_WRONLY | O_CREAT,
|
||||||
/* Set permissions on the file */
|
stat_buf.st_mode);
|
||||||
stat(compressed_file, &stat_buf);
|
|
||||||
chmod(uncompressed_file, stat_buf.st_mode);
|
|
||||||
|
|
||||||
/* If unzip succeeds remove the old file */
|
/* If unzip succeeds remove the old file */
|
||||||
delete_path = compressed_file;
|
delete_path = compressed_file;
|
||||||
|
@ -47,10 +47,7 @@ int unlzma_main(int argc, char **argv)
|
|||||||
if (strcmp(extension, ".lzma") != 0) {
|
if (strcmp(extension, ".lzma") != 0) {
|
||||||
bb_error_msg_and_die("Invalid extension");
|
bb_error_msg_and_die("Invalid extension");
|
||||||
}
|
}
|
||||||
/* TODO: xstat? */
|
xstat(filename, &stat_buf);
|
||||||
if (stat(filename, &stat_buf) < 0) {
|
|
||||||
bb_error_msg_and_die("Couldn't stat file %s", filename);
|
|
||||||
}
|
|
||||||
*extension = 0;
|
*extension = 0;
|
||||||
dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
|
dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
|
||||||
} else
|
} else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user