BUG: Do not leave ../ in the full path to a source file. Using CollapseFullPath simplifies the code anyway.

This commit is contained in:
Brad King 2005-04-27 11:33:22 -04:00
parent cc2cd3bc41
commit 0ef2334a5f

View File

@ -31,27 +31,15 @@ void cmSourceFile::SetName(const char* name, const char* dir,
this->SetProperty("HEADER_FILE_ONLY","1"); this->SetProperty("HEADER_FILE_ONLY","1");
m_SourceNameWithoutLastExtension = ""; m_SourceNameWithoutLastExtension = "";
// Save the original name given.
m_SourceName = name; m_SourceName = name;
std::string pathname = dir; // Convert the name to a full path in case the given name is a
// relative path.
// the name might include the full path already, so std::string pathname = cmSystemTools::CollapseFullPath(name, dir);
// check for this case
if (name && (name[0] == '/' ||
(name[0] != '\0' && name[1] == ':')))
{
pathname = "";
}
if(pathname != "")
{
pathname += "/";
}
// First try and see whether the listed file can be found // First try and see whether the listed file can be found
// as is without extensions added on. // as is without extensions added on.
pathname += name;
std::string hname = pathname; std::string hname = pathname;
if(cmSystemTools::FileExists(hname.c_str())) if(cmSystemTools::FileExists(hname.c_str()))
{ {
@ -138,26 +126,19 @@ void cmSourceFile::SetName(const char* name, const char* dir,
errorMsg.c_str()); errorMsg.c_str());
} }
void cmSourceFile::SetName(const char* name, const char* dir, const char *ext, void cmSourceFile::SetName(const char* name, const char* dir, const char *ext,
bool hfo) bool hfo)
{ {
this->SetProperty("HEADER_FILE_ONLY",(hfo ? "1" : "0")); this->SetProperty("HEADER_FILE_ONLY",(hfo ? "1" : "0"));
m_SourceNameWithoutLastExtension = ""; m_SourceNameWithoutLastExtension = "";
m_SourceName = name; m_SourceName = name;
std::string pathname = dir; std::string fname = m_SourceName;
if(pathname != "")
{
pathname += "/";
}
pathname += m_SourceName;
if(ext && strlen(ext)) if(ext && strlen(ext))
{ {
pathname += "."; fname += ".";
pathname += ext; fname += ext;
} }
m_FullPath = pathname; m_FullPath = cmSystemTools::CollapseFullPath(fname.c_str(), dir);
m_SourceExtension = ext; m_SourceExtension = ext;
return; return;
} }