summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-04-20 16:56:15 +0200
committerOskar <[email protected]>2024-04-20 16:56:15 +0200
commitd0a02181a78720017cd5671023470437e8a0659a (patch)
tree51c9ef90ab1451f7824bb538b4180c9bcda84467
parentb3d8be14e12aca5993925c156da5eb76af88e665 (diff)
Added check for if its a directory or file
-rw-r--r--startmode.c9
1 files changed, 9 insertions, 0 deletions
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 <stdint.h>
+#include <sys/stat.h>
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) {