KWSys: Remove always-true dir_only parameter

Its presence confuses, and, since it is always true, is useless.
This commit is contained in:
David Cole 2011-09-06 13:07:52 -04:00
parent 5b4528b1f4
commit 98cb017a9d
2 changed files with 14 additions and 13 deletions

View File

@ -215,7 +215,7 @@ kwsys_stl::string Glob::PatternToRegex(const kwsys_stl::string& pattern,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void Glob::RecurseDirectory(kwsys_stl::string::size_type start, void Glob::RecurseDirectory(kwsys_stl::string::size_type start,
const kwsys_stl::string& dir, bool dir_only) const kwsys_stl::string& dir)
{ {
kwsys::Directory d; kwsys::Directory d;
if ( !d.Load(dir.c_str()) ) if ( !d.Load(dir.c_str()) )
@ -258,7 +258,9 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start,
fullname = dir + "/" + fname; fullname = dir + "/" + fname;
} }
if ( !dir_only || !kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) bool isDir = kwsys::SystemTools::FileIsDirectory(realname.c_str());
if ( !isDir )
{ {
if ( (this->Internals->Expressions.size() > 0) && if ( (this->Internals->Expressions.size() > 0) &&
this->Internals->Expressions[ this->Internals->Expressions[
@ -267,7 +269,7 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start,
this->AddFile(this->Internals->Files, realname.c_str()); this->AddFile(this->Internals->Files, realname.c_str());
} }
} }
if ( kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) else
{ {
bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str()); bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str());
if (!isSymLink || this->RecurseThroughSymlinks) if (!isSymLink || this->RecurseThroughSymlinks)
@ -276,7 +278,7 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start,
{ {
++this->FollowedSymlinkCount; ++this->FollowedSymlinkCount;
} }
this->RecurseDirectory(start+1, realname, dir_only); this->RecurseDirectory(start+1, realname);
} }
} }
} }
@ -284,13 +286,13 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void Glob::ProcessDirectory(kwsys_stl::string::size_type start, void Glob::ProcessDirectory(kwsys_stl::string::size_type start,
const kwsys_stl::string& dir, bool dir_only) const kwsys_stl::string& dir)
{ {
//kwsys_ios::cout << "ProcessDirectory: " << dir << kwsys_ios::endl; //kwsys_ios::cout << "ProcessDirectory: " << dir << kwsys_ios::endl;
bool last = ( start == this->Internals->Expressions.size()-1 ); bool last = ( start == this->Internals->Expressions.size()-1 );
if ( last && this->Recurse ) if ( last && this->Recurse )
{ {
this->RecurseDirectory(start, dir, dir_only); this->RecurseDirectory(start, dir);
return; return;
} }
@ -345,7 +347,7 @@ void Glob::ProcessDirectory(kwsys_stl::string::size_type start,
// << this->Internals->TextExpressions[start].c_str() << kwsys_ios::endl; // << this->Internals->TextExpressions[start].c_str() << kwsys_ios::endl;
//kwsys_ios::cout << "Full name: " << fullname << kwsys_ios::endl; //kwsys_ios::cout << "Full name: " << fullname << kwsys_ios::endl;
if ( (!dir_only || !last) && if ( !last &&
!kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) !kwsys::SystemTools::FileIsDirectory(realname.c_str()) )
{ {
continue; continue;
@ -359,7 +361,7 @@ void Glob::ProcessDirectory(kwsys_stl::string::size_type start,
} }
else else
{ {
this->ProcessDirectory(start+1, realname + "/", dir_only); this->ProcessDirectory(start+1, realname + "/");
} }
} }
} }
@ -462,12 +464,11 @@ bool Glob::FindFiles(const kwsys_stl::string& inexpr)
// Handle network paths // Handle network paths
if ( skip > 0 ) if ( skip > 0 )
{ {
this->ProcessDirectory(0, fexpr.substr(0, skip) + "/", this->ProcessDirectory(0, fexpr.substr(0, skip) + "/");
true);
} }
else else
{ {
this->ProcessDirectory(0, "/", true); this->ProcessDirectory(0, "/");
} }
return true; return true;
} }

View File

@ -83,12 +83,12 @@ public:
protected: protected:
//! Process directory //! Process directory
void ProcessDirectory(kwsys_stl::string::size_type start, void ProcessDirectory(kwsys_stl::string::size_type start,
const kwsys_stl::string& dir, bool dir_only); const kwsys_stl::string& dir);
//! Process last directory, but only when recurse flags is on. That is //! Process last directory, but only when recurse flags is on. That is
// effectively like saying: /path/to/file/**/file // effectively like saying: /path/to/file/**/file
void RecurseDirectory(kwsys_stl::string::size_type start, void RecurseDirectory(kwsys_stl::string::size_type start,
const kwsys_stl::string& dir, bool dir_only); const kwsys_stl::string& dir);
//! Add regular expression //! Add regular expression
void AddExpression(const char* expr); void AddExpression(const char* expr);