diff options
author | Sebastien Barre <sebastien.barre@kitware.com> | 2001-05-24 23:17:47 (GMT) |
---|---|---|
committer | Sebastien Barre <sebastien.barre@kitware.com> | 2001-05-24 23:17:47 (GMT) |
commit | d8354e65c90159e388b794d0b7bcd5ac539d3524 (patch) | |
tree | 127683543beb24c97cf71a854397d817c759ed53 /Source/cmSystemTools.cxx | |
parent | 296649209c861738640f016d26c281bd83ccb024 (diff) | |
download | CMake-d8354e65c90159e388b794d0b7bcd5ac539d3524.zip CMake-d8354e65c90159e388b794d0b7bcd5ac539d3524.tar.gz CMake-d8354e65c90159e388b794d0b7bcd5ac539d3524.tar.bz2 |
optimize ConvertToUnixSlashes a little bit, and use it in MakeDirectory (code was duplicated)
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3e9642f..f524750 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -126,14 +126,10 @@ const char* cmSystemTools::GetExecutableExtension() bool cmSystemTools::MakeDirectory(const char* path) { std::string dir = path; - // replace all of the \ with / - size_t pos = 0; - while((pos = dir.find('\\', pos)) != std::string::npos) - { - dir[pos] = '/'; - pos++; - } - pos = dir.find(':'); + + cmSystemTools::ConvertToUnixSlashes(dir); + + std::string::size_type pos = dir.find(':'); if(pos == std::string::npos) { pos = 0; @@ -334,11 +330,11 @@ std::string cmSystemTools::Capitalized(std::string& s) // convert windows slashes to unix slashes \ with / void cmSystemTools::ConvertToUnixSlashes(std::string& path) { - std::string::size_type pos = path.find('\\'); - while(pos != std::string::npos) + std::string::size_type pos = 0; + while((pos = path.find('\\', pos)) != std::string::npos) { path[pos] = '/'; - pos = path.find('\\'); + pos++; } // remove any trailing slash if(path[path.size()-1] == '/') @@ -892,9 +888,9 @@ void cmSystemTools::SplitProgramPath(const char* in_name, if(!cmSystemTools::FileIsDirectory(dir.c_str())) { std::string::size_type slashPos = dir.rfind("/"); - if(slashPos != std::string::npos) + if(slashPos != std::string::npos) { - file = dir.substr(slashPos+1) + file; + file = dir.substr(slashPos+1); dir = dir.substr(0, slashPos); } else |