From 31c1071ebfb559ba4d0cd113e54f85d9e2228d77 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Fri, 6 Feb 2004 15:26:15 -0500 Subject: ENH: When nor specifying full path, make sure it actually works, on broken filesystems fix case of files. --- Source/cmGlob.cxx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Source/cmGlob.cxx b/Source/cmGlob.cxx index 20db17e..8454384 100644 --- a/Source/cmGlob.cxx +++ b/Source/cmGlob.cxx @@ -163,6 +163,7 @@ void cmGlob::RecurseDirectory(const std::string& dir, bool dir_only) } unsigned long cc; std::string fullname; + std::string realname; std::string fname; for ( cc = 0; cc < d.GetNumberOfFiles(); cc ++ ) { @@ -173,6 +174,8 @@ void cmGlob::RecurseDirectory(const std::string& dir, bool dir_only) continue; } + realname = dir + "/" + fname; + #if defined( CM_GLOB_CASE_INDEPENDENT ) // On Windows and apple, no difference between lower and upper case fname = cmsys::SystemTools::LowerCase(fname); @@ -210,6 +213,7 @@ void cmGlob::ProcessDirectory(std::string::size_type start, } unsigned long cc; std::string fullname; + std::string realname; std::string fname; for ( cc = 0; cc < d.GetNumberOfFiles(); cc ++ ) { @@ -220,6 +224,15 @@ void cmGlob::ProcessDirectory(std::string::size_type start, continue; } + if ( start == 0 ) + { + realname = dir + fname; + } + else + { + realname = dir + "/" + fname; + } + #if defined( CM_GLOB_CASE_INDEPENDENT ) // On Windows and apple, no difference between lower and upper case fname = cmsys::SystemTools::LowerCase(fname); @@ -247,11 +260,11 @@ void cmGlob::ProcessDirectory(std::string::size_type start, { if ( last ) { - m_Internals->Files.push_back(fullname); + m_Internals->Files.push_back(realname); } else { - this->ProcessDirectory(start+1, fullname + "/", dir_only); + this->ProcessDirectory(start+1, realname + "/", dir_only); } } } @@ -271,6 +284,7 @@ bool cmGlob::FindFiles(const std::string& inexpr) expr = cmsys::SystemTools::GetCurrentWorkingDirectory(); expr += "/" + inexpr; } + std::string fexpr = expr; int skip = 0; int last_slash = 0; @@ -289,7 +303,7 @@ bool cmGlob::FindFiles(const std::string& inexpr) } if ( last_slash > 0 ) { - //std::cout << "I can skip: " << inexpr.substr(0, last_slash) << std::endl; + //std::cout << "I can skip: " << fexpr.substr(0, last_slash) << std::endl; skip = last_slash; } if ( skip == 0 ) @@ -351,7 +365,7 @@ bool cmGlob::FindFiles(const std::string& inexpr) // Handle network paths if ( skip > 0 ) { - this->ProcessDirectory(0, inexpr.substr(0, skip) + "/", + this->ProcessDirectory(0, fexpr.substr(0, skip) + "/", true); } else -- cgit v0.12