summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2000-08-29 19:26:29 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2000-08-29 19:26:29 (GMT)
commit1f42f521cea8b953f4ad7ef5ca0d4c6d49c42a88 (patch)
treea7b88a2e4397167c0d6c72c9cf0fcf8f91dcd024 /Source/cmSystemTools.cxx
parentd6bdba1096f36268e414f32829e22159e983031a (diff)
downloadCMake-1f42f521cea8b953f4ad7ef5ca0d4c6d49c42a88.zip
CMake-1f42f521cea8b953f4ad7ef5ca0d4c6d49c42a88.tar.gz
CMake-1f42f521cea8b953f4ad7ef5ca0d4c6d49c42a88.tar.bz2
NEW: move from tools and config to create CMake
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx52
1 files changed, 52 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
new file mode 100644
index 0000000..4efb05d
--- /dev/null
+++ b/Source/cmSystemTools.cxx
@@ -0,0 +1,52 @@
+#include "cmSystemTools.h"
+#include <direct.h>
+#include "errno.h"
+#include <windows.h>
+
+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(':');
+ if(pos == std::string::npos)
+ {
+ pos = 0;
+ }
+ while((pos = dir.find('/', pos)) != std::string::npos)
+ {
+ std::string topdir = dir.substr(0, pos);
+ _mkdir(topdir.c_str());
+ pos++;
+ }
+ if(_mkdir(path) != 0)
+ {
+ // if it is some other error besides directory exists
+ // then return false
+ if(errno != EEXIST)
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+void cmSystemTools::ReplaceString(std::string& source,
+ const char* replace,
+ const char* with)
+{
+ std::string line = source;
+ size_t start = line.find(replace);
+ while(start != std::string::npos)
+ {
+ source = line.substr(0, start);
+ source += with;
+ source += line.substr(start + strlen(replace));
+ start = line.find(replace, start + strlen(replace) );
+ }
+}