summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Biddiscombe <jbiddiscombe@skippingmouse.co.uk>2001-06-05 21:41:16 (GMT)
committerJohn Biddiscombe <jbiddiscombe@skippingmouse.co.uk>2001-06-05 21:41:16 (GMT)
commit46aa080edc059d96c0ef7ce9c2e31fa7173c63bd (patch)
tree390fbf793b3ced92f062726f97c328870a792a2a
parent729908bd4ab74c9ccab24d621514edd3fd0907c6 (diff)
downloadCMake-46aa080edc059d96c0ef7ce9c2e31fa7173c63bd.zip
CMake-46aa080edc059d96c0ef7ce9c2e31fa7173c63bd.tar.gz
CMake-46aa080edc059d96c0ef7ce9c2e31fa7173c63bd.tar.bz2
ENH: Some tweaks, hacks and #ifdefs required to compile
cmake on Borland C++Builder
-rw-r--r--Source/cmSystemTools.cxx39
-rw-r--r--Source/cmSystemTools.h8
2 files changed, 44 insertions, 3 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index a878e1f..dd1dc80 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -59,7 +59,11 @@ inline const char* Getcwd(char* buf, unsigned int len)
}
inline int Chdir(const char* dir)
{
+ #if defined(__BORLANDC__)
+ return chdir(dir);
+ #else
return _chdir(dir);
+ #endif
}
#else
#include <sys/types.h>
@@ -147,12 +151,21 @@ bool cmSystemTools::MakeDirectory(const char* path)
}
if(Mkdir(path) != 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)
{
return false;
}
+ #endif
}
return true;
}
@@ -329,7 +342,7 @@ std::string cmSystemTools::Capitalized(const std::string& s)
n[i] = tolower(s[i]);
}
return n;
-}
+}
// convert windows slashes to unix slashes \ with /
@@ -348,8 +361,30 @@ void cmSystemTools::ConvertToUnixSlashes(std::string& path)
}
}
+// convert windows slashes to unix slashes \ with /
+void cmSystemTools::CleanUpWindowsSlashes(std::string& path)
+{
+ std::string::size_type pos = 0;
+ while((pos = path.find('/', pos)) != std::string::npos)
+ {
+ path[pos] = '\\';
+ pos++;
+ }
+ // remove any trailing slash
+ if(path[path.size()-1] == '\\')
+ {
+ path = path.substr(0, path.size()-1);
+ }
+ // remove any duplicate // slashes
+ pos = 0;
+ while((pos = path.find("\\\\", pos)) != std::string::npos)
+ {
+ path.erase(pos, 1);
+ }
+}
+
-int cmSystemTools::Grep(const char* dir, const char* file,
+int cmSystemTools::Grep(const char* dir, const char* file,
const char* expression)
{
std::string path = dir;
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index a0f672f..749b2e8 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -88,7 +88,13 @@ public:
* Replace Windows file system slashes with Unix-style slashes.
*/
static void ConvertToUnixSlashes(std::string& path);
-
+
+ /**
+ * Replace Unix file system slashes with Windows-style slashes and
+ * remove any duplicate slashes to clean the path.
+ */
+ static void CleanUpWindowsSlashes(std::string& path);
+
///! Return true if a file exists in the current directory.
static bool FileExists(const char* filename);