summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/SystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-08-21 21:34:40 (GMT)
committerBrad King <brad.king@kitware.com>2006-08-21 21:34:40 (GMT)
commitc58777ec475ae1a03147246a15315a52538a5d41 (patch)
treeabc6e0cb9d551c5d463a3c4adb19a08f12d8cbb9 /Source/kwsys/SystemTools.cxx
parentbed79f6c6b47b2c0661da67799ec37fce8905c54 (diff)
downloadCMake-c58777ec475ae1a03147246a15315a52538a5d41.zip
CMake-c58777ec475ae1a03147246a15315a52538a5d41.tar.gz
CMake-c58777ec475ae1a03147246a15315a52538a5d41.tar.bz2
BUG: FileIsDirectory should work when the name contains a trailing slash.
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r--Source/kwsys/SystemTools.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 85225ba..d1b31e7 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2256,6 +2256,17 @@ kwsys_stl::string SystemTools
bool SystemTools::FileIsDirectory(const char* name)
{
+ // Remove any trailing slash from the name.
+ char buffer[KWSYS_SYSTEMTOOLS_MAXPATH];
+ int last = static_cast<int>(strlen(name))-1;
+ if(last >= 0 && (name[last] == '/' || name[last] == '\\'))
+ {
+ memcpy(buffer, name, last);
+ buffer[last] = 0;
+ name = buffer;
+ }
+
+ // Now check the file node type.
struct stat fs;
if(stat(name, &fs) == 0)
{