summaryrefslogtreecommitdiffstats
path: root/Source/cmGlob.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2003-07-14 13:15:13 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2003-07-14 13:15:13 (GMT)
commit274535d36642e5615a3b8b1d098396759a9e09f9 (patch)
treefdce84aed2f10ca0b68447fba707708dc5d11ad7 /Source/cmGlob.cxx
parent2910c30dd5b0042f476110d63e9c300b4e2feb0d (diff)
downloadCMake-274535d36642e5615a3b8b1d098396759a9e09f9.zip
CMake-274535d36642e5615a3b8b1d098396759a9e09f9.tar.gz
CMake-274535d36642e5615a3b8b1d098396759a9e09f9.tar.bz2
ENH: Recurse subdirectories
Diffstat (limited to 'Source/cmGlob.cxx')
-rw-r--r--Source/cmGlob.cxx39
1 files changed, 38 insertions, 1 deletions
diff --git a/Source/cmGlob.cxx b/Source/cmGlob.cxx
index bb4d421..2ac32c7 100644
--- a/Source/cmGlob.cxx
+++ b/Source/cmGlob.cxx
@@ -32,6 +32,7 @@ public:
cmGlob::cmGlob()
{
m_Internals = new cmGlobInternal;
+ m_Recurse = false;
}
cmGlob::~cmGlob()
@@ -137,9 +138,46 @@ std::string cmGlob::ConvertExpression(const std::string& expr)
return res + "$";
}
+void cmGlob::RecurseDirectory(const std::string& dir, bool dir_only)
+{
+ cmsys::Directory d;
+ if ( !d.Load(dir.c_str()) )
+ {
+ return;
+ }
+ unsigned long cc;
+ std::string fullname;
+ for ( cc = 0; cc < d.GetNumberOfFiles(); cc ++ )
+ {
+ if ( strcmp(d.GetFile(cc), ".") == 0 ||
+ strcmp(d.GetFile(cc), "..") == 0 )
+ {
+ continue;
+ }
+ fullname = dir + "/" + d.GetFile(cc);
+ if ( !dir_only || !cmsys::SystemTools::FileIsDirectory(fullname.c_str()) )
+ {
+ if ( m_Internals->Expressions[m_Internals->Expressions.size()-1].find(d.GetFile(cc)) )
+ {
+ m_Internals->Files.push_back(fullname);
+ }
+ }
+ if ( cmsys::SystemTools::FileIsDirectory(fullname.c_str()) )
+ {
+ this->RecurseDirectory(fullname, dir_only);
+ }
+ }
+}
+
void cmGlob::ProcessDirectory(std::string::size_type start,
const std::string& dir, bool dir_only)
{
+ bool last = ( start == m_Internals->Expressions.size()-1 );
+ if ( last && m_Recurse )
+ {
+ this->RecurseDirectory(dir, dir_only);
+ return;
+ }
cmsys::Directory d;
if ( !d.Load(dir.c_str()) )
{
@@ -147,7 +185,6 @@ void cmGlob::ProcessDirectory(std::string::size_type start,
}
unsigned long cc;
std::string fullname;
- bool last = ( start == m_Internals->Expressions.size()-1 );
for ( cc = 0; cc < d.GetNumberOfFiles(); cc ++ )
{
if ( strcmp(d.GetFile(cc), ".") == 0 ||