diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2006-03-02 18:30:22 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2006-03-02 18:30:22 (GMT) |
commit | a5825cd11af3a6def49c9528e77f4394babff7de (patch) | |
tree | cf8f0ed84fc150bd0befa0b00937deb0cb1cec0a /Source/kwsys | |
parent | 2f78d874a75e8032b90997df3449040c941b1b5b (diff) | |
download | CMake-a5825cd11af3a6def49c9528e77f4394babff7de.zip CMake-a5825cd11af3a6def49c9528e77f4394babff7de.tar.gz CMake-a5825cd11af3a6def49c9528e77f4394babff7de.tar.bz2 |
ENH: check in new find stuff
Diffstat (limited to 'Source/kwsys')
-rw-r--r-- | Source/kwsys/Registry.cxx | 1 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 60 |
2 files changed, 45 insertions, 16 deletions
diff --git a/Source/kwsys/Registry.cxx b/Source/kwsys/Registry.cxx index 3c0be26..414b066 100644 --- a/Source/kwsys/Registry.cxx +++ b/Source/kwsys/Registry.cxx @@ -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; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index e30cc51..abc3cd1 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -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. |