summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/SystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-05-13 18:55:35 (GMT)
committerBrad King <brad.king@kitware.com>2014-05-13 18:55:35 (GMT)
commit7fa16df4d7ce963dda98a6c5d54f528db7a29037 (patch)
tree3ed99c648b9c58251a0773356ed646905b23de1b /Source/kwsys/SystemTools.cxx
parent96e9eb1766261605ebc97009d6ace20214eaa9a4 (diff)
parent7762c57405d3b0daefc484a5e07bc24e04701615 (diff)
downloadCMake-7fa16df4d7ce963dda98a6c5d54f528db7a29037.zip
CMake-7fa16df4d7ce963dda98a6c5d54f528db7a29037.tar.gz
CMake-7fa16df4d7ce963dda98a6c5d54f528db7a29037.tar.bz2
Merge branch 'upstream-kwsys' into update-kwsys
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r--Source/kwsys/SystemTools.cxx214
1 files changed, 107 insertions, 107 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 32e79e6..a2681c1 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -627,7 +627,7 @@ bool SystemTools::MakeDirectory(const char* path)
return SystemTools::FileIsDirectory(path);
}
kwsys_stl::string dir = path;
- if(dir.size() == 0)
+ if(dir.empty())
{
return false;
}
@@ -1262,7 +1262,7 @@ bool SystemTools::FileTimeCompare(const char* f1, const char* f2,
kwsys_stl::string SystemTools::Capitalized(const kwsys_stl::string& s)
{
kwsys_stl::string n;
- if(s.size() == 0)
+ if(s.empty())
{
return n;
}
@@ -1322,7 +1322,7 @@ kwsys_stl::string SystemTools::AddSpaceBetweenCapitalizedWords(
const kwsys_stl::string& s)
{
kwsys_stl::string n;
- if (s.size())
+ if (!s.empty())
{
n.reserve(s.size());
n += s[0];
@@ -1815,12 +1815,13 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path)
// remove trailing slash if the path is more than
// a single /
pathCString = path.c_str();
- if(path.size() > 1 && *(pathCString+(path.size()-1)) == '/')
+ size_t size = path.size();
+ if(size > 1 && *path.rbegin() == '/')
{
// if it is c:/ then do not remove the trailing slash
- if(!((path.size() == 3 && pathCString[1] == ':')))
+ if(!((size == 3 && pathCString[1] == ':')))
{
- path = path.substr(0, path.size()-1);
+ path.resize(size - 1);
}
}
}
@@ -2500,7 +2501,7 @@ kwsys_stl::string SystemTools
i != path.end(); ++i)
{
kwsys_stl::string& p = *i;
- if(p.empty() || p[p.size()-1] != '/')
+ if(p.empty() || *p.rbegin() != '/')
{
p += "/";
}
@@ -2535,7 +2536,7 @@ kwsys_stl::string SystemTools
kwsys_stl::string tryPath = SystemTools::FindName(name, userPaths, no_system_path);
if(tryPath != "" && !SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
// Couldn't find the file.
return "";
@@ -2554,7 +2555,7 @@ kwsys_stl::string SystemTools
kwsys_stl::string tryPath = SystemTools::FindName(name, userPaths, no_system_path);
if(tryPath != "" && SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
// Couldn't find the file.
return "";
@@ -2594,18 +2595,15 @@ kwsys_stl::string SystemTools::FindProgram(
kwsys_stl::string tryPath;
// first try with extensions if the os supports them
- if(extensions.size())
+ for(kwsys_stl::vector<kwsys_stl::string>::iterator i =
+ extensions.begin(); i != extensions.end(); ++i)
{
- for(kwsys_stl::vector<kwsys_stl::string>::iterator i =
- extensions.begin(); i != extensions.end(); ++i)
+ tryPath = name;
+ tryPath += *i;
+ if(SystemTools::FileExists(tryPath.c_str()) &&
+ !SystemTools::FileIsDirectory(tryPath.c_str()))
{
- tryPath = name;
- tryPath += *i;
- if(SystemTools::FileExists(tryPath.c_str()) &&
- !SystemTools::FileIsDirectory(tryPath.c_str()))
- {
- return SystemTools::CollapseFullPath(tryPath.c_str());
- }
+ return SystemTools::CollapseFullPath(tryPath);
}
}
// now try just the name
@@ -2613,7 +2611,7 @@ kwsys_stl::string SystemTools::FindProgram(
if(SystemTools::FileExists(tryPath.c_str()) &&
!SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
// now construct the path
kwsys_stl::vector<kwsys_stl::string> path;
@@ -2636,7 +2634,7 @@ kwsys_stl::string SystemTools::FindProgram(
i != path.end(); ++i)
{
kwsys_stl::string& p = *i;
- if(p.empty() || p[p.size()-1] != '/')
+ if(p.empty() || *p.rbegin() != '/')
{
p += "/";
}
@@ -2651,19 +2649,16 @@ kwsys_stl::string SystemTools::FindProgram(
SystemTools::ReplaceString(*p, "\"", "");
#endif
// first try with extensions
- if(extensions.size())
+ for(kwsys_stl::vector<kwsys_stl::string>::iterator ext
+ = extensions.begin(); ext != extensions.end(); ++ext)
{
- for(kwsys_stl::vector<kwsys_stl::string>::iterator ext
- = extensions.begin(); ext != extensions.end(); ++ext)
+ tryPath = *p;
+ tryPath += name;
+ tryPath += *ext;
+ if(SystemTools::FileExists(tryPath.c_str()) &&
+ !SystemTools::FileIsDirectory(tryPath.c_str()))
{
- tryPath = *p;
- tryPath += name;
- tryPath += *ext;
- if(SystemTools::FileExists(tryPath.c_str()) &&
- !SystemTools::FileIsDirectory(tryPath.c_str()))
- {
- return SystemTools::CollapseFullPath(tryPath.c_str());
- }
+ return SystemTools::CollapseFullPath(tryPath);
}
}
// now try it without them
@@ -2672,7 +2667,7 @@ kwsys_stl::string SystemTools::FindProgram(
if(SystemTools::FileExists(tryPath.c_str()) &&
!SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
}
// Couldn't find the program.
@@ -2732,7 +2727,7 @@ kwsys_stl::string SystemTools
i != path.end(); ++i)
{
kwsys_stl::string& p = *i;
- if(p.empty() || p[p.size()-1] != '/')
+ if(p.empty() || *p.rbegin() != '/')
{
p += "/";
}
@@ -2749,7 +2744,7 @@ kwsys_stl::string SystemTools
if(SystemTools::FileExists(tryPath.c_str())
&& SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
#endif
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
@@ -2759,7 +2754,7 @@ kwsys_stl::string SystemTools
if(SystemTools::FileExists(tryPath.c_str())
&& !SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
#else
tryPath = *p;
@@ -2769,7 +2764,7 @@ kwsys_stl::string SystemTools
if(SystemTools::FileExists(tryPath.c_str())
&& !SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
tryPath = *p;
tryPath += "lib";
@@ -2778,7 +2773,7 @@ kwsys_stl::string SystemTools
if(SystemTools::FileExists(tryPath.c_str())
&& !SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
tryPath = *p;
tryPath += "lib";
@@ -2787,7 +2782,7 @@ kwsys_stl::string SystemTools
if(SystemTools::FileExists(tryPath.c_str())
&& !SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
tryPath = *p;
tryPath += "lib";
@@ -2796,7 +2791,7 @@ kwsys_stl::string SystemTools
if(SystemTools::FileExists(tryPath.c_str())
&& !SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
tryPath = *p;
tryPath += "lib";
@@ -2805,7 +2800,7 @@ kwsys_stl::string SystemTools
if(SystemTools::FileExists(tryPath.c_str())
&& !SystemTools::FileIsDirectory(tryPath.c_str()))
{
- return SystemTools::CollapseFullPath(tryPath.c_str());
+ return SystemTools::CollapseFullPath(tryPath);
}
#endif
}
@@ -2823,11 +2818,11 @@ kwsys_stl::string SystemTools::GetRealPath(const char* path)
bool SystemTools::FileIsDirectory(const char* name)
{
- size_t length = strlen(name);
- if (length == 0)
+ if (!*name)
{
return false;
}
+ size_t length = strlen(name);
// Remove any trailing slash from the name except in a root component.
char local_buffer[KWSYS_SYSTEMTOOLS_MAXPATH];
@@ -2940,7 +2935,7 @@ kwsys_stl::string SystemTools::GetCurrentWorkingDirectory(bool collapse)
}
if(collapse)
{
- return SystemTools::CollapseFullPath(path.c_str());
+ return SystemTools::CollapseFullPath(path);
}
return path;
}
@@ -3041,7 +3036,7 @@ bool SystemTools::FindProgramPath(const char* argv0,
kwsys_stl::vector<kwsys_stl::string>::iterator i;
for(i=failures.begin(); i != failures.end(); ++i)
{
- msg << " \"" << i->c_str() << "\"\n";
+ msg << " \"" << *i << "\"\n";
}
errorMsg = msg.str();
return false;
@@ -3051,12 +3046,12 @@ bool SystemTools::FindProgramPath(const char* argv0,
}
-kwsys_stl::string SystemTools::CollapseFullPath(const char* in_relative)
+kwsys_stl::string SystemTools::CollapseFullPath(const kwsys_stl::string& in_relative)
{
return SystemTools::CollapseFullPath(in_relative, 0);
}
-void SystemTools::AddTranslationPath(const char * a, const char * b)
+void SystemTools::AddTranslationPath(const kwsys_stl::string& a, const kwsys_stl::string& b)
{
kwsys_stl::string path_a = a;
kwsys_stl::string path_b = b;
@@ -3073,11 +3068,11 @@ void SystemTools::AddTranslationPath(const char * a, const char * b)
== kwsys_stl::string::npos )
{
// Before inserting make sure path ends with '/'
- if(path_a.size() && path_a[path_a.size() -1] != '/')
+ if(!path_a.empty() && *path_a.rbegin() != '/')
{
path_a += '/';
}
- if(path_b.size() && path_b[path_b.size() -1] != '/')
+ if(!path_b.empty() && *path_b.rbegin() != '/')
{
path_b += '/';
}
@@ -3090,11 +3085,11 @@ void SystemTools::AddTranslationPath(const char * a, const char * b)
}
}
-void SystemTools::AddKeepPath(const char* dir)
+void SystemTools::AddKeepPath(const kwsys_stl::string& dir)
{
kwsys_stl::string cdir;
Realpath(SystemTools::CollapseFullPath(dir).c_str(), cdir);
- SystemTools::AddTranslationPath(cdir.c_str(), dir);
+ SystemTools::AddTranslationPath(cdir, dir);
}
void SystemTools::CheckTranslationPath(kwsys_stl::string & path)
@@ -3135,24 +3130,26 @@ SystemToolsAppendComponents(
kwsys_stl::vector<kwsys_stl::string>::const_iterator first,
kwsys_stl::vector<kwsys_stl::string>::const_iterator last)
{
+ static const kwsys_stl::string up = "..";
+ static const kwsys_stl::string cur = ".";
for(kwsys_stl::vector<kwsys_stl::string>::const_iterator i = first;
i != last; ++i)
{
- if(*i == "..")
+ if(*i == up)
{
if(out_components.size() > 1)
{
- out_components.erase(out_components.end()-1, out_components.end());
+ out_components.resize(out_components.size()-1);
}
}
- else if(!(*i == ".") && !(*i == ""))
+ else if(!i->empty() && *i != cur)
{
out_components.push_back(*i);
}
}
}
-kwsys_stl::string SystemTools::CollapseFullPath(const char* in_path,
+kwsys_stl::string SystemTools::CollapseFullPath(const kwsys_stl::string& in_path,
const char* in_base)
{
// Collect the output path components.
@@ -3212,7 +3209,7 @@ kwsys_stl::string SystemTools::CollapseFullPath(const char* in_path,
// collapsed, so I am going to try to comment it out, and see what hits the
// fan, hopefully quickly.
// Commented out line below:
- //SystemTools::AddTranslationPath(newPath.c_str(), in_path);
+ //SystemTools::AddTranslationPath(newPath, in_path);
SystemTools::CheckTranslationPath(newPath);
#ifdef _WIN32
@@ -3277,7 +3274,7 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot
// path into the remote dir
for(unsigned int i = 0; i < localSplit.size(); ++i)
{
- if(localSplit[i].size())
+ if(!localSplit[i].empty())
{
finalPath.push_back("../");
}
@@ -3287,7 +3284,7 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot
for(kwsys_stl::vector<String>::iterator vit = remoteSplit.begin();
vit != remoteSplit.end(); ++vit)
{
- if(vit->size())
+ if(!vit->empty())
{
finalPath.push_back(*vit);
}
@@ -3298,7 +3295,7 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot
for(kwsys_stl::vector<String>::iterator vit1 = finalPath.begin();
vit1 != finalPath.end(); ++vit1)
{
- if(relativePath.size() && relativePath[relativePath.size()-1] != '/')
+ if(!relativePath.empty() && *relativePath.rbegin() != '/')
{
relativePath += "/";
}
@@ -3312,7 +3309,7 @@ static int GetCasePathName(const kwsys_stl::string & pathIn,
kwsys_stl::string & casePath)
{
kwsys_stl::vector<kwsys_stl::string> path_components;
- SystemTools::SplitPath(pathIn.c_str(), path_components);
+ SystemTools::SplitPath(pathIn, path_components);
if(path_components[0].empty()) // First component always exists.
{
// Relative paths cannot be converted.
@@ -3394,11 +3391,11 @@ kwsys_stl::string SystemTools::GetActualCaseForPath(const char* p)
}
//----------------------------------------------------------------------------
-const char* SystemTools::SplitPathRootComponent(const char* p,
+const char* SystemTools::SplitPathRootComponent(const std::string& p,
kwsys_stl::string* root)
{
// Identify the root component.
- const char* c = p;
+ const char* c = p.c_str();
if((c[0] == '/' && c[1] == '/') || (c[0] == '\\' && c[1] == '\\'))
{
// Network path.
@@ -3480,17 +3477,17 @@ const char* SystemTools::SplitPathRootComponent(const char* p,
}
//----------------------------------------------------------------------------
-void SystemTools::SplitPath(const char* p,
+void SystemTools::SplitPath(const std::string& p,
kwsys_stl::vector<kwsys_stl::string>& components,
bool expand_home_dir)
{
- const char* c = p;
+ const char* c;
components.clear();
// Identify the root component.
{
kwsys_stl::string root;
- c = SystemTools::SplitPathRootComponent(c, &root);
+ c = SystemTools::SplitPathRootComponent(p, &root);
// Expand home directory references if requested.
if(expand_home_dir && !root.empty() && root[0] == '~')
@@ -3520,12 +3517,12 @@ void SystemTools::SplitPath(const char* p,
}
}
#endif
- if(!homedir.empty() && (homedir[homedir.size()-1] == '/' ||
- homedir[homedir.size()-1] == '\\'))
+ if(!homedir.empty() && (*homedir.rbegin() == '/' ||
+ *homedir.rbegin() == '\\'))
{
- homedir = homedir.substr(0, homedir.size()-1);
+ homedir.resize(homedir.size() - 1);
}
- SystemTools::SplitPath(homedir.c_str(), components);
+ SystemTools::SplitPath(homedir, components);
}
else
{
@@ -3541,9 +3538,7 @@ void SystemTools::SplitPath(const char* p,
if(*last == '/' || *last == '\\')
{
// End of a component. Save it.
- components.push_back(
- kwsys_stl::string(first,static_cast<kwsys_stl::string::size_type>(
- last-first)));
+ components.push_back(kwsys_stl::string(first, last));
first = last+1;
}
}
@@ -3551,9 +3546,7 @@ void SystemTools::SplitPath(const char* p,
// Save the last component unless there were no components.
if(last != c)
{
- components.push_back(
- kwsys_stl::string(first,static_cast<kwsys_stl::string::size_type>(
- last-first)));
+ components.push_back(kwsys_stl::string(first, last));
}
}
@@ -3572,6 +3565,13 @@ SystemTools
{
// Construct result in a single string.
kwsys_stl::string result;
+ size_t len = 0;
+ kwsys_stl::vector<kwsys_stl::string>::const_iterator i;
+ for(i = first; i != last; ++i)
+ {
+ len += 1 + i->size();
+ }
+ result.reserve(len);
// The first two components do not add a slash.
if(first != last)
@@ -3595,18 +3595,18 @@ SystemTools
}
//----------------------------------------------------------------------------
-bool SystemTools::ComparePath(const char* c1, const char* c2)
+bool SystemTools::ComparePath(const kwsys_stl::string& c1, const kwsys_stl::string& c2)
{
#if defined(_WIN32) || defined(__APPLE__)
# ifdef _MSC_VER
- return _stricmp(c1, c2) == 0;
+ return _stricmp(c1.c_str(), c2.c_str()) == 0;
# elif defined(__APPLE__) || defined(__GNUC__)
- return strcasecmp(c1, c2) == 0;
+ return strcasecmp(c1.c_str(), c2.c_str()) == 0;
#else
- return SystemTools::Strucmp(c1, c2) == 0;
+ return SystemTools::Strucmp(c1.c_str(), c2.c_str()) == 0;
# endif
#else
- return strcmp(c1, c2) == 0;
+ return c1 == c2;
#endif
}
@@ -3680,7 +3680,7 @@ kwsys_stl::string SystemTools::GetFilenamePath(const kwsys_stl::string& filename
{
return ret + '/';
}
- if(ret.size() == 0)
+ if(ret.empty())
{
return "/";
}
@@ -3701,7 +3701,7 @@ kwsys_stl::string SystemTools::GetFilenameName(const kwsys_stl::string& filename
#if defined(_WIN32)
kwsys_stl::string::size_type slash_pos = filename.find_last_of("/\\");
#else
- kwsys_stl::string::size_type slash_pos = filename.find_last_of("/");
+ kwsys_stl::string::size_type slash_pos = filename.rfind('/');
#endif
if(slash_pos != kwsys_stl::string::npos)
{
@@ -3915,7 +3915,7 @@ bool SystemTools::LocateFileInDir(const char *filename,
// Try to find the file in 'dir'
bool res = false;
- if (filename_base.size() && dir)
+ if (!filename_base.empty() && dir)
{
size_t dir_len = strlen(dir);
int need_slash =
@@ -3949,10 +3949,10 @@ bool SystemTools::LocateFileInDir(const char *filename,
filename_dir = SystemTools::GetFilenamePath(filename_dir);
filename_dir_base = SystemTools::GetFilenameName(filename_dir);
#if defined( _WIN32 )
- if (!filename_dir_base.size() ||
- filename_dir_base[filename_dir_base.size() - 1] == ':')
+ if (filename_dir_base.empty() ||
+ *filename_dir_base.rbegin() == ':')
#else
- if (!filename_dir_base.size())
+ if (filename_dir_base.empty())
#endif
{
break;
@@ -3970,7 +3970,7 @@ bool SystemTools::LocateFileInDir(const char *filename,
res = SystemTools::LocateFileInDir(
filename_base.c_str(), temp.c_str(), filename_found, 0);
- } while (!res && filename_dir_base.size());
+ } while (!res && !filename_dir_base.empty());
}
}
@@ -3979,30 +3979,30 @@ bool SystemTools::LocateFileInDir(const char *filename,
bool SystemTools::FileIsFullPath(const char* in_name)
{
- kwsys_stl::string name = in_name;
+ size_t len = strlen(in_name);
#if defined(_WIN32) || defined(__CYGWIN__)
// On Windows, the name must be at least two characters long.
- if(name.length() < 2)
+ if(len < 2)
{
return false;
}
- if(name[1] == ':')
+ if(in_name[1] == ':')
{
return true;
}
- if(name[0] == '\\')
+ if(in_name[0] == '\\')
{
return true;
}
#else
// On UNIX, the name must be at least one character long.
- if(name.length() < 1)
+ if(len < 1)
{
return false;
}
#endif
#if !defined(_WIN32)
- if(name[0] == '~')
+ if(in_name[0] == '~')
{
return true;
}
@@ -4010,29 +4010,29 @@ bool SystemTools::FileIsFullPath(const char* in_name)
// On UNIX, the name must begin in a '/'.
// On Windows, if the name begins in a '/', then it is a full
// network path.
- if(name[0] == '/')
+ if(in_name[0] == '/')
{
return true;
}
return false;
}
-bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath)
+bool SystemTools::GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& shortPath)
{
#if defined(WIN32) && !defined(__CYGWIN__)
- const int size = int(strlen(path)) +1; // size of return
+ const int size = int(path.size()) +1; // size of return
char *tempPath = new char[size]; // create a buffer
DWORD ret;
// if the path passed in has quotes around it, first remove the quotes
- if (path[0] == '"' && path[strlen(path)-1] == '"')
+ if (!path.empty() && path[0] == '"' && *path.rbegin() == '"')
{
- strcpy(tempPath,path+1);
- tempPath[strlen(tempPath)-1] = '\0';
+ strcpy(tempPath,path.c_str()+1);
+ tempPath[size-2] = '\0';
}
else
{
- strcpy(tempPath,path);
+ strcpy(tempPath,path.c_str());
}
kwsys_stl::wstring wtempPath = Encoding::ToWide(tempPath);
@@ -4073,7 +4073,7 @@ void SystemTools::SplitProgramFromArgs(const char* path,
// may have spaces in its name so we have to look for it
kwsys_stl::vector<kwsys_stl::string> e;
kwsys_stl::string findProg = SystemTools::FindProgram(path, e);
- if(findProg.size())
+ if(!findProg.empty())
{
program = findProg;
args = "";
@@ -4103,7 +4103,7 @@ void SystemTools::SplitProgramFromArgs(const char* path,
}
// Now try and find the program in the path
findProg = SystemTools::FindProgram(tryProg.c_str(), e);
- if(findProg.size())
+ if(!findProg.empty())
{
program = findProg;
// remove trailing spaces from program
@@ -4344,9 +4344,9 @@ kwsys_stl::string SystemTools::GetParentDirectory(const char* fileOrDir)
return SystemTools::GetFilenamePath(fileOrDir);
}
-bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)
+bool SystemTools::IsSubDirectory(const kwsys_stl::string& cSubdir, const kwsys_stl::string& cDir)
{
- if(!*cDir)
+ if(cDir.empty())
{
return false;
}
@@ -4357,7 +4357,7 @@ bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)
if(subdir.size() > dir.size() && subdir[dir.size()] == '/')
{
std::string s = subdir.substr(0, dir.size());
- return SystemTools::ComparePath(s.c_str(), dir.c_str());
+ return SystemTools::ComparePath(s, dir);
}
return false;
}
@@ -4926,8 +4926,8 @@ void SystemTools::ClassInitialize()
// Add the translation to keep the logical path name.
if(!cwd_changed.empty() && !pwd_changed.empty())
{
- SystemTools::AddTranslationPath(cwd_changed.c_str(),
- pwd_changed.c_str());
+ SystemTools::AddTranslationPath(cwd_changed,
+ pwd_changed);
}
}
}