aboutsummaryrefslogtreecommitdiffstats
path: root/src/easydir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/easydir.c')
-rw-r--r--src/easydir.c41
1 files changed, 7 insertions, 34 deletions
diff --git a/src/easydir.c b/src/easydir.c
index 162bae7..6de77bc 100644
--- a/src/easydir.c
+++ b/src/easydir.c
@@ -5,43 +5,16 @@
#include <sys/wait.h>
#include <errno.h>
+#include "easydir.h"
#include "handerror.h"
-int deleteFile(char *file_path)
+int checkFileExist(char *source)
{
- char *arguments[] = {"rm", file_path, NULL};
- easyFork("rm", arguments);
-
- return 1;
-}
-
-int deleteEmptyDir(char *dir_path)
-{
- #if defined(DEBUG)
- char *arguments[] = {"rmdir", "-p", dir_path, NULL};
- #else
- char *arguments[] = {"rmdir", "-p", "--ignore-fail-on-non-empty", dir_path, NULL};
- #endif
- easyFork("rmdir", arguments);
-
- return 1;
-}
-
-int checkFileExist(char *path_to_file)
-{
- FILE *pFile;
-
- pFile = fopen(path_to_file, "r+"); // r+ so that errno can equal EISDIR
- if(pFile == NULL) {
- if(errno == ENOENT) // file doesn't exist
- return 0;
- if(errno == EISDIR) // it's directory
- return 2;
- else callError(120);
- }
- fclose(pFile);
-
- return 1;
+ FILE *file = fopen(source, "r+"); // r+ so that errno can equal EISDIR
+ if(!file)
+ return errno == EISDIR ? F_ISDIR : F_NOEXIST;
+ fclose(file);
+ return F_NOEXIST;
}
char *fileCropLineFeed(char *path, char *text, int maxlen)