KWSys: Remove trailing whitespace in SystemTools.cxx
This commit is contained in:
parent
9aa10f8045
commit
2f8f7ec56a
@ -128,7 +128,7 @@ public:
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#define _unlink unlink
|
#define _unlink unlink
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The maximum length of a file name. */
|
/* The maximum length of a file name. */
|
||||||
#if defined(PATH_MAX)
|
#if defined(PATH_MAX)
|
||||||
@ -168,9 +168,9 @@ static inline char *realpath(const char *path, char *resolved_path)
|
|||||||
snprintf(resolved_path, maxlen, "%s", path);
|
snprintf(resolved_path, maxlen, "%s", path);
|
||||||
BPath normalized(resolved_path, NULL, true);
|
BPath normalized(resolved_path, NULL, true);
|
||||||
const char *resolved = normalized.Path();
|
const char *resolved = normalized.Path();
|
||||||
if (resolved != NULL) // NULL == No such file.
|
if (resolved != NULL) // NULL == No such file.
|
||||||
{
|
{
|
||||||
if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen)
|
if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen)
|
||||||
{
|
{
|
||||||
return resolved_path;
|
return resolved_path;
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ static inline char *realpath(const char *path, char *resolved_path)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__))
|
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__))
|
||||||
inline int Mkdir(const char* dir)
|
inline int Mkdir(const char* dir)
|
||||||
{
|
{
|
||||||
return _mkdir(dir);
|
return _mkdir(dir);
|
||||||
@ -300,7 +300,7 @@ double SystemTools::GetTime(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
class SystemToolsTranslationMap :
|
class SystemToolsTranslationMap :
|
||||||
public kwsys_stl::map<kwsys_stl::string,kwsys_stl::string>
|
public kwsys_stl::map<kwsys_stl::string,kwsys_stl::string>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
@ -392,7 +392,7 @@ kwsysDeletingCharVector::~kwsysDeletingCharVector()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
bool SystemTools::PutEnv(const char* value)
|
bool SystemTools::PutEnv(const char* value)
|
||||||
{
|
{
|
||||||
static kwsysDeletingCharVector localEnvironment;
|
static kwsysDeletingCharVector localEnvironment;
|
||||||
char* envVar = new char[strlen(value)+1];
|
char* envVar = new char[strlen(value)+1];
|
||||||
strcpy(envVar, value);
|
strcpy(envVar, value);
|
||||||
@ -414,7 +414,7 @@ const char* SystemTools::GetExecutableExtension()
|
|||||||
return ".exe";
|
return ".exe";
|
||||||
#else
|
#else
|
||||||
return "";
|
return "";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -482,7 +482,7 @@ void SystemTools::ReplaceString(kwsys_stl::string& source,
|
|||||||
{
|
{
|
||||||
const char *src = source.c_str();
|
const char *src = source.c_str();
|
||||||
char *searchPos = const_cast<char *>(strstr(src,replace));
|
char *searchPos = const_cast<char *>(strstr(src,replace));
|
||||||
|
|
||||||
// get out quick if string is not found
|
// get out quick if string is not found
|
||||||
if (!searchPos)
|
if (!searchPos)
|
||||||
{
|
{
|
||||||
@ -499,7 +499,7 @@ void SystemTools::ReplaceString(kwsys_stl::string& source,
|
|||||||
char *orig = strdup(src);
|
char *orig = strdup(src);
|
||||||
char *currentPos = orig;
|
char *currentPos = orig;
|
||||||
searchPos = searchPos - src + orig;
|
searchPos = searchPos - src + orig;
|
||||||
|
|
||||||
// initialize the result
|
// initialize the result
|
||||||
source.erase(source.begin(),source.end());
|
source.erase(source.begin(),source.end());
|
||||||
do
|
do
|
||||||
@ -551,7 +551,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Read a registry value.
|
// Read a registry value.
|
||||||
// Example :
|
// Example :
|
||||||
// HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath
|
// HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath
|
||||||
// => will return the data of the "default" value of the key
|
// => will return the data of the "default" value of the key
|
||||||
// HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root
|
// HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root
|
||||||
@ -580,7 +580,7 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value,
|
|||||||
|
|
||||||
second = primary.substr(start+1, valuenamepos-start-1);
|
second = primary.substr(start+1, valuenamepos-start-1);
|
||||||
primary = primary.substr(0, start);
|
primary = primary.substr(0, start);
|
||||||
|
|
||||||
HKEY primaryKey = HKEY_CURRENT_USER;
|
HKEY primaryKey = HKEY_CURRENT_USER;
|
||||||
if (primary == "HKEY_CURRENT_USER")
|
if (primary == "HKEY_CURRENT_USER")
|
||||||
{
|
{
|
||||||
@ -602,11 +602,11 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value,
|
|||||||
{
|
{
|
||||||
primaryKey = HKEY_USERS;
|
primaryKey = HKEY_USERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if(RegOpenKeyEx(primaryKey,
|
if(RegOpenKeyEx(primaryKey,
|
||||||
second.c_str(),
|
second.c_str(),
|
||||||
0,
|
0,
|
||||||
SystemToolsMakeRegistryMode(KEY_READ, view),
|
SystemToolsMakeRegistryMode(KEY_READ, view),
|
||||||
&hKey) != ERROR_SUCCESS)
|
&hKey) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
@ -617,11 +617,11 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value,
|
|||||||
DWORD dwType, dwSize;
|
DWORD dwType, dwSize;
|
||||||
dwSize = 1023;
|
dwSize = 1023;
|
||||||
char data[1024];
|
char data[1024];
|
||||||
if(RegQueryValueEx(hKey,
|
if(RegQueryValueEx(hKey,
|
||||||
(LPTSTR)valuename.c_str(),
|
(LPTSTR)valuename.c_str(),
|
||||||
NULL,
|
NULL,
|
||||||
&dwType,
|
&dwType,
|
||||||
(BYTE *)data,
|
(BYTE *)data,
|
||||||
&dwSize) == ERROR_SUCCESS)
|
&dwSize) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (dwType == REG_SZ)
|
if (dwType == REG_SZ)
|
||||||
@ -656,7 +656,7 @@ bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &,
|
|||||||
|
|
||||||
|
|
||||||
// Write a registry value.
|
// Write a registry value.
|
||||||
// Example :
|
// Example :
|
||||||
// HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath
|
// HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath
|
||||||
// => will set the data of the "default" value of the key
|
// => will set the data of the "default" value of the key
|
||||||
// HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root
|
// HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root
|
||||||
@ -669,7 +669,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value,
|
|||||||
kwsys_stl::string primary = key;
|
kwsys_stl::string primary = key;
|
||||||
kwsys_stl::string second;
|
kwsys_stl::string second;
|
||||||
kwsys_stl::string valuename;
|
kwsys_stl::string valuename;
|
||||||
|
|
||||||
size_t start = primary.find("\\");
|
size_t start = primary.find("\\");
|
||||||
if (start == kwsys_stl::string::npos)
|
if (start == kwsys_stl::string::npos)
|
||||||
{
|
{
|
||||||
@ -684,7 +684,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value,
|
|||||||
|
|
||||||
second = primary.substr(start+1, valuenamepos-start-1);
|
second = primary.substr(start+1, valuenamepos-start-1);
|
||||||
primary = primary.substr(0, start);
|
primary = primary.substr(0, start);
|
||||||
|
|
||||||
HKEY primaryKey = HKEY_CURRENT_USER;
|
HKEY primaryKey = HKEY_CURRENT_USER;
|
||||||
if (primary == "HKEY_CURRENT_USER")
|
if (primary == "HKEY_CURRENT_USER")
|
||||||
{
|
{
|
||||||
@ -706,13 +706,13 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value,
|
|||||||
{
|
{
|
||||||
primaryKey = HKEY_USERS;
|
primaryKey = HKEY_USERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD dwDummy;
|
DWORD dwDummy;
|
||||||
char lpClass[] = "";
|
char lpClass[] = "";
|
||||||
if(RegCreateKeyEx(primaryKey,
|
if(RegCreateKeyEx(primaryKey,
|
||||||
second.c_str(),
|
second.c_str(),
|
||||||
0,
|
0,
|
||||||
lpClass,
|
lpClass,
|
||||||
REG_OPTION_NON_VOLATILE,
|
REG_OPTION_NON_VOLATILE,
|
||||||
SystemToolsMakeRegistryMode(KEY_WRITE, view),
|
SystemToolsMakeRegistryMode(KEY_WRITE, view),
|
||||||
@ -723,11 +723,11 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(RegSetValueEx(hKey,
|
if(RegSetValueEx(hKey,
|
||||||
(LPTSTR)valuename.c_str(),
|
(LPTSTR)valuename.c_str(),
|
||||||
0,
|
0,
|
||||||
REG_SZ,
|
REG_SZ,
|
||||||
(CONST BYTE *)value,
|
(CONST BYTE *)value,
|
||||||
(DWORD)(strlen(value) + 1)) == ERROR_SUCCESS)
|
(DWORD)(strlen(value) + 1)) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -742,7 +742,7 @@ bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Delete a registry value.
|
// Delete a registry value.
|
||||||
// Example :
|
// Example :
|
||||||
// HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath
|
// HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath
|
||||||
// => will delete the data of the "default" value of the key
|
// => will delete the data of the "default" value of the key
|
||||||
// HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root
|
// HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root
|
||||||
@ -754,7 +754,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view)
|
|||||||
kwsys_stl::string primary = key;
|
kwsys_stl::string primary = key;
|
||||||
kwsys_stl::string second;
|
kwsys_stl::string second;
|
||||||
kwsys_stl::string valuename;
|
kwsys_stl::string valuename;
|
||||||
|
|
||||||
size_t start = primary.find("\\");
|
size_t start = primary.find("\\");
|
||||||
if (start == kwsys_stl::string::npos)
|
if (start == kwsys_stl::string::npos)
|
||||||
{
|
{
|
||||||
@ -769,7 +769,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view)
|
|||||||
|
|
||||||
second = primary.substr(start+1, valuenamepos-start-1);
|
second = primary.substr(start+1, valuenamepos-start-1);
|
||||||
primary = primary.substr(0, start);
|
primary = primary.substr(0, start);
|
||||||
|
|
||||||
HKEY primaryKey = HKEY_CURRENT_USER;
|
HKEY primaryKey = HKEY_CURRENT_USER;
|
||||||
if (primary == "HKEY_CURRENT_USER")
|
if (primary == "HKEY_CURRENT_USER")
|
||||||
{
|
{
|
||||||
@ -791,11 +791,11 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view)
|
|||||||
{
|
{
|
||||||
primaryKey = HKEY_USERS;
|
primaryKey = HKEY_USERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if(RegOpenKeyEx(primaryKey,
|
if(RegOpenKeyEx(primaryKey,
|
||||||
second.c_str(),
|
second.c_str(),
|
||||||
0,
|
0,
|
||||||
SystemToolsMakeRegistryMode(KEY_WRITE, view),
|
SystemToolsMakeRegistryMode(KEY_WRITE, view),
|
||||||
&hKey) != ERROR_SUCCESS)
|
&hKey) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
@ -803,7 +803,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(RegDeleteValue(hKey,
|
if(RegDeleteValue(hKey,
|
||||||
(LPTSTR)valuename.c_str()) == ERROR_SUCCESS)
|
(LPTSTR)valuename.c_str()) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
@ -824,17 +824,17 @@ bool SystemTools::SameFile(const char* file1, const char* file2)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE hFile1, hFile2;
|
HANDLE hFile1, hFile2;
|
||||||
|
|
||||||
hFile1 = CreateFile( file1,
|
hFile1 = CreateFile( file1,
|
||||||
GENERIC_READ,
|
GENERIC_READ,
|
||||||
FILE_SHARE_READ ,
|
FILE_SHARE_READ ,
|
||||||
NULL,
|
NULL,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
FILE_FLAG_BACKUP_SEMANTICS,
|
FILE_FLAG_BACKUP_SEMANTICS,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
hFile2 = CreateFile( file2,
|
hFile2 = CreateFile( file2,
|
||||||
GENERIC_READ,
|
GENERIC_READ,
|
||||||
FILE_SHARE_READ,
|
FILE_SHARE_READ,
|
||||||
NULL,
|
NULL,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
FILE_FLAG_BACKUP_SEMANTICS,
|
FILE_FLAG_BACKUP_SEMANTICS,
|
||||||
@ -868,10 +868,10 @@ bool SystemTools::SameFile(const char* file1, const char* file2)
|
|||||||
{
|
{
|
||||||
// see if the files are the same file
|
// see if the files are the same file
|
||||||
// check the device inode and size
|
// check the device inode and size
|
||||||
if(memcmp(&fileStat2.st_dev, &fileStat1.st_dev, sizeof(fileStat1.st_dev)) == 0 &&
|
if(memcmp(&fileStat2.st_dev, &fileStat1.st_dev, sizeof(fileStat1.st_dev)) == 0 &&
|
||||||
memcmp(&fileStat2.st_ino, &fileStat1.st_ino, sizeof(fileStat1.st_ino)) == 0 &&
|
memcmp(&fileStat2.st_ino, &fileStat1.st_ino, sizeof(fileStat1.st_ino)) == 0 &&
|
||||||
fileStat2.st_size == fileStat1.st_size
|
fileStat2.st_size == fileStat1.st_size
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1068,11 +1068,11 @@ kwsys_stl::string SystemTools::CapitalizedWords(const kwsys_stl::string& s)
|
|||||||
#if defined(_MSC_VER) && defined (_MT) && defined (_DEBUG)
|
#if defined(_MSC_VER) && defined (_MT) && defined (_DEBUG)
|
||||||
// MS has an assert that will fail if s[i] < 0; setting
|
// MS has an assert that will fail if s[i] < 0; setting
|
||||||
// LC_CTYPE using setlocale() does *not* help. Painful.
|
// LC_CTYPE using setlocale() does *not* help. Painful.
|
||||||
if ((int)s[i] >= 0 && isalpha(s[i]) &&
|
if ((int)s[i] >= 0 && isalpha(s[i]) &&
|
||||||
(i == 0 || ((int)s[i - 1] >= 0 && isspace(s[i - 1]))))
|
(i == 0 || ((int)s[i - 1] >= 0 && isspace(s[i - 1]))))
|
||||||
#else
|
#else
|
||||||
if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1])))
|
if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1])))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
n[i] = static_cast<kwsys_stl::string::value_type>(toupper(s[i]));
|
n[i] = static_cast<kwsys_stl::string::value_type>(toupper(s[i]));
|
||||||
}
|
}
|
||||||
@ -1089,11 +1089,11 @@ kwsys_stl::string SystemTools::UnCapitalizedWords(const kwsys_stl::string& s)
|
|||||||
#if defined(_MSC_VER) && defined (_MT) && defined (_DEBUG)
|
#if defined(_MSC_VER) && defined (_MT) && defined (_DEBUG)
|
||||||
// MS has an assert that will fail if s[i] < 0; setting
|
// MS has an assert that will fail if s[i] < 0; setting
|
||||||
// LC_CTYPE using setlocale() does *not* help. Painful.
|
// LC_CTYPE using setlocale() does *not* help. Painful.
|
||||||
if ((int)s[i] >= 0 && isalpha(s[i]) &&
|
if ((int)s[i] >= 0 && isalpha(s[i]) &&
|
||||||
(i == 0 || ((int)s[i - 1] >= 0 && isspace(s[i - 1]))))
|
(i == 0 || ((int)s[i - 1] >= 0 && isspace(s[i - 1]))))
|
||||||
#else
|
#else
|
||||||
if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1])))
|
if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1])))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
n[i] = static_cast<kwsys_stl::string::value_type>(tolower(s[i]));
|
n[i] = static_cast<kwsys_stl::string::value_type>(tolower(s[i]));
|
||||||
}
|
}
|
||||||
@ -1171,7 +1171,7 @@ char* SystemTools::AppendStrings(
|
|||||||
return newstr;
|
return newstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a lower case string
|
// Return a lower case string
|
||||||
kwsys_stl::string SystemTools::LowerCase(const kwsys_stl::string& s)
|
kwsys_stl::string SystemTools::LowerCase(const kwsys_stl::string& s)
|
||||||
{
|
{
|
||||||
kwsys_stl::string n;
|
kwsys_stl::string n;
|
||||||
@ -1183,7 +1183,7 @@ kwsys_stl::string SystemTools::LowerCase(const kwsys_stl::string& s)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a lower case string
|
// Return a lower case string
|
||||||
kwsys_stl::string SystemTools::UpperCase(const kwsys_stl::string& s)
|
kwsys_stl::string SystemTools::UpperCase(const kwsys_stl::string& s)
|
||||||
{
|
{
|
||||||
kwsys_stl::string n;
|
kwsys_stl::string n;
|
||||||
@ -1313,7 +1313,7 @@ const char* SystemTools::FindLastString(const char* str1, const char* str2)
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len1 = strlen(str1), len2 = strlen(str2);
|
size_t len1 = strlen(str1), len2 = strlen(str2);
|
||||||
if (len1 >= len2)
|
if (len1 >= len2)
|
||||||
{
|
{
|
||||||
@ -1341,8 +1341,8 @@ char* SystemTools::DuplicateString(const char* str)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a cropped string
|
// Return a cropped string
|
||||||
kwsys_stl::string SystemTools::CropString(const kwsys_stl::string& s,
|
kwsys_stl::string SystemTools::CropString(const kwsys_stl::string& s,
|
||||||
size_t max_len)
|
size_t max_len)
|
||||||
{
|
{
|
||||||
if (!s.size() || max_len == 0 || max_len >= s.size())
|
if (!s.size() || max_len == 0 || max_len >= s.size())
|
||||||
@ -1386,7 +1386,7 @@ kwsys_stl::vector<kwsys::String> SystemTools::SplitString(const char* p, char se
|
|||||||
if(isPath && path[0] == '/')
|
if(isPath && path[0] == '/')
|
||||||
{
|
{
|
||||||
path.erase(path.begin());
|
path.erase(path.begin());
|
||||||
paths.push_back("/");
|
paths.push_back("/");
|
||||||
}
|
}
|
||||||
kwsys_stl::string::size_type pos1 = 0;
|
kwsys_stl::string::size_type pos1 = 0;
|
||||||
kwsys_stl::string::size_type pos2 = path.find(sep, pos1+1);
|
kwsys_stl::string::size_type pos2 = path.find(sep, pos1+1);
|
||||||
@ -1395,9 +1395,9 @@ kwsys_stl::vector<kwsys::String> SystemTools::SplitString(const char* p, char se
|
|||||||
paths.push_back(path.substr(pos1, pos2-pos1));
|
paths.push_back(path.substr(pos1, pos2-pos1));
|
||||||
pos1 = pos2+1;
|
pos1 = pos2+1;
|
||||||
pos2 = path.find(sep, pos1+1);
|
pos2 = path.find(sep, pos1+1);
|
||||||
}
|
}
|
||||||
paths.push_back(path.substr(pos1, pos2-pos1));
|
paths.push_back(path.substr(pos1, pos2-pos1));
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1411,11 +1411,11 @@ int SystemTools::EstimateFormatLength(const char *format, va_list ap)
|
|||||||
|
|
||||||
// Quick-hack attempt at estimating the length of the string.
|
// Quick-hack attempt at estimating the length of the string.
|
||||||
// Should never under-estimate.
|
// Should never under-estimate.
|
||||||
|
|
||||||
// Start with the length of the format string itself.
|
// Start with the length of the format string itself.
|
||||||
|
|
||||||
size_t length = strlen(format);
|
size_t length = strlen(format);
|
||||||
|
|
||||||
// Increase the length for every argument in the format.
|
// Increase the length for every argument in the format.
|
||||||
|
|
||||||
const char* cur = format;
|
const char* cur = format;
|
||||||
@ -1447,7 +1447,7 @@ int SystemTools::EstimateFormatLength(const char *format, va_list ap)
|
|||||||
{
|
{
|
||||||
// Assume the argument contributes no more than 64 characters.
|
// Assume the argument contributes no more than 64 characters.
|
||||||
length += 64;
|
length += 64;
|
||||||
|
|
||||||
// Eat the argument.
|
// Eat the argument.
|
||||||
static_cast<void>(va_arg(ap, double));
|
static_cast<void>(va_arg(ap, double));
|
||||||
} break;
|
} break;
|
||||||
@ -1455,24 +1455,24 @@ int SystemTools::EstimateFormatLength(const char *format, va_list ap)
|
|||||||
{
|
{
|
||||||
// Assume the argument contributes no more than 64 characters.
|
// Assume the argument contributes no more than 64 characters.
|
||||||
length += 64;
|
length += 64;
|
||||||
|
|
||||||
// Eat the argument.
|
// Eat the argument.
|
||||||
static_cast<void>(va_arg(ap, int));
|
static_cast<void>(va_arg(ap, int));
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move past the characters just tested.
|
// Move past the characters just tested.
|
||||||
++cur;
|
++cur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<int>(length);
|
return static_cast<int>(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
kwsys_stl::string SystemTools::EscapeChars(
|
kwsys_stl::string SystemTools::EscapeChars(
|
||||||
const char *str,
|
const char *str,
|
||||||
const char *chars_to_escape,
|
const char *chars_to_escape,
|
||||||
char escape_char)
|
char escape_char)
|
||||||
{
|
{
|
||||||
kwsys_stl::string n;
|
kwsys_stl::string n;
|
||||||
@ -1529,7 +1529,7 @@ static void ConvertVMSToUnix(kwsys_stl::string& path)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// convert windows slashes to unix slashes
|
// convert windows slashes to unix slashes
|
||||||
void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
|
void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
|
||||||
{
|
{
|
||||||
const char* pathCString = path.c_str();
|
const char* pathCString = path.c_str();
|
||||||
@ -1596,7 +1596,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// remove trailing slash if the path is more than
|
// remove trailing slash if the path is more than
|
||||||
// a single /
|
// a single /
|
||||||
pathCString = path.c_str();
|
pathCString = path.c_str();
|
||||||
if(path.size() > 1 && *(pathCString+(path.size()-1)) == '/')
|
if(path.size() > 1 && *(pathCString+(path.size()-1)) == '/')
|
||||||
@ -1614,7 +1614,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
|
|||||||
kwsys_stl::string SystemTools::ConvertToUnixOutputPath(const char* path)
|
kwsys_stl::string SystemTools::ConvertToUnixOutputPath(const char* path)
|
||||||
{
|
{
|
||||||
kwsys_stl::string ret = path;
|
kwsys_stl::string ret = path;
|
||||||
|
|
||||||
// remove // except at the beginning might be a cygwin drive
|
// remove // except at the beginning might be a cygwin drive
|
||||||
kwsys_stl::string::size_type pos=1;
|
kwsys_stl::string::size_type pos=1;
|
||||||
while((pos = ret.find("//", pos)) != kwsys_stl::string::npos)
|
while((pos = ret.find("//", pos)) != kwsys_stl::string::npos)
|
||||||
@ -1652,7 +1652,7 @@ kwsys_stl::string SystemTools::ConvertToOutputPath(const char* path)
|
|||||||
|
|
||||||
// remove double slashes not at the start
|
// remove double slashes not at the start
|
||||||
kwsys_stl::string SystemTools::ConvertToWindowsOutputPath(const char* path)
|
kwsys_stl::string SystemTools::ConvertToWindowsOutputPath(const char* path)
|
||||||
{
|
{
|
||||||
kwsys_stl::string ret;
|
kwsys_stl::string ret;
|
||||||
// make it big enough for all of path and double quotes
|
// make it big enough for all of path and double quotes
|
||||||
ret.reserve(strlen(path)+3);
|
ret.reserve(strlen(path)+3);
|
||||||
@ -1738,13 +1738,13 @@ bool SystemTools::FilesDiffer(const char* source,
|
|||||||
const char* destination)
|
const char* destination)
|
||||||
{
|
{
|
||||||
struct stat statSource;
|
struct stat statSource;
|
||||||
if (stat(source, &statSource) != 0)
|
if (stat(source, &statSource) != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stat statDestination;
|
struct stat statDestination;
|
||||||
if (stat(destination, &statDestination) != 0)
|
if (stat(destination, &statDestination) != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1790,7 +1790,7 @@ bool SystemTools::FilesDiffer(const char* source,
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this block differs the file differs.
|
// If this block differs the file differs.
|
||||||
if(memcmp(static_cast<const void*>(source_buf),
|
if(memcmp(static_cast<const void*>(source_buf),
|
||||||
static_cast<const void*>(dest_buf),
|
static_cast<const void*>(dest_buf),
|
||||||
@ -1849,7 +1849,7 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination)
|
|||||||
// Open files
|
// Open files
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
kwsys_ios::ifstream fin(source,
|
kwsys_ios::ifstream fin(source,
|
||||||
kwsys_ios::ios::binary | kwsys_ios::ios::in);
|
kwsys_ios::ios::binary | kwsys_ios::ios::in);
|
||||||
#else
|
#else
|
||||||
kwsys_ios::ifstream fin(source);
|
kwsys_ios::ifstream fin(source);
|
||||||
@ -1858,7 +1858,7 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// try and remove the destination file so that read only destination files
|
// try and remove the destination file so that read only destination files
|
||||||
// can be written to.
|
// can be written to.
|
||||||
// If the remove fails continue so that files in read only directories
|
// If the remove fails continue so that files in read only directories
|
||||||
@ -1866,17 +1866,17 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination)
|
|||||||
SystemTools::RemoveFile(destination);
|
SystemTools::RemoveFile(destination);
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
kwsys_ios::ofstream fout(destination,
|
kwsys_ios::ofstream fout(destination,
|
||||||
kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc);
|
kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc);
|
||||||
#else
|
#else
|
||||||
kwsys_ios::ofstream fout(destination,
|
kwsys_ios::ofstream fout(destination,
|
||||||
kwsys_ios::ios::out | kwsys_ios::ios::trunc);
|
kwsys_ios::ios::out | kwsys_ios::ios::trunc);
|
||||||
#endif
|
#endif
|
||||||
if(!fout)
|
if(!fout)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This copy loop is very sensitive on certain platforms with
|
// This copy loop is very sensitive on certain platforms with
|
||||||
// slightly broken stream libraries (like HPUX). Normally, it is
|
// slightly broken stream libraries (like HPUX). Normally, it is
|
||||||
// incorrect to not check the error condition on the fin.read()
|
// incorrect to not check the error condition on the fin.read()
|
||||||
@ -1890,12 +1890,12 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination)
|
|||||||
fout.write(buffer, fin.gcount());
|
fout.write(buffer, fin.gcount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the operating system has finished writing the file
|
// Make sure the operating system has finished writing the file
|
||||||
// before closing it. This will ensure the file is finished before
|
// before closing it. This will ensure the file is finished before
|
||||||
// the check below.
|
// the check below.
|
||||||
fout.flush();
|
fout.flush();
|
||||||
|
|
||||||
fin.close();
|
fin.close();
|
||||||
fout.close();
|
fout.close();
|
||||||
|
|
||||||
@ -1979,7 +1979,7 @@ bool SystemTools::CopyADirectory(const char* source, const char* destination,
|
|||||||
unsigned long SystemTools::FileLength(const char* filename)
|
unsigned long SystemTools::FileLength(const char* filename)
|
||||||
{
|
{
|
||||||
struct stat fs;
|
struct stat fs;
|
||||||
if (stat(filename, &fs) != 0)
|
if (stat(filename, &fs) != 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2225,7 +2225,7 @@ kwsys_stl::string SystemTools
|
|||||||
{
|
{
|
||||||
// Add the system search path to our path first
|
// Add the system search path to our path first
|
||||||
kwsys_stl::vector<kwsys_stl::string> path;
|
kwsys_stl::vector<kwsys_stl::string> path;
|
||||||
if (!no_system_path)
|
if (!no_system_path)
|
||||||
{
|
{
|
||||||
SystemTools::GetPath(path, "CMAKE_FILE_PATH");
|
SystemTools::GetPath(path, "CMAKE_FILE_PATH");
|
||||||
SystemTools::GetPath(path);
|
SystemTools::GetPath(path);
|
||||||
@ -2340,7 +2340,7 @@ kwsys_stl::string SystemTools::FindProgram(
|
|||||||
// first try with extensions if the os supports them
|
// first try with extensions if the os supports them
|
||||||
if(extensions.size())
|
if(extensions.size())
|
||||||
{
|
{
|
||||||
for(kwsys_stl::vector<kwsys_stl::string>::iterator i =
|
for(kwsys_stl::vector<kwsys_stl::string>::iterator i =
|
||||||
extensions.begin(); i != extensions.end(); ++i)
|
extensions.begin(); i != extensions.end(); ++i)
|
||||||
{
|
{
|
||||||
tryPath = name;
|
tryPath = name;
|
||||||
@ -2368,7 +2368,7 @@ kwsys_stl::string SystemTools::FindProgram(
|
|||||||
}
|
}
|
||||||
// now add the additional paths
|
// now add the additional paths
|
||||||
{
|
{
|
||||||
for(kwsys_stl::vector<kwsys_stl::string>::const_iterator i =
|
for(kwsys_stl::vector<kwsys_stl::string>::const_iterator i =
|
||||||
userPaths.begin(); i != userPaths.end(); ++i)
|
userPaths.begin(); i != userPaths.end(); ++i)
|
||||||
{
|
{
|
||||||
path.push_back(*i);
|
path.push_back(*i);
|
||||||
@ -2397,7 +2397,7 @@ kwsys_stl::string SystemTools::FindProgram(
|
|||||||
// first try with extensions
|
// first try with extensions
|
||||||
if(extensions.size())
|
if(extensions.size())
|
||||||
{
|
{
|
||||||
for(kwsys_stl::vector<kwsys_stl::string>::iterator ext
|
for(kwsys_stl::vector<kwsys_stl::string>::iterator ext
|
||||||
= extensions.begin(); ext != extensions.end(); ++ext)
|
= extensions.begin(); ext != extensions.end(); ++ext)
|
||||||
{
|
{
|
||||||
tryPath = *p;
|
tryPath = *p;
|
||||||
@ -2962,7 +2962,7 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot
|
|||||||
}
|
}
|
||||||
|
|
||||||
// split up both paths into arrays of strings using / as a separator
|
// split up both paths into arrays of strings using / as a separator
|
||||||
kwsys_stl::vector<kwsys::String> localSplit = SystemTools::SplitString(local, '/', true);
|
kwsys_stl::vector<kwsys::String> localSplit = SystemTools::SplitString(local, '/', true);
|
||||||
kwsys_stl::vector<kwsys::String> remoteSplit = SystemTools::SplitString(remote, '/', true);
|
kwsys_stl::vector<kwsys::String> remoteSplit = SystemTools::SplitString(remote, '/', true);
|
||||||
kwsys_stl::vector<kwsys::String> commonPath; // store shared parts of path in this array
|
kwsys_stl::vector<kwsys::String> commonPath; // store shared parts of path in this array
|
||||||
kwsys_stl::vector<kwsys::String> finalPath; // store the final relative path here
|
kwsys_stl::vector<kwsys::String> finalPath; // store the final relative path here
|
||||||
@ -3019,7 +3019,7 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
kwsys_stl::string relativePath; // result string
|
kwsys_stl::string relativePath; // result string
|
||||||
// now turn the array of directories into a unix path by puttint /
|
// now turn the array of directories into a unix path by puttint /
|
||||||
// between each entry that does not already have one
|
// between each entry that does not already have one
|
||||||
for(kwsys_stl::vector<String>::iterator vit1 = finalPath.begin();
|
for(kwsys_stl::vector<String>::iterator vit1 = finalPath.begin();
|
||||||
vit1 != finalPath.end(); ++vit1)
|
vit1 != finalPath.end(); ++vit1)
|
||||||
@ -3396,7 +3396,7 @@ kwsys_stl::string SystemTools::GetFilenamePath(const kwsys_stl::string& filename
|
|||||||
{
|
{
|
||||||
kwsys_stl::string fn = filename;
|
kwsys_stl::string fn = filename;
|
||||||
SystemTools::ConvertToUnixSlashes(fn);
|
SystemTools::ConvertToUnixSlashes(fn);
|
||||||
|
|
||||||
kwsys_stl::string::size_type slash_pos = fn.rfind("/");
|
kwsys_stl::string::size_type slash_pos = fn.rfind("/");
|
||||||
if(slash_pos != kwsys_stl::string::npos)
|
if(slash_pos != kwsys_stl::string::npos)
|
||||||
{
|
{
|
||||||
@ -3515,7 +3515,7 @@ SystemTools::GetFilenameWithoutLastExtension(const kwsys_stl::string& filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SystemTools::FileHasSignature(const char *filename,
|
bool SystemTools::FileHasSignature(const char *filename,
|
||||||
const char *signature,
|
const char *signature,
|
||||||
long offset)
|
long offset)
|
||||||
{
|
{
|
||||||
if (!filename || !signature)
|
if (!filename || !signature)
|
||||||
@ -3547,9 +3547,9 @@ bool SystemTools::FileHasSignature(const char *filename,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemTools::FileTypeEnum
|
SystemTools::FileTypeEnum
|
||||||
SystemTools::DetectFileType(const char *filename,
|
SystemTools::DetectFileType(const char *filename,
|
||||||
unsigned long length,
|
unsigned long length,
|
||||||
double percent_bin)
|
double percent_bin)
|
||||||
{
|
{
|
||||||
if (!filename || percent_bin < 0)
|
if (!filename || percent_bin < 0)
|
||||||
@ -3577,13 +3577,13 @@ SystemTools::DetectFileType(const char *filename,
|
|||||||
// Loop over contents and count
|
// Loop over contents and count
|
||||||
|
|
||||||
size_t text_count = 0;
|
size_t text_count = 0;
|
||||||
|
|
||||||
const unsigned char *ptr = buffer;
|
const unsigned char *ptr = buffer;
|
||||||
const unsigned char *buffer_end = buffer + read_length;
|
const unsigned char *buffer_end = buffer + read_length;
|
||||||
|
|
||||||
while (ptr != buffer_end)
|
while (ptr != buffer_end)
|
||||||
{
|
{
|
||||||
if ((*ptr >= 0x20 && *ptr <= 0x7F) ||
|
if ((*ptr >= 0x20 && *ptr <= 0x7F) ||
|
||||||
*ptr == '\n' ||
|
*ptr == '\n' ||
|
||||||
*ptr == '\r' ||
|
*ptr == '\r' ||
|
||||||
*ptr == '\t')
|
*ptr == '\t')
|
||||||
@ -3595,7 +3595,7 @@ SystemTools::DetectFileType(const char *filename,
|
|||||||
|
|
||||||
delete [] buffer;
|
delete [] buffer;
|
||||||
|
|
||||||
double current_percent_bin =
|
double current_percent_bin =
|
||||||
(static_cast<double>(read_length - text_count) /
|
(static_cast<double>(read_length - text_count) /
|
||||||
static_cast<double>(read_length));
|
static_cast<double>(read_length));
|
||||||
|
|
||||||
@ -3607,8 +3607,8 @@ SystemTools::DetectFileType(const char *filename,
|
|||||||
return SystemTools::FileTypeText;
|
return SystemTools::FileTypeText;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemTools::LocateFileInDir(const char *filename,
|
bool SystemTools::LocateFileInDir(const char *filename,
|
||||||
const char *dir,
|
const char *dir,
|
||||||
kwsys_stl::string& filename_found,
|
kwsys_stl::string& filename_found,
|
||||||
int try_filename_dirs)
|
int try_filename_dirs)
|
||||||
{
|
{
|
||||||
@ -3621,7 +3621,7 @@ bool SystemTools::LocateFileInDir(const char *filename,
|
|||||||
|
|
||||||
kwsys_stl::string filename_base = SystemTools::GetFilenameName(filename);
|
kwsys_stl::string filename_base = SystemTools::GetFilenameName(filename);
|
||||||
|
|
||||||
// Check if 'dir' is really a directory
|
// Check if 'dir' is really a directory
|
||||||
// If win32 and matches something like C:, accept it as a dir
|
// If win32 and matches something like C:, accept it as a dir
|
||||||
|
|
||||||
kwsys_stl::string real_dir;
|
kwsys_stl::string real_dir;
|
||||||
@ -3645,7 +3645,7 @@ bool SystemTools::LocateFileInDir(const char *filename,
|
|||||||
if (filename_base.size() && dir)
|
if (filename_base.size() && dir)
|
||||||
{
|
{
|
||||||
size_t dir_len = strlen(dir);
|
size_t dir_len = strlen(dir);
|
||||||
int need_slash =
|
int need_slash =
|
||||||
(dir_len && dir[dir_len - 1] != '/' && dir[dir_len - 1] != '\\');
|
(dir_len && dir[dir_len - 1] != '/' && dir[dir_len - 1] != '\\');
|
||||||
|
|
||||||
kwsys_stl::string temp = dir;
|
kwsys_stl::string temp = dir;
|
||||||
@ -3676,7 +3676,7 @@ bool SystemTools::LocateFileInDir(const char *filename,
|
|||||||
filename_dir = SystemTools::GetFilenamePath(filename_dir);
|
filename_dir = SystemTools::GetFilenamePath(filename_dir);
|
||||||
filename_dir_base = SystemTools::GetFilenameName(filename_dir);
|
filename_dir_base = SystemTools::GetFilenameName(filename_dir);
|
||||||
#if defined( _WIN32 )
|
#if defined( _WIN32 )
|
||||||
if (!filename_dir_base.size() ||
|
if (!filename_dir_base.size() ||
|
||||||
filename_dir_base[filename_dir_base.size() - 1] == ':')
|
filename_dir_base[filename_dir_base.size() - 1] == ':')
|
||||||
#else
|
#else
|
||||||
if (!filename_dir_base.size())
|
if (!filename_dir_base.size())
|
||||||
@ -3700,7 +3700,7 @@ bool SystemTools::LocateFileInDir(const char *filename,
|
|||||||
} while (!res && filename_dir_base.size());
|
} while (!res && filename_dir_base.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3746,12 +3746,12 @@ bool SystemTools::FileIsFullPath(const char* in_name)
|
|||||||
|
|
||||||
bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath)
|
bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath)
|
||||||
{
|
{
|
||||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||||
const int size = int(strlen(path)) +1; // size of return
|
const int size = int(strlen(path)) +1; // size of return
|
||||||
char *buffer = new char[size]; // create a buffer
|
char *buffer = new char[size]; // create a buffer
|
||||||
char *tempPath = new char[size]; // create a buffer
|
char *tempPath = new char[size]; // create a buffer
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// if the path passed in has quotes around it, first remove the quotes
|
// if the path passed in has quotes around it, first remove the quotes
|
||||||
if (path[0] == '"' && path[strlen(path)-1] == '"')
|
if (path[0] == '"' && path[strlen(path)-1] == '"')
|
||||||
{
|
{
|
||||||
@ -3762,7 +3762,7 @@ bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath)
|
|||||||
{
|
{
|
||||||
strcpy(tempPath,path);
|
strcpy(tempPath,path);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
ret = GetShortPathName(tempPath, buffer, size);
|
ret = GetShortPathName(tempPath, buffer, size);
|
||||||
|
|
||||||
@ -3785,7 +3785,7 @@ bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTools::SplitProgramFromArgs(const char* path,
|
void SystemTools::SplitProgramFromArgs(const char* path,
|
||||||
kwsys_stl::string& program, kwsys_stl::string& args)
|
kwsys_stl::string& program, kwsys_stl::string& args)
|
||||||
{
|
{
|
||||||
// see if this is a full path to a program
|
// see if this is a full path to a program
|
||||||
@ -3797,7 +3797,7 @@ void SystemTools::SplitProgramFromArgs(const char* path,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Try to find the program in the path, note the program
|
// Try to find the program in the path, note the program
|
||||||
// may have spaces in its name so we have to look for it
|
// may have spaces in its name so we have to look for it
|
||||||
kwsys_stl::vector<kwsys_stl::string> e;
|
kwsys_stl::vector<kwsys_stl::string> e;
|
||||||
kwsys_stl::string findProg = SystemTools::FindProgram(path, e);
|
kwsys_stl::string findProg = SystemTools::FindProgram(path, e);
|
||||||
if(findProg.size())
|
if(findProg.size())
|
||||||
@ -3828,7 +3828,7 @@ void SystemTools::SplitProgramFromArgs(const char* path,
|
|||||||
args = dir.substr(spacePos, dir.size()-spacePos);
|
args = dir.substr(spacePos, dir.size()-spacePos);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Now try and find the the program in the path
|
// Now try and find the the program in the path
|
||||||
findProg = SystemTools::FindProgram(tryProg.c_str(), e);
|
findProg = SystemTools::FindProgram(tryProg.c_str(), e);
|
||||||
if(findProg.size())
|
if(findProg.size())
|
||||||
{
|
{
|
||||||
@ -4203,23 +4203,23 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
if (!bOsVersionInfoEx)
|
if (!bOsVersionInfoEx)
|
||||||
{
|
{
|
||||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
if (!GetVersionEx((OSVERSIONINFO *)&osvi))
|
if (!GetVersionEx((OSVERSIONINFO *)&osvi))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (osvi.dwPlatformId)
|
switch (osvi.dwPlatformId)
|
||||||
{
|
{
|
||||||
// Test for the Windows NT product family.
|
// Test for the Windows NT product family.
|
||||||
|
|
||||||
case VER_PLATFORM_WIN32_NT:
|
case VER_PLATFORM_WIN32_NT:
|
||||||
|
|
||||||
// Test for the specific product family.
|
// Test for the specific product family.
|
||||||
|
|
||||||
if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0)
|
if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0)
|
||||||
{
|
{
|
||||||
#if (_MSC_VER >= 1300)
|
#if (_MSC_VER >= 1300)
|
||||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
if (osvi.wProductType == VER_NT_WORKSTATION)
|
||||||
{
|
{
|
||||||
res += "Microsoft Windows Vista";
|
res += "Microsoft Windows Vista";
|
||||||
@ -4259,7 +4259,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
{
|
{
|
||||||
// Test for the workstation type.
|
// Test for the workstation type.
|
||||||
|
|
||||||
#if (_MSC_VER >= 1300)
|
#if (_MSC_VER >= 1300)
|
||||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
if (osvi.wProductType == VER_NT_WORKSTATION)
|
||||||
{
|
{
|
||||||
if (osvi.dwMajorVersion == 4)
|
if (osvi.dwMajorVersion == 4)
|
||||||
@ -4278,7 +4278,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for the server type.
|
// Test for the server type.
|
||||||
|
|
||||||
else if (osvi.wProductType == VER_NT_SERVER)
|
else if (osvi.wProductType == VER_NT_SERVER)
|
||||||
@ -4302,7 +4302,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
res += " Standard Edition";
|
res += " Standard Edition";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
|
else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
|
||||||
{
|
{
|
||||||
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
|
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
|
||||||
@ -4319,7 +4319,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (osvi.dwMajorVersion <= 4) // Windows NT 4.0
|
else if (osvi.dwMajorVersion <= 4) // Windows NT 4.0
|
||||||
{
|
{
|
||||||
if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
|
if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
|
||||||
{
|
{
|
||||||
@ -4336,7 +4336,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
|
|
||||||
// Test for specific product on Windows NT 4.0 SP5 and earlier
|
// Test for specific product on Windows NT 4.0 SP5 and earlier
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
#define BUFSIZE 80
|
#define BUFSIZE 80
|
||||||
@ -4386,7 +4386,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
|
|
||||||
// Display service pack (if any) and build number.
|
// Display service pack (if any) and build number.
|
||||||
|
|
||||||
if (osvi.dwMajorVersion == 4 &&
|
if (osvi.dwMajorVersion == 4 &&
|
||||||
lstrcmpi(osvi.szCSDVersion, "Service Pack 6") == 0)
|
lstrcmpi(osvi.szCSDVersion, "Service Pack 6") == 0)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
@ -4415,7 +4415,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
res += buffer;
|
res += buffer;
|
||||||
res += ")";
|
res += ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
else // Windows NT 3.51 and earlier or Windows 2000 and later
|
else // Windows NT 3.51 and earlier or Windows 2000 and later
|
||||||
@ -4455,11 +4455,11 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
|
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
|
||||||
{
|
{
|
||||||
res += "Microsoft Windows Millennium Edition";
|
res += "Microsoft Windows Millennium Edition";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VER_PLATFORM_WIN32s:
|
case VER_PLATFORM_WIN32s:
|
||||||
|
|
||||||
res += "Microsoft Win32s";
|
res += "Microsoft Win32s";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4469,7 +4469,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
bool SystemTools::ParseURLProtocol( const kwsys_stl::string& URL,
|
bool SystemTools::ParseURLProtocol( const kwsys_stl::string& URL,
|
||||||
kwsys_stl::string& protocol,
|
kwsys_stl::string& protocol,
|
||||||
kwsys_stl::string& dataglom )
|
kwsys_stl::string& dataglom )
|
||||||
{
|
{
|
||||||
@ -4487,12 +4487,12 @@ bool SystemTools::ParseURLProtocol( const kwsys_stl::string& URL,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
bool SystemTools::ParseURL( const kwsys_stl::string& URL,
|
bool SystemTools::ParseURL( const kwsys_stl::string& URL,
|
||||||
kwsys_stl::string& protocol,
|
kwsys_stl::string& protocol,
|
||||||
kwsys_stl::string& username,
|
kwsys_stl::string& username,
|
||||||
kwsys_stl::string& password,
|
kwsys_stl::string& password,
|
||||||
kwsys_stl::string& hostname,
|
kwsys_stl::string& hostname,
|
||||||
kwsys_stl::string& dataport,
|
kwsys_stl::string& dataport,
|
||||||
kwsys_stl::string& database )
|
kwsys_stl::string& database )
|
||||||
{
|
{
|
||||||
kwsys::RegularExpression urlRe( VTK_URL_REGEX );
|
kwsys::RegularExpression urlRe( VTK_URL_REGEX );
|
||||||
@ -4515,7 +4515,7 @@ bool SystemTools::ParseURL( const kwsys_stl::string& URL,
|
|||||||
hostname = urlRe.match( 6 );
|
hostname = urlRe.match( 6 );
|
||||||
dataport = urlRe.match( 8 );
|
dataport = urlRe.match( 8 );
|
||||||
database = urlRe.match( 9 );
|
database = urlRe.match( 9 );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user