ENH: On windows handle network paths

This commit is contained in:
Andy Cedilnik 2003-07-24 11:12:03 -04:00
parent e450309ca3
commit d720b2bc72
1 changed files with 50 additions and 3 deletions

View File

@ -23,6 +23,16 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined( _WIN32 ) || defined( APPLE ) || defined( __CYGWIN__ )
// On Windows and apple, no difference between lower and upper case
#define CM_GLOB_CASE_INDEPENDENT
#endif
#if defined( _WIN32 ) || defined( __CYGWIN__ )
// Handle network paths
#define CM_GLOB_SUPPORT_NETWORK_PATHS
#endif
class cmGlobInternal class cmGlobInternal
{ {
public: public:
@ -52,7 +62,7 @@ void cmGlob::Escape(int ch, char* buffer)
} }
else else
{ {
#if defined( _WIN32 ) || defined(APPLE) #if defined( CM_GLOB_CASE_INDEPENDENT )
// On Windows and apple, no difference between lower and upper case // On Windows and apple, no difference between lower and upper case
sprintf(buffer, "%c", tolower(ch)); sprintf(buffer, "%c", tolower(ch));
#else #else
@ -163,7 +173,7 @@ void cmGlob::RecurseDirectory(const std::string& dir, bool dir_only)
continue; continue;
} }
#if defined( _WIN32 ) || defined( APPLE ) #if defined( CM_GLOB_CASE_INDEPENDENT )
// On Windows and apple, no difference between lower and upper case // On Windows and apple, no difference between lower and upper case
fname = cmsys::SystemTools::LowerCase(fname); fname = cmsys::SystemTools::LowerCase(fname);
#endif #endif
@ -209,7 +219,7 @@ void cmGlob::ProcessDirectory(std::string::size_type start,
continue; continue;
} }
#if defined( _WIN32 ) || defined( APPLE ) #if defined( CM_GLOB_CASE_INDEPENDENT )
// On Windows and apple, no difference between lower and upper case // On Windows and apple, no difference between lower and upper case
fname = cmsys::SystemTools::LowerCase(fname); fname = cmsys::SystemTools::LowerCase(fname);
#endif #endif
@ -256,10 +266,36 @@ bool cmGlob::FindFiles(const std::string& inexpr)
expr = cmsys::SystemTools::GetCurrentWorkingDirectory(); expr = cmsys::SystemTools::GetCurrentWorkingDirectory();
expr += "/" + inexpr; expr += "/" + inexpr;
} }
int skip = 0;
#if defined( CM_GLOB_SUPPORT_NETWORK_PATHS )
// Handle network paths
if ( expr[0] == '/' && expr[1] == '/' )
{
int cnt = 0;
for ( cc = 2; cc < expr.size(); cc ++ )
{
if ( expr[cc] == '/' )
{
cnt ++;
if ( cnt == 2 )
{
break;
}
}
}
skip = cc + 1;
expr = expr.substr(skip);
}
else
#endif
if ( expr[1] == ':' && expr[0] != '/' ) if ( expr[1] == ':' && expr[0] != '/' )
{ {
expr = expr.substr(2); expr = expr.substr(2);
} }
cexpr = "";
for ( cc = 0; cc < expr.size(); cc ++ ) for ( cc = 0; cc < expr.size(); cc ++ )
{ {
int ch = expr[cc]; int ch = expr[cc];
@ -280,6 +316,17 @@ bool cmGlob::FindFiles(const std::string& inexpr)
{ {
this->AddExpression(cexpr.c_str()); this->AddExpression(cexpr.c_str());
} }
#ifdef _WIN32
// Handle network paths
if ( skip > 0 )
{
this->ProcessDirectory(0, inexpr.substr(0, skip),
true);
}
else
#endif
if ( inexpr[1] == ':' && inexpr[0] != '/' ) if ( inexpr[1] == ':' && inexpr[0] != '/' )
{ {
std::string startdir = "A:/"; std::string startdir = "A:/";