diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2003-07-14 13:15:13 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2003-07-14 13:15:13 (GMT) |
commit | 274535d36642e5615a3b8b1d098396759a9e09f9 (patch) | |
tree | fdce84aed2f10ca0b68447fba707708dc5d11ad7 /Source/cmGlob.cxx | |
parent | 2910c30dd5b0042f476110d63e9c300b4e2feb0d (diff) | |
download | CMake-274535d36642e5615a3b8b1d098396759a9e09f9.zip CMake-274535d36642e5615a3b8b1d098396759a9e09f9.tar.gz CMake-274535d36642e5615a3b8b1d098396759a9e09f9.tar.bz2 |
ENH: Recurse subdirectories
Diffstat (limited to 'Source/cmGlob.cxx')
-rw-r--r-- | Source/cmGlob.cxx | 39 |
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 || |