search_path.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2006, 2007 Julio M. Merino Vidal
  2. // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
  3. // Copyright (c) 2009 Boris Schaeling
  4. // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
  5. // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. /**
  10. * \file boost/process/search_path.hpp
  11. *
  12. * Defines a function to search for an executable in path.
  13. */
  14. #ifndef BOOST_PROCESS_SEARCH_PATH_HPP
  15. #define BOOST_PROCESS_SEARCH_PATH_HPP
  16. #include <boost/process/detail/config.hpp>
  17. #include <boost/process/environment.hpp>
  18. #if defined(BOOST_POSIX_API)
  19. #include <boost/process/detail/posix/search_path.hpp>
  20. #elif defined(BOOST_WINDOWS_API)
  21. #include <boost/process/detail/windows/search_path.hpp>
  22. #endif
  23. namespace boost { namespace process {
  24. /**
  25. * Searches for an executable in path.
  26. *
  27. * filename must be a basename including the file extension.
  28. * It must not include any directory separators (like a slash).
  29. * On Windows the file extension may be omitted. The function
  30. * will then try the various file extensions for executables on
  31. * Windows to find filename.
  32. *
  33. * \param filename The base of the filename to find
  34. *
  35. * \param path the set of paths to search, defaults to the "PATH" environment variable.
  36. *
  37. * \returns the absolute path to the executable filename or an
  38. * empty string if filename isn't found
  39. */
  40. inline boost::filesystem::path search_path(const boost::filesystem::path &filename,
  41. const std::vector<boost::filesystem::path> path = ::boost::this_process::path())
  42. {
  43. return ::boost::process::detail::api::search_path(filename, path);
  44. }
  45. }}
  46. #endif