diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2006-04-13 15:00:52 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2006-04-13 15:00:52 (GMT) |
commit | cae4e6b37a6ff7caf0748f2702fb503a9c95dcc8 (patch) | |
tree | 51115b16145313311c88cfd50409672c5f2b335e /Source/kwsys | |
parent | b323c3f51cc4caf7f8c26f86ba3dd4a08e964c4b (diff) | |
download | CMake-cae4e6b37a6ff7caf0748f2702fb503a9c95dcc8.zip CMake-cae4e6b37a6ff7caf0748f2702fb503a9c95dcc8.tar.gz CMake-cae4e6b37a6ff7caf0748f2702fb503a9c95dcc8.tar.bz2 |
ENH: add patch for finding applications on OSX
Diffstat (limited to 'Source/kwsys')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 55 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.hxx.in | 23 |
2 files changed, 70 insertions, 8 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 0e77dbe..b404914 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1877,13 +1877,17 @@ size_t SystemTools::GetMaximumFilePathLength() * found. Otherwise, the empty string is returned. */ kwsys_stl::string SystemTools -::FindFile(const char* name, - const kwsys_stl::vector<kwsys_stl::string>& userPaths) +::FindName(const char* name, + const kwsys_stl::vector<kwsys_stl::string>& userPaths, + bool no_system_path) { // Add the system search path to our path first kwsys_stl::vector<kwsys_stl::string> path; - SystemTools::GetPath(path, "CMAKE_FILE_PATH"); - SystemTools::GetPath(path); + if (!no_system_path) + { + SystemTools::GetPath(path, "CMAKE_FILE_PATH"); + SystemTools::GetPath(path); + } // now add the additional paths for(kwsys_stl::vector<kwsys_stl::string>::const_iterator i = userPaths.begin(); i != userPaths.end(); ++i) @@ -1898,10 +1902,9 @@ kwsys_stl::string SystemTools tryPath = *p; tryPath += "/"; tryPath += name; - if(SystemTools::FileExists(tryPath.c_str()) && - !SystemTools::FileIsDirectory(tryPath.c_str())) + if(SystemTools::FileExists(tryPath.c_str())) { - return SystemTools::CollapseFullPath(tryPath.c_str()); + return tryPath; } } // Couldn't find the file. @@ -1909,6 +1912,44 @@ kwsys_stl::string SystemTools } /** + * Find the file the given name. Searches the given path and then + * the system search path. Returns the full path to the file if it is + * found. Otherwise, the empty string is returned. + */ +kwsys_stl::string SystemTools +::FindFile(const char* name, + const kwsys_stl::vector<kwsys_stl::string>& userPaths, + bool no_system_path) +{ + kwsys_stl::string tryPath = SystemTools::FindName(name, userPaths, no_system_path); + if(tryPath != "" && !SystemTools::FileIsDirectory(tryPath.c_str())) + { + return SystemTools::CollapseFullPath(tryPath.c_str()); + } + // Couldn't find the file. + return ""; +} + +/** + * Find the directory the given name. Searches the given path and then + * the system search path. Returns the full path to the directory if it is + * found. Otherwise, the empty string is returned. + */ +kwsys_stl::string SystemTools +::FindDirectory(const char* name, + const kwsys_stl::vector<kwsys_stl::string>& userPaths, + bool no_system_path) +{ + kwsys_stl::string tryPath = SystemTools::FindName(name, userPaths, no_system_path); + if(tryPath != "" && SystemTools::FileIsDirectory(tryPath.c_str())) + { + return SystemTools::CollapseFullPath(tryPath.c_str()); + } + // Couldn't find the file. + return ""; +} + +/** * Find the executable with the given name. Searches the given path and then * the system search path. Returns the full path to the executable if it is * found. Otherwise, the empty string is returned. diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index f0afa36..af26444 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -495,7 +495,17 @@ public: static kwsys_stl::string FindFile( const char* name, const kwsys_stl::vector<kwsys_stl::string>& path = - kwsys_stl::vector<kwsys_stl::string>()); + kwsys_stl::vector<kwsys_stl::string>(), + bool no_system_path = false); + + /** + * Find a directory in the system PATH, with optional extra paths + */ + static kwsys_stl::string FindDirectory( + const char* name, + const kwsys_stl::vector<kwsys_stl::string>& path = + kwsys_stl::vector<kwsys_stl::string>(), + bool no_system_path = false); /** * Find an executable in the system PATH, with optional extra paths @@ -763,6 +773,17 @@ private: } /** + * Find a filename (file or directory) in the system PATH, with + * optional extra paths. + */ + static kwsys_stl::string FindName( + const char* name, + const kwsys_stl::vector<kwsys_stl::string>& path = + kwsys_stl::vector<kwsys_stl::string>(), + bool no_system_path = false); + + + /** * Path translation table from dir to refdir * Each time 'dir' will be found it will be replace by 'refdir' */ |