Verify if a certain resource exists before do any other sanity check

This commit is contained in:
Felipe Zimmerle 2017-05-28 21:26:49 -03:00
parent 6143eb99e3
commit c49688fd7d
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277

View File

@ -147,6 +147,9 @@ bool createDir(std::string dir, int mode, std::string *error) {
bool isFile(std::string f) {
struct stat fileInfo;
FILE *fp = fopen(f.c_str(), "r");
if (fp == NULL) {
return false;
}
fstat(fileno(fp), &fileInfo);
if (!S_ISREG(fileInfo.st_mode)) {
fclose(fp);