From 86e0a1998c2426fde3125ae853a981120d251b1c Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Tue, 12 Oct 2010 02:16:28 -0400 Subject: [PATCH] Let write be a filter --- write.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/write.c b/write.c index f51e2be..9259481 100644 --- a/write.c +++ b/write.c @@ -102,12 +102,17 @@ int main(int argc, char **argv) { argv += optind - 1; - if (argc != 3) + if (argc == 1) { + gInFile = stdin; + gOutFile = stdout; + } else if (argc == 3) { + if (!(gInFile = fopen(argv[1], "r"))) + die("Can't open input file"); + if (!(gOutFile = fopen(argv[2], "w"))) + die("Can't open output file"); + } else { die("Need two arguments"); - if (!(gInFile = fopen(argv[1], "r"))) - die("Can't open input file"); - if (!(gOutFile = fopen(argv[2], "w"))) - die("Can't open output file"); + } // xz options lzma_options_lzma lzma_opts;