[utils] adding a function for checking if files exists (yay C), or at least the closest agreed-upon method for it (may return false if the user doesn't have permissions, but that's ok for our purposes here)
This commit is contained in:
@@ -32,6 +32,13 @@ char *file_getline(FILE * f)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool file_exists(char *filename) {
|
||||
FILE *f = fopen(filename, "r");
|
||||
bool exists = f != NULL;
|
||||
if (exists) fclose(f);
|
||||
return exists;
|
||||
}
|
||||
|
||||
bool is_relative_path(struct dirent *ent) {
|
||||
return strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user