if (strcmp(extension, ".bz2") != 0) {
bb_error_msg_and_die("Invalid extension");
}
- /* TODO: xstat */
- if (stat(filename, &stat_buf) < 0) {
- bb_error_msg_and_die("Couldn't stat file %s", filename);
- }
+ xstat(filename, &stat_buf);
*extension=0;
dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
} else dst_fd = STDOUT_FILENO;
*extension = '\0';
/* Open output file */
- dst_fd = bb_xopen(uncompressed_file, O_WRONLY | O_CREAT);
-
- /* Set permissions on the file */
- stat(compressed_file, &stat_buf);
- chmod(uncompressed_file, stat_buf.st_mode);
+ xstat(compressed_file, &stat_buf);
+ dst_fd = bb_xopen3(uncompressed_file, O_WRONLY | O_CREAT,
+ stat_buf.st_mode);
/* If unzip succeeds remove the old file */
delete_path = compressed_file;
if (strcmp(extension, ".lzma") != 0) {
bb_error_msg_and_die("Invalid extension");
}
- /* TODO: xstat? */
- if (stat(filename, &stat_buf) < 0) {
- bb_error_msg_and_die("Couldn't stat file %s", filename);
- }
+ xstat(filename, &stat_buf);
*extension = 0;
dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
} else