BUG: fix collapse full path to handle a file in the root directory
This commit is contained in:
parent
6c0fb31d50
commit
8d41f97ff6
@ -725,7 +725,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove any trailing slash
|
// remove any trailing slash
|
||||||
if(path.size() && path[path.size()-1] == '/')
|
if(path.size() > 1 && path[path.size()-1] == '/')
|
||||||
{
|
{
|
||||||
path = path.substr(0, path.size()-1);
|
path = path.substr(0, path.size()-1);
|
||||||
}
|
}
|
||||||
@ -1364,6 +1364,12 @@ kwsys_stl::string SystemTools::CollapseFullPath(const char* in_relative,
|
|||||||
|
|
||||||
kwsys_stl::string dir, file;
|
kwsys_stl::string dir, file;
|
||||||
SystemTools::SplitProgramPath(in_relative, dir, file, false);
|
SystemTools::SplitProgramPath(in_relative, dir, file, false);
|
||||||
|
if(dir.size() == 0 &&
|
||||||
|
in_relative && strlen(in_relative) > 0 &&
|
||||||
|
in_relative[0] == '/')
|
||||||
|
{
|
||||||
|
dir = "/";
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Follow relative path.
|
// Follow relative path.
|
||||||
@ -1412,8 +1418,11 @@ kwsys_stl::string SystemTools::CollapseFullPath(const char* in_relative,
|
|||||||
// Construct and return the full path.
|
// Construct and return the full path.
|
||||||
kwsys_stl::string newPath = newDir;
|
kwsys_stl::string newPath = newDir;
|
||||||
if(!(file == ""))
|
if(!(file == ""))
|
||||||
|
{
|
||||||
|
if(!(newDir.size() == 1 && newDir[0] == '/'))
|
||||||
{
|
{
|
||||||
newPath += "/";
|
newPath += "/";
|
||||||
|
}
|
||||||
newPath += file;
|
newPath += file;
|
||||||
}
|
}
|
||||||
return newPath;
|
return newPath;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user