|
a/src/utils/pathut.cpp |
|
b/src/utils/pathut.cpp |
|
... |
|
... |
329 |
if (!getcwd(buf, MAXPATHLEN)) {
|
329 |
if (!getcwd(buf, MAXPATHLEN)) {
|
330 |
return string();
|
330 |
return string();
|
331 |
}
|
331 |
}
|
332 |
s = path_cat(string(buf), s);
|
332 |
s = path_cat(string(buf), s);
|
333 |
}
|
333 |
}
|
334 |
list<string>elems;
|
334 |
vector<string> elems;
|
335 |
stringToTokens(s, elems, "/");
|
335 |
stringToTokens(s, elems, "/");
|
336 |
list<string> cleaned;
|
336 |
vector<string> cleaned;
|
337 |
for (list<string>::const_iterator it = elems.begin();
|
337 |
for (vector<string>::const_iterator it = elems.begin();
|
338 |
it != elems.end(); it++){
|
338 |
it != elems.end(); it++){
|
339 |
if (*it == "..") {
|
339 |
if (*it == "..") {
|
340 |
if (!cleaned.empty())
|
340 |
if (!cleaned.empty())
|
341 |
cleaned.pop_back();
|
341 |
cleaned.pop_back();
|
342 |
} else if (it->empty() || *it == ".") {
|
342 |
} else if (it->empty() || *it == ".") {
|
|
... |
|
... |
344 |
cleaned.push_back(*it);
|
344 |
cleaned.push_back(*it);
|
345 |
}
|
345 |
}
|
346 |
}
|
346 |
}
|
347 |
string ret;
|
347 |
string ret;
|
348 |
if (!cleaned.empty()) {
|
348 |
if (!cleaned.empty()) {
|
349 |
for (list<string>::const_iterator it = cleaned.begin();
|
349 |
for (vector<string>::const_iterator it = cleaned.begin();
|
350 |
it != cleaned.end(); it++) {
|
350 |
it != cleaned.end(); it++) {
|
351 |
ret += "/";
|
351 |
ret += "/";
|
352 |
ret += *it;
|
352 |
ret += *it;
|
353 |
}
|
353 |
}
|
354 |
} else {
|
354 |
} else {
|