ENH: Some tweaks, hacks and #ifdefs required to compile

cmake on Borland C++Builder
This commit is contained in:
John Biddiscombe 2001-06-05 17:41:16 -04:00
parent 729908bd4a
commit 46aa080edc
2 changed files with 44 additions and 3 deletions

View File

@ -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;

View File

@ -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);