From c58777ec475ae1a03147246a15315a52538a5d41 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 21 Aug 2006 17:34:40 -0400 Subject: [PATCH] BUG: FileIsDirectory should work when the name contains a trailing slash. --- Source/kwsys/SystemTools.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 85225bafc..d1b31e71f 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(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) {