summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2011-09-06 17:12:03 (GMT)
committerDavid Cole <david.cole@kitware.com>2011-09-06 17:20:02 (GMT)
commit527a40f06fc7f0ea6aa9c1fe96fb0fe5611fa633 (patch)
treeb5a5ef67181cc706eb009502e92427cd4de915e6
parent98cb017a9deca35cd9a67e03b6bd95064b6d2fb7 (diff)
downloadCMake-527a40f06fc7f0ea6aa9c1fe96fb0fe5611fa633.zip
CMake-527a40f06fc7f0ea6aa9c1fe96fb0fe5611fa633.tar.gz
CMake-527a40f06fc7f0ea6aa9c1fe96fb0fe5611fa633.tar.bz2
KWSys: Add symlinks to directories as files (#12284)
This behaviour was previously broken; regardless of the RecurseThroughSymLinks value, symlinks to directories were NEVER added as files in the results. When RecurseThroughSymLinks is ON, symlinks to directories should be recursed as if they were the actual directories to gather the files within. However, when RecurseThroughSymLinks is OFF, symlinks to directories should be returned as files in the result. Inspired-by: Johan Björk <phb@spotify.com>
-rw-r--r--Source/kwsys/Glob.cxx21
1 files changed, 9 insertions, 12 deletions
diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx
index b33b926..513eb64 100644
--- a/Source/kwsys/Glob.cxx
+++ b/Source/kwsys/Glob.cxx
@@ -259,26 +259,23 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start,
}
bool isDir = kwsys::SystemTools::FileIsDirectory(realname.c_str());
+ bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str());
- if ( !isDir )
+ if ( isDir && (!isSymLink || this->RecurseThroughSymlinks) )
{
- if ( (this->Internals->Expressions.size() > 0) &&
- this->Internals->Expressions[
- this->Internals->Expressions.size()-1].find(fname.c_str()) )
+ if (isSymLink)
{
- this->AddFile(this->Internals->Files, realname.c_str());
+ ++this->FollowedSymlinkCount;
}
+ this->RecurseDirectory(start+1, realname);
}
else
{
- bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str());
- if (!isSymLink || this->RecurseThroughSymlinks)
+ if ( (this->Internals->Expressions.size() > 0) &&
+ this->Internals->Expressions[
+ this->Internals->Expressions.size()-1].find(fname.c_str()) )
{
- if (isSymLink)
- {
- ++this->FollowedSymlinkCount;
- }
- this->RecurseDirectory(start+1, realname);
+ this->AddFile(this->Internals->Files, realname.c_str());
}
}
}