Commit d3a9692e authored by Bill Hoffman's avatar Bill Hoffman
Browse files

ENH: check in new find stuff

parent c1696cf2
......@@ -267,6 +267,7 @@ bool Registry::DeleteValue(const char *subkey, const char *key)
if ( !this->Open(this->GetTopLevel(), subkey,
Registry::READWRITE) )
{
std::cerr << "Failed to open\n";
return res;
}
open = true;
......
......@@ -1923,21 +1923,35 @@ kwsys_stl::string SystemTools::FindProgram(
{
return "";
}
std::string ext = SystemTools::GetExecutableExtension();
if(ext.size())
{
unsigned int len = strlen(name);
if(len > ext.size())
{
if(strcmp(name+(len-ext.size()), ext.c_str()) == 0)
{
ext = ""; // name already has Executable extension
}
}
}
// See if the executable exists as written.
if(SystemTools::FileExists(name) &&
!SystemTools::FileIsDirectory(name))
{
return SystemTools::CollapseFullPath(name);
}
kwsys_stl::string tryPath = name;
tryPath += SystemTools::GetExecutableExtension();
if(SystemTools::FileExists(tryPath.c_str()) &&
!SystemTools::FileIsDirectory(tryPath.c_str()))
if(ext.size())
{
return SystemTools::CollapseFullPath(tryPath.c_str());
kwsys_stl::string tryPath = name;
tryPath += ext;
if(SystemTools::FileExists(tryPath.c_str()) &&
!SystemTools::FileIsDirectory(tryPath.c_str()))
{
return SystemTools::CollapseFullPath(tryPath.c_str());
}
}
kwsys_stl::vector<kwsys_stl::string> path;
SystemTools::GetPath(path, "CMAKE_PROGRAM_PATH");
// Add the system search path to our path.
if (!no_system_path)
{
......@@ -1954,9 +1968,10 @@ kwsys_stl::string SystemTools::FindProgram(
p != path.end(); ++p)
{
#ifdef _WIN32
// Remove double quotes from the path on windows
SystemTools::ReplaceString(*p, "\"", "");
#endif
tryPath = *p;
kwsys_stl::string tryPath = *p;
tryPath += "/";
tryPath += name;
if(SystemTools::FileExists(tryPath.c_str()) &&
......@@ -1965,22 +1980,35 @@ kwsys_stl::string SystemTools::FindProgram(
return SystemTools::CollapseFullPath(tryPath.c_str());
}
#ifdef _WIN32
tryPath += ".com";
if(SystemTools::FileExists(tryPath.c_str()) &&
!SystemTools::FileIsDirectory(tryPath.c_str()))
// on windows try .com before .exe
if(ext.size() == 0)
{
return SystemTools::CollapseFullPath(tryPath.c_str());
SystemTools::ReplaceString(tryPath, ".exe", ".com");
SystemTools::ReplaceString(tryPath, ".EXE", ".com");
}
else
{
tryPath += ".com";
}
tryPath = *p;
tryPath += "/";
tryPath += name;
#endif
tryPath += SystemTools::GetExecutableExtension();
if(SystemTools::FileExists(tryPath.c_str()) &&
!SystemTools::FileIsDirectory(tryPath.c_str()))
{
return SystemTools::CollapseFullPath(tryPath.c_str());
}
#endif
// now try to add ext if it is different than name
if(ext.size())
{
tryPath = *p;
tryPath += "/";
tryPath += name;
tryPath += ext;
if(SystemTools::FileExists(tryPath.c_str()) &&
!SystemTools::FileIsDirectory(tryPath.c_str()))
{
return SystemTools::CollapseFullPath(tryPath.c_str());
}
}
}
// Couldn't find the program.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment