BUG: fix for broken apple mkdir and general clean up of MakeDirectory command

This commit is contained in:
Bill Hoffman 2001-08-28 10:57:25 -04:00
parent 98b4ea2609
commit c7bd083549
2 changed files with 48 additions and 21 deletions

View File

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

View File

@ -59,25 +59,41 @@ void cmUnixMakefileGenerator::GenerateMakefile()
if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
{
m_LibraryOutputPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
if(m_LibraryOutputPath.size() &&
m_LibraryOutputPath[m_LibraryOutputPath.size() -1] != '/')
if(m_LibraryOutputPath.size())
{
m_LibraryOutputPath += "/";
if(m_LibraryOutputPath[m_LibraryOutputPath.size() -1] != '/')
{
m_LibraryOutputPath += "/";
}
if(!cmSystemTools::MakeDirectory(m_LibraryOutputPath.c_str()))
{
cmSystemTools::Error("Error failed create "
"LIBRARY_OUTPUT_PATH directory:",
m_LibraryOutputPath.c_str());
}
m_Makefile->AddLinkDirectory(m_LibraryOutputPath.c_str());
}
cmSystemTools::MakeDirectory(m_LibraryOutputPath.c_str());
m_Makefile->AddLinkDirectory(m_LibraryOutputPath.c_str());
}
if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
{
m_ExecutableOutputPath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
if(m_ExecutableOutputPath.size() &&
m_ExecutableOutputPath[m_ExecutableOutputPath.size() -1] != '/')
m_ExecutableOutputPath =
m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
if(m_ExecutableOutputPath.size())
{
m_ExecutableOutputPath += "/";
if(m_ExecutableOutputPath[m_ExecutableOutputPath.size() -1] != '/')
{
m_ExecutableOutputPath += "/";
}
if(!cmSystemTools::MakeDirectory(m_ExecutableOutputPath.c_str()))
{
cmSystemTools::Error("Error failed to create "
"EXECUTABLE_OUTPUT_PATH directory:",
m_ExecutableOutputPath.c_str());
}
m_Makefile->AddLinkDirectory(m_ExecutableOutputPath.c_str());
}
cmSystemTools::MakeDirectory(m_ExecutableOutputPath.c_str());
m_Makefile->AddLinkDirectory(m_ExecutableOutputPath.c_str());
}
if(m_CacheOnly)
{