BUG: Replace brittle GetParentDirectory impl

The previous change to this method broke cases where the input path does
not exist.  The SystemTools::GetParentDirectory method is redundant with
the more robust SystemTools::GetFilenamePath.  This replaces its
implementation to just call GetFilenamePath.
This commit is contained in:
Brad King 2009-04-15 13:03:33 -04:00
parent 1ed7f381f1
commit 3824f54c17
1 changed files with 1 additions and 25 deletions

View File

@ -3975,31 +3975,7 @@ bool SystemTools::SetPermissions(const char* file, mode_t mode)
kwsys_stl::string SystemTools::GetParentDirectory(const char* fileOrDir)
{
if ( !fileOrDir || !*fileOrDir || !SystemTools::FileExists(fileOrDir))
{
return "";
}
kwsys_stl::string res = fileOrDir;
SystemTools::ConvertToUnixSlashes(res);
// If the root "/" directory is passed in, return empty string
if(strcmp(res.c_str(), "/") ==0 )
{
return "";
}
kwsys_stl::string::size_type cc = res.size()-1;
if ( res[cc] == '/' )
{
cc --;
}
for ( ; cc > 0; cc -- )
{
if ( res[cc] == '/' )
{
break;
}
}
return res.substr(0, cc);
return SystemTools::GetFilenamePath(fileOrDir);
}
bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)