summaryrefslogtreecommitdiff
path: root/bin/tar2sqfs/tar2sqfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/tar2sqfs/tar2sqfs.c')
-rw-r--r--bin/tar2sqfs/tar2sqfs.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/bin/tar2sqfs/tar2sqfs.c b/bin/tar2sqfs/tar2sqfs.c
index ae56e6b..6cab231 100644
--- a/bin/tar2sqfs/tar2sqfs.c
+++ b/bin/tar2sqfs/tar2sqfs.c
@@ -9,26 +9,18 @@
int main(int argc, char **argv)
{
int status = EXIT_FAILURE;
- FILE *input_file = NULL;
+ istream_t *input_file = NULL;
sqfs_writer_t sqfs;
process_args(argc, argv);
-#ifdef _WIN32
- _setmode(_fileno(stdin), _O_BINARY);
- input_file = stdin;
-#else
- input_file = freopen(NULL, "rb", stdin);
-#endif
-
- if (input_file == NULL) {
- perror("changing stdin to binary mode");
+ input_file = istream_open_stdin();
+ if (input_file == NULL)
return EXIT_FAILURE;
- }
memset(&sqfs, 0, sizeof(sqfs));
if (sqfs_writer_init(&sqfs, &cfg))
- return EXIT_FAILURE;
+ goto out_if;
if (process_tarball(input_file, &sqfs))
goto out;
@@ -42,5 +34,7 @@ int main(int argc, char **argv)
status = EXIT_SUCCESS;
out:
sqfs_writer_cleanup(&sqfs, status);
+out_if:
+ sqfs_destroy(input_file);
return status;
}