diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-09-13 13:37:42 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-09-16 09:34:35 +0200 |
commit | f757737060d4daebb24a32e90d912661428708a8 (patch) | |
tree | a6e96145d4fc540e435c13a69c924329db2edb6d /bin/tar2sqfs/tar2sqfs.c | |
parent | c1a2cb729bd5bb5fdadf00cb3968bbc541f79750 (diff) |
Remodel libtar/tar2sqfs to read data from an istream_t
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/tar2sqfs/tar2sqfs.c')
-rw-r--r-- | bin/tar2sqfs/tar2sqfs.c | 18 |
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; } |