summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-08-28 14:57:25 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-08-28 14:57:25 (GMT)
commitc7bd083549ab5ff7c14884dd6fd309ea9ccaa16b (patch)
tree221266788410d300793798901b6985f91d1001cd /Source/cmSystemTools.cxx
parent98b4ea2609793d57e0fe8ea68d7e8b97bb4802e4 (diff)
downloadCMake-c7bd083549ab5ff7c14884dd6fd309ea9ccaa16b.zip
CMake-c7bd083549ab5ff7c14884dd6fd309ea9ccaa16b.tar.gz
CMake-c7bd083549ab5ff7c14884dd6fd309ea9ccaa16b.tar.bz2
BUG: fix for broken apple mkdir and general clean up of MakeDirectory command
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx31
1 files changed, 21 insertions, 10 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 5020969..72ffca0 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -135,6 +135,10 @@ const char* cmSystemTools::GetExecutableExtension()
bool cmSystemTools::MakeDirectory(const char* path)
{
+ if(cmSystemTools::FileExists(path))
+ {
+ return true;
+ }
std::string dir = path;
cmSystemTools::ConvertToUnixSlashes(dir);
@@ -144,29 +148,36 @@ bool cmSystemTools::MakeDirectory(const char* path)
{
pos = 0;
}
+ std::string topdir;
while((pos = dir.find('/', pos)) != std::string::npos)
{
- std::string topdir = dir.substr(0, pos);
+ topdir = dir.substr(0, pos);
Mkdir(topdir.c_str());
pos++;
}
- if(Mkdir(path) != 0)
+ if(topdir[dir.size()] == '/')
+ {
+ topdir = dir.substr(0, dir.size());
+ }
+ else
+ {
+ topdir = dir;
+ }
+ if(Mkdir(topdir.c_str()) != 0)
{
// There is a bug in the Borland Run time library which makes MKDIR
// return EACCES when it should return EEXISTS
- #ifdef __BORLANDC__
- if( (errno != EEXIST) && (errno != EACCES) )
- {
- return false;
- }
- #else
// if it is some other error besides directory exists
// then return false
- if(errno != EEXIST)
+ if( (errno != EEXIST)
+#ifdef __BORLANDC__
+ && (errno != EACCES)
+#endif
+ )
{
+ cmSystemTools::Error("Faild to create directory:", path);
return false;
}
- #endif
}
return true;
}