From d0a02181a78720017cd5671023470437e8a0659a Mon Sep 17 00:00:00 2001 From: Oskar Date: Sat, 20 Apr 2024 16:56:15 +0200 Subject: Added check for if its a directory or file --- startmode.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/startmode.c b/startmode.c index 7cf532a..645616d 100644 --- a/startmode.c +++ b/startmode.c @@ -8,6 +8,7 @@ #include "i_validation.h" #include "process_multiples.h" #include +#include extern int clfstdin_doubleprint; uint8_t new = 0; @@ -112,6 +113,14 @@ int fe_stop = 0; int startmode(char filename[]) { + struct stat sb; + stat(filename, &sb); + + if (sb.st_mode & S_IFDIR) { // check if its a directory + fprintf(stderr, "This is a directory\n"); + exit(EXIT_FAILURE); + } + uint8_t file_existence = check_if_file_exists(filename); if (fe_stop == 0) { if (file_existence == FILE_NOT_FOUND) { -- cgit v1.2.3