mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
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>
This commit is contained in:
@@ -259,28 +259,25 @@ 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) &&
|
||||
if (isSymLink)
|
||||
{
|
||||
++this->FollowedSymlinkCount;
|
||||
}
|
||||
this->RecurseDirectory(start+1, realname);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (this->Internals->Expressions.size() > 0) &&
|
||||
this->Internals->Expressions[
|
||||
this->Internals->Expressions.size()-1].find(fname.c_str()) )
|
||||
{
|
||||
this->AddFile(this->Internals->Files, realname.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str());
|
||||
if (!isSymLink || this->RecurseThroughSymlinks)
|
||||
{
|
||||
if (isSymLink)
|
||||
{
|
||||
++this->FollowedSymlinkCount;
|
||||
}
|
||||
this->RecurseDirectory(start+1, realname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user