ENH: fix glob on windows and add glob recurse test

This commit is contained in:
Andy Cedilnik 2003-07-21 15:29:29 -04:00
parent d4042b46d1
commit 2d513c2364
2 changed files with 25 additions and 2 deletions

View File

@ -205,6 +205,7 @@ void cmGlob::ProcessDirectory(std::string::size_type start,
{
continue;
}
if ( m_Internals->Expressions[start].find(d.GetFile(cc)) )
{
if ( last )
@ -233,6 +234,10 @@ bool cmGlob::FindFiles(const std::string& inexpr)
expr = cmsys::SystemTools::GetCurrentWorkingDirectory();
expr += "/" + inexpr;
}
if ( expr[1] == ':' && expr[0] != '/' )
{
expr = expr.substr(2);
}
for ( cc = 0; cc < expr.size(); cc ++ )
{
int ch = expr[cc];
@ -253,8 +258,24 @@ bool cmGlob::FindFiles(const std::string& inexpr)
{
this->AddExpression(cexpr.c_str());
}
this->ProcessDirectory(0, "/", true);
if ( inexpr[1] == ':' && inexpr[0] != '/' )
{
std::string startdir = "A:/";
if ( inexpr[0] >= 'a' && inexpr[0] <= 'z' ||
inexpr[0] >= 'A' && inexpr[0] <= 'Z')
{
startdir[0] = inexpr[0];
this->ProcessDirectory(0, startdir, true);
}
else
{
return false;
}
}
else
{
this->ProcessDirectory(0, "/", true);
}
return true;
}

View File

@ -60,6 +60,8 @@ STRING(REGEX REPLACE "includefile" "${file}" outfile "${infile}")
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/OutputFile.h" "${outfile}")
# Test file glob
FILE(GLOB_RECURSE src_files "${CMAKE_CURRENT_SOURCE_DIR}/*")
MESSAGE(STATUS "Files in ${CMAKE_CURRENT_SOURCE_DIR} are ${src_files}")
FILE(GLOB src_files "${CMAKE_CURRENT_SOURCE_DIR}/[sS][!a-su-zA-Z0-9][^a-qs-zA-Z0-9]ing?ile*.cxx")
ADD_EXECUTABLE(StringFileTest ${src_files})