Handle windows paths: mostly change tests for relative, and some other tweaks.

--HG--
branch : WINDOWSPORT
This commit is contained in:
Jean-Francois Dockes
2015-08-31 17:20:04 +02:00
parent 3aeffea387
commit 94da56aadc
12 changed files with 46 additions and 19 deletions
+15 -3
View File
@@ -380,10 +380,11 @@ string path_getfather(const string &s) {
if (father.empty())
return "./";
if (path_isroot(father))
return father;
if (father[father.length() - 1] == '/') {
// Input ends with /. Strip it, handle special case for root
if (father.length() == 1)
return father;
// Input ends with /. Strip it, root special case was tested above
father.erase(father.length()-1);
}
@@ -514,6 +515,17 @@ string path_tildexpand(const string &s)
return o;
}
bool path_isroot(const string& path)
{
if (path.size() == 1 && path[0] == '/')
return true;
#ifdef _WIN32
if (path.size == 3 && isalpha(path[0]) && path[1] == ':' && path[2] == '/')
return true;
#endif
return false;
}
bool path_isabsolute(const string &path)
{
if (!path.empty() && (path[0] == '/'