[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:
Al
2017-03-10 13:39:43 -05:00
parent 3b33325c1a
commit b85ed70674
3 changed files with 8 additions and 4 deletions

View File

@@ -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;
}