From c4ccd4e0798a7ed9af6f86d9819b309575d418a0 Mon Sep 17 00:00:00 2001 From: Lieuwe Rooijakkers Date: Tue, 23 Jul 2024 00:23:06 +0200 Subject: file_to_filebuf: isdir output parameter --- src/tak.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/tak.c') diff --git a/src/tak.c b/src/tak.c index 8ae6ca5..e0c501f 100644 --- a/src/tak.c +++ b/src/tak.c @@ -82,11 +82,13 @@ int entry_tak(int argc, char **argv) { if (!strcmp(*args, "-")) { fb = stream_to_filebuf(stdin, 0); if (fb == NULL) goto err_stdin; + } else { + bool isdir = false; + fb = file_to_filebuf(*args, 0, &isdir); + if (isdir) goto err_isdir; + else if (fb == NULL) goto err_file; } - if (fb == NULL) fb = file_to_filebuf(*args, 0); - - if (fb == NULL) goto err_file; process(fb); args++; @@ -101,4 +103,8 @@ err_stdin: err_file: fprintf(stderr, "tak: fout bij lezen van bestand\n"); return 1; + +err_isdir: + fprintf(stderr, "tak: bestand '%s' is een mapje\n", *args); + return 1; } -- cgit v1.2.3-70-g09d2