diff options
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 7c81eb0..94b7591 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -3975,12 +3975,18 @@ bool SystemTools::SetPermissions(const char* file, mode_t mode) kwsys_stl::string SystemTools::GetParentDirectory(const char* fileOrDir) { - if ( !fileOrDir || !*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] == '/' ) { |