Use xstat() instead of if(stat()) die()
authorRob Landley <rob@landley.net>
Tue, 13 Jun 2006 16:09:16 +0000 (16:09 -0000)
committerRob Landley <rob@landley.net>
Tue, 13 Jun 2006 16:09:16 +0000 (16:09 -0000)
archival/bunzip2.c
archival/uncompress.c
archival/unlzma.c

index 09364b40ecec128e9b9804452837a1d1fda6d52a..abd7db3ab730250dfa55d54066888590f816e1e2 100644 (file)
@@ -50,10 +50,7 @@ int bunzip2_main(int argc, char **argv)
                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;
index c47436ea381ccbdc889d43a306e73d99762ad68e..b282fe811c7f3a1468c79b00014b7ac77e309f04 100644 (file)
@@ -61,11 +61,9 @@ int uncompress_main(int argc, char **argv)
                        *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;
index 404da0acd486fa819e1d01d5c6561413acc22d44..b4881af7537b163ce33623eddc07d1a4a2a10706 100644 (file)
@@ -47,10 +47,7 @@ int unlzma_main(int argc, char **argv)
                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