diff options
author | Brad King <brad.king@kitware.com> | 2009-04-15 17:03:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-04-15 17:03:33 (GMT) |
commit | 3824f54c1722b18409892a7112b091607c524a0d (patch) | |
tree | 1f0d9dede444aa86c978a055654d797e3bd1c0b9 /Source | |
parent | 1ed7f381f1200ca64dd8c8ac5abd6a7834193b2d (diff) | |
download | CMake-3824f54c1722b18409892a7112b091607c524a0d.zip CMake-3824f54c1722b18409892a7112b091607c524a0d.tar.gz CMake-3824f54c1722b18409892a7112b091607c524a0d.tar.bz2 |
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.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 94b7591..814c417 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -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) |