blob: 08cac0fa28a979285506aefb0d35e48276eefd2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
#include "handerror.h"
int deleteFile(char *file_path)
{
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");
if(pFile == NULL) {
if(errno == ENOENT) { // file doesn't exist
return 0;
}
else callError(120);
}
fclose(pFile);
return 1;
}
|