+ small fix to avoid duplicate slashes in paths

This commit is contained in:
kelson42 2011-11-01 12:58:00 +00:00
parent 5922808e12
commit 79d00c2b36
1 changed files with 2 additions and 2 deletions

View File

@ -33,7 +33,7 @@ string computeAbsolutePath(const string path, const string relativePath) {
#else #else
string separator = "/"; string separator = "/";
#endif #endif
string absolutePath = path + "/"; string absolutePath = path[path.length() - 1] == '/' ? path : path + "/";
char *cRelativePath = strdup(relativePath.c_str()); char *cRelativePath = strdup(relativePath.c_str());
char *token = strtok(cRelativePath, "/"); char *token = strtok(cRelativePath, "/");
@ -78,7 +78,7 @@ string getLastPathElement(const string &path) {
string separator = "/"; string separator = "/";
#endif #endif
return path.substr(path.find_last_of(separator)); return path.substr(path.find_last_of(separator) + 1);
} }
unsigned int getFileSize(const string &path) { unsigned int getFileSize(const string &path) {