dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit 520be8af4316a964af8002485578be8e9974ca2c
parent ca9ee58a216991ea03f4a6bc6a7834616e514fcb
Author: sin <sin@2f30.org>
Date:   Wed, 21 Mar 2018 14:33:11 +0000

Rework argument parsing

Diffstat:
Mdedup.c | 26++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/dedup.c b/dedup.c @@ -536,19 +536,25 @@ main(int argc, char *argv[]) return 0; } - if (argc == 1) { - if (id) + if (id) { + if (argc == 1) { fd = open(argv[0], O_RDWR | O_CREAT, 0600); - else + if (fd == -1) + err(1, "open %s", argv[0]); + } else { + fd = STDOUT_FILENO; + } + extract(id, fd); + } else { + if (argc == 1) { fd = open(argv[0], O_RDONLY); - if (fd == -1) - err(1, "open %s", argv[0]); + if (fd == -1) + err(1, "open %s", argv[0]); + } else { + fd = STDIN_FILENO; + } + dedup(fd); } - if (id) - extract(id, fd == -1 ? 0 : fd); - else - dedup(fd == -1 ? 0 : fd); - term(); }