Add -C --clean

This commit is contained in:
2023-01-10 23:52:29 +01:00
parent 15c6b7ddaa
commit e8d8abdc5a
6 changed files with 115 additions and 17 deletions

View File

@ -15,21 +15,26 @@
int path_is_directory(const char *path) {
struct stat statbuf;
return stat(path, &statbuf) == 0 && S_ISDIR(statbuf.st_mode) != 0;
int e = errno;
struct stat stat_buf;
int ret = stat(path, &stat_buf);
errno = e;
return ret == 0 && S_ISDIR(stat_buf.st_mode) != 0;
}
int path_is_file(const char *path) {
struct stat statbuf;
int ret = stat(path, &statbuf);
errno = 0;
return ret == 0 && S_ISDIR(statbuf.st_mode) == 0;
int e = errno;
struct stat stat_buf;
int ret = stat(path, &stat_buf);
errno = e;
return ret == 0 && S_ISDIR(stat_buf.st_mode) == 0;
}
int path_exists(const char *path) {
struct stat statbuf;
int ret = stat(path, &statbuf);
errno = 0;
int e = errno;
struct stat stat_buf;
int ret = stat(path, &stat_buf);
errno = e;
return ret == 0;
}