diff options
author | Brad King <brad.king@kitware.com> | 2001-09-20 14:54:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2001-09-20 14:54:29 (GMT) |
commit | 65ef85320a900c620f235fddc17ae2a6068ec75d (patch) | |
tree | 8dc6841de28a34c7536bff6bdf8d217c9f92d8f2 | |
parent | ee86c59cba8884879e94361044dd8d4359abfd6e (diff) | |
download | CMake-65ef85320a900c620f235fddc17ae2a6068ec75d.zip CMake-65ef85320a900c620f235fddc17ae2a6068ec75d.tar.gz CMake-65ef85320a900c620f235fddc17ae2a6068ec75d.tar.bz2 |
ENH: Added cmSystemTools::GlobDirs function to allow wildcards in paths (like /foo/bar/*).
-rw-r--r-- | Source/cmFindFileCommand.cxx | 3 | ||||
-rw-r--r-- | Source/cmFindLibraryCommand.cxx | 7 | ||||
-rw-r--r-- | Source/cmFindPathCommand.cxx | 6 | ||||
-rw-r--r-- | Source/cmFindProgramCommand.cxx | 7 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 34 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 1 |
6 files changed, 51 insertions, 7 deletions
diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx index c3b83c9..7a240fe 100644 --- a/Source/cmFindFileCommand.cxx +++ b/Source/cmFindFileCommand.cxx @@ -76,7 +76,8 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string>& args) // expand variables std::string exp = args[j]; m_Makefile->ExpandVariablesInString(exp); - path.push_back(exp); + // Glob the entry in case of wildcards. + cmSystemTools::GlobDirs(exp.c_str(), path); } // add the standard path diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index f27fc07..1a931bb 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -77,7 +77,8 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string>& args) else { cmSystemTools::ExpandRegistryValues(args[j]); - path.push_back(args[j]); + // Glob the entry in case of wildcards. + cmSystemTools::GlobDirs(args[j].c_str(), path); } } } @@ -94,7 +95,9 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string>& args) std::string exp = args[j]; m_Makefile->ExpandVariablesInString(exp); cmSystemTools::ExpandRegistryValues(exp); - path.push_back(exp); + + // Glob the entry in case of wildcards. + cmSystemTools::GlobDirs(exp.c_str(), path); } } diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index cd73ea1..7b0550c 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -68,8 +68,10 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string>& args) // expand variables std::string exp = args[j]; m_Makefile->ExpandVariablesInString(exp); - cmSystemTools::ExpandRegistryValues(exp); - path.push_back(exp); + cmSystemTools::ExpandRegistryValues(exp); + + // Glob the entry in case of wildcards. + cmSystemTools::GlobDirs(exp.c_str(), path); } // add the standard path diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index d40d7f9..1195ea8 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -91,7 +91,8 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string>& args) else { cmSystemTools::ExpandRegistryValues(args[j]); - path.push_back(args[j]); + // Glob the entry in case of wildcards. + cmSystemTools::GlobDirs(args[j].c_str(), path); } } } @@ -108,7 +109,9 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string>& args) std::string exp = args[j]; m_Makefile->ExpandVariablesInString(exp); cmSystemTools::ExpandRegistryValues(exp); - path.push_back(exp); + + // Glob the entry in case of wildcards. + cmSystemTools::GlobDirs(exp.c_str(), path); } } for(std::vector<std::string>::iterator i = names.begin(); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 29d96ea..f8e1874 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1305,3 +1305,37 @@ void cmSystemTools::Glob(const char *directory, const char *regexp, } } + +void cmSystemTools::GlobDirs(const char *fullPath, + std::vector<std::string>& files) +{ + std::string path = fullPath; + int pos = path.find("/*"); + if(pos == std::string::npos) + { + files.push_back(fullPath); + return; + } + std::string startPath = path.substr(0, pos); + std::string finishPath = path.substr(pos+2); + + cmDirectory d; + if (d.Load(startPath.c_str())) + { + for (int i = 0; i < d.GetNumberOfFiles(); ++i) + { + if((std::string(d.GetFile(i)) != ".") + && (std::string(d.GetFile(i)) != "..")) + { + std::string fname = startPath; + fname +="/"; + fname += d.GetFile(i); + if(cmSystemTools::FileIsDirectory(fname.c_str())) + { + fname += finishPath; + cmSystemTools::GlobDirs(fname.c_str(), files); + } + } + } + } +} diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index e50e425..b724bc7 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -226,6 +226,7 @@ public: static bool FileIsDirectory(const char* name); static void Glob(const char *directory, const char *regexp, std::vector<std::string>& files); + static void GlobDirs(const char *fullPath, std::vector<std::string>& files); static std::string GetCurrentWorkingDirectory(); static std::string GetProgramPath(const char*); |