+ add the fileExists() function

This commit is contained in:
kelson42 committed 2011-10-28 16:13:44 +00:00
1 parent 400cf57343
commit 5bd84c8db7
2 files changed
+16 -2

No files matched your search

+12 -1
View File
@@ -41,7 +41,7 @@ string computeAbsolutePath(const string libraryPath, const string relativePath)
if (string(token) == "..") {
absolutePath = removeLastPathElement(absolutePath, true, false);
token = strtok(NULL, "/");
} else if (token != "." && token != "") {
} else if (strcmp(token, ".") && strcmp(token, "")) {
absolutePath += string(token);
token = strtok(NULL, "/");
if (token != NULL)
@@ -82,3 +82,14 @@ string getFileSizeAsString(const string &path) {
sprintf(csize, "%u", getFileSize(path));
return csize;
}
bool fileExists(const string &path) {
bool flag = false;
fstream fin;
fin.open(path.c_str(), ios::in);
if (fin.is_open()) {
flag = true;
}
fin.close();
return flag;
}