+ in computeAbsolutePath(), if "root" path is empty, compute with the current path

This commit is contained in:
kelson42 2012-08-13 22:47:09 +00:00
parent 0305c3fff5
commit d37e2355f8
1 changed files with 10 additions and 1 deletions

View File

@ -50,7 +50,16 @@ string computeAbsolutePath(const string path, const string relativePath) {
#else #else
string separator = "/"; string separator = "/";
#endif #endif
string absolutePath = path[path.length() - 1] == separator[0] ? path : path + separator;
string absolutePath;
if (path.empty()) {
char *path=NULL;
size_t size;
path = getcwd(path,size);
absolutePath = string(path) + separator;
} else {
absolutePath = path[path.length() - 1] == separator[0] ? path : path + separator;
}
char *cRelativePath = strdup(relativePath.c_str()); char *cRelativePath = strdup(relativePath.c_str());
char *token = strtok(cRelativePath, "/"); char *token = strtok(cRelativePath, "/");