ENH: Added cmSystemTools::GlobDirs function to allow wildcards in paths (like /foo/bar/*).
This commit is contained in:
parent
ee86c59cba
commit
65ef85320a
|
@ -76,7 +76,8 @@ bool cmFindFileCommand::InitialPass(std::vector<std::string>& args)
|
||||||
// expand variables
|
// expand variables
|
||||||
std::string exp = args[j];
|
std::string exp = args[j];
|
||||||
m_Makefile->ExpandVariablesInString(exp);
|
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
|
// add the standard path
|
||||||
|
|
|
@ -77,7 +77,8 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string>& args)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmSystemTools::ExpandRegistryValues(args[j]);
|
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];
|
std::string exp = args[j];
|
||||||
m_Makefile->ExpandVariablesInString(exp);
|
m_Makefile->ExpandVariablesInString(exp);
|
||||||
cmSystemTools::ExpandRegistryValues(exp);
|
cmSystemTools::ExpandRegistryValues(exp);
|
||||||
path.push_back(exp);
|
|
||||||
|
// Glob the entry in case of wildcards.
|
||||||
|
cmSystemTools::GlobDirs(exp.c_str(), path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,9 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string>& args)
|
||||||
std::string exp = args[j];
|
std::string exp = args[j];
|
||||||
m_Makefile->ExpandVariablesInString(exp);
|
m_Makefile->ExpandVariablesInString(exp);
|
||||||
cmSystemTools::ExpandRegistryValues(exp);
|
cmSystemTools::ExpandRegistryValues(exp);
|
||||||
path.push_back(exp);
|
|
||||||
|
// Glob the entry in case of wildcards.
|
||||||
|
cmSystemTools::GlobDirs(exp.c_str(), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the standard path
|
// add the standard path
|
||||||
|
|
|
@ -91,7 +91,8 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string>& args)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmSystemTools::ExpandRegistryValues(args[j]);
|
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];
|
std::string exp = args[j];
|
||||||
m_Makefile->ExpandVariablesInString(exp);
|
m_Makefile->ExpandVariablesInString(exp);
|
||||||
cmSystemTools::ExpandRegistryValues(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();
|
for(std::vector<std::string>::iterator i = names.begin();
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -226,6 +226,7 @@ public:
|
||||||
static bool FileIsDirectory(const char* name);
|
static bool FileIsDirectory(const char* name);
|
||||||
static void Glob(const char *directory, const char *regexp,
|
static void Glob(const char *directory, const char *regexp,
|
||||||
std::vector<std::string>& files);
|
std::vector<std::string>& files);
|
||||||
|
static void GlobDirs(const char *fullPath, std::vector<std::string>& files);
|
||||||
|
|
||||||
static std::string GetCurrentWorkingDirectory();
|
static std::string GetCurrentWorkingDirectory();
|
||||||
static std::string GetProgramPath(const char*);
|
static std::string GetProgramPath(const char*);
|
||||||
|
|
Loading…
Reference in New Issue