Skip to content
Snippets Groups Projects
Commit 1ecd1ab6 authored by David Cole's avatar David Cole
Browse files

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: default avatarJohan Björk <phb@spotify.com>
parent bbbfe083
No related branches found
No related tags found
No related merge requests found
......@@ -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());
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment