From ae1cb7fc44d7abb7ffe47656547cfae40cacdf05 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 30 Sep 2020 22:10:45 +0300 Subject: refactor input in -egi --- easydir.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'easydir.c') diff --git a/easydir.c b/easydir.c index a4ece76..0c8c387 100644 --- a/easydir.c +++ b/easydir.c @@ -111,3 +111,19 @@ int delete_emptydir(char *dir_path) return 1; } + +int checkFileExist(char *path_to_file) +{ + FILE *pFile; + + pFile = fopen(path_to_file, "r"); + if(pFile == NULL) { + if(errno == ENOENT) { // file doesn't exist + return 0; + } + else call_error(120); + } + fclose(pFile); + + return 1; +} -- cgit v1.2.3-18-g5258