Merge branch 'upstream-kwsys' into update-kwsys
This commit is contained in:
commit
540f02531b
|
@ -385,6 +385,26 @@ class SystemToolsTranslationMap :
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
struct SystemToolsPathCaseCmp
|
||||||
|
{
|
||||||
|
bool operator()(kwsys_stl::string const& l, kwsys_stl::string const& r) const
|
||||||
|
{
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
return _stricmp(l.c_str(), r.c_str()) < 0;
|
||||||
|
# elif defined(__GNUC__)
|
||||||
|
return strcasecmp(l.c_str(), r.c_str()) < 0;
|
||||||
|
# else
|
||||||
|
return SystemTools::Strucmp(l.c_str(), r.c_str()) < 0;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class SystemToolsPathCaseMap:
|
||||||
|
public kwsys_stl::map<kwsys_stl::string, kwsys_stl::string,
|
||||||
|
SystemToolsPathCaseCmp> {};
|
||||||
|
#endif
|
||||||
|
|
||||||
// adds the elements of the env variable path to the arg passed in
|
// adds the elements of the env variable path to the arg passed in
|
||||||
void SystemTools::GetPath(kwsys_stl::vector<kwsys_stl::string>& path, const char* env)
|
void SystemTools::GetPath(kwsys_stl::vector<kwsys_stl::string>& path, const char* env)
|
||||||
{
|
{
|
||||||
|
@ -3690,6 +3710,11 @@ static int GetCasePathName(const kwsys_stl::string & pathIn,
|
||||||
// Start with root component.
|
// Start with root component.
|
||||||
kwsys_stl::vector<kwsys_stl::string>::size_type idx = 0;
|
kwsys_stl::vector<kwsys_stl::string>::size_type idx = 0;
|
||||||
casePath = path_components[idx++];
|
casePath = path_components[idx++];
|
||||||
|
// make sure drive letter is always upper case
|
||||||
|
if(casePath.size() > 1 && casePath[1] == ':')
|
||||||
|
{
|
||||||
|
casePath[0] = toupper(casePath[0]);
|
||||||
|
}
|
||||||
const char* sep = "";
|
const char* sep = "";
|
||||||
|
|
||||||
// If network path, fill casePath with server/share so FindFirstFile
|
// If network path, fill casePath with server/share so FindFirstFile
|
||||||
|
@ -3745,27 +3770,21 @@ kwsys_stl::string SystemTools::GetActualCaseForPath(const kwsys_stl::string& p)
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
return p;
|
return p;
|
||||||
#else
|
#else
|
||||||
kwsys_stl::string casePath = p;
|
|
||||||
// make sure drive letter is always upper case
|
|
||||||
if(casePath.size() > 1 && casePath[1] == ':')
|
|
||||||
{
|
|
||||||
casePath[0] = toupper(casePath[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check to see if actual case has already been called
|
// Check to see if actual case has already been called
|
||||||
// for this path, and the result is stored in the LongPathMap
|
// for this path, and the result is stored in the PathCaseMap
|
||||||
SystemToolsTranslationMap::iterator i =
|
SystemToolsPathCaseMap::iterator i =
|
||||||
SystemTools::LongPathMap->find(casePath);
|
SystemTools::PathCaseMap->find(p);
|
||||||
if(i != SystemTools::LongPathMap->end())
|
if(i != SystemTools::PathCaseMap->end())
|
||||||
{
|
{
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
kwsys_stl::string casePath;
|
||||||
int len = GetCasePathName(p, casePath);
|
int len = GetCasePathName(p, casePath);
|
||||||
if(len == 0 || len > MAX_PATH+1)
|
if(len == 0 || len > MAX_PATH+1)
|
||||||
{
|
{
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
(*SystemTools::LongPathMap)[p] = casePath;
|
(*SystemTools::PathCaseMap)[p] = casePath;
|
||||||
return casePath;
|
return casePath;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -5139,7 +5158,9 @@ bool SystemTools::ParseURL( const kwsys_stl::string& URL,
|
||||||
// necessary.
|
// necessary.
|
||||||
static unsigned int SystemToolsManagerCount;
|
static unsigned int SystemToolsManagerCount;
|
||||||
SystemToolsTranslationMap *SystemTools::TranslationMap;
|
SystemToolsTranslationMap *SystemTools::TranslationMap;
|
||||||
SystemToolsTranslationMap *SystemTools::LongPathMap;
|
#ifdef _WIN32
|
||||||
|
SystemToolsPathCaseMap *SystemTools::PathCaseMap;
|
||||||
|
#endif
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
SystemToolsTranslationMap *SystemTools::Cyg2Win32Map;
|
SystemToolsTranslationMap *SystemTools::Cyg2Win32Map;
|
||||||
#endif
|
#endif
|
||||||
|
@ -5187,7 +5208,9 @@ void SystemTools::ClassInitialize()
|
||||||
#endif
|
#endif
|
||||||
// Allocate the translation map first.
|
// Allocate the translation map first.
|
||||||
SystemTools::TranslationMap = new SystemToolsTranslationMap;
|
SystemTools::TranslationMap = new SystemToolsTranslationMap;
|
||||||
SystemTools::LongPathMap = new SystemToolsTranslationMap;
|
#ifdef _WIN32
|
||||||
|
SystemTools::PathCaseMap = new SystemToolsPathCaseMap;
|
||||||
|
#endif
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
SystemTools::Cyg2Win32Map = new SystemToolsTranslationMap;
|
SystemTools::Cyg2Win32Map = new SystemToolsTranslationMap;
|
||||||
#endif
|
#endif
|
||||||
|
@ -5244,7 +5267,9 @@ void SystemTools::ClassInitialize()
|
||||||
void SystemTools::ClassFinalize()
|
void SystemTools::ClassFinalize()
|
||||||
{
|
{
|
||||||
delete SystemTools::TranslationMap;
|
delete SystemTools::TranslationMap;
|
||||||
delete SystemTools::LongPathMap;
|
#ifdef _WIN32
|
||||||
|
delete SystemTools::PathCaseMap;
|
||||||
|
#endif
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
delete SystemTools::Cyg2Win32Map;
|
delete SystemTools::Cyg2Win32Map;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -54,6 +54,8 @@ namespace @KWSYS_NAMESPACE@
|
||||||
{
|
{
|
||||||
|
|
||||||
class SystemToolsTranslationMap;
|
class SystemToolsTranslationMap;
|
||||||
|
class SystemToolsPathCaseMap;
|
||||||
|
|
||||||
/** \class SystemToolsManager
|
/** \class SystemToolsManager
|
||||||
* \brief Use to make sure SystemTools is initialized before it is used
|
* \brief Use to make sure SystemTools is initialized before it is used
|
||||||
* and is the last static object destroyed
|
* and is the last static object destroyed
|
||||||
|
@ -944,7 +946,9 @@ private:
|
||||||
* Each time 'dir' will be found it will be replace by 'refdir'
|
* Each time 'dir' will be found it will be replace by 'refdir'
|
||||||
*/
|
*/
|
||||||
static SystemToolsTranslationMap *TranslationMap;
|
static SystemToolsTranslationMap *TranslationMap;
|
||||||
static SystemToolsTranslationMap *LongPathMap;
|
#ifdef _WIN32
|
||||||
|
static SystemToolsPathCaseMap *PathCaseMap;
|
||||||
|
#endif
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
static SystemToolsTranslationMap *Cyg2Win32Map;
|
static SystemToolsTranslationMap *Cyg2Win32Map;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue