cwd.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2022 Klemens D. Morgenstern
  2. // Copyright (c) 2022 Samuel Venable
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_PROCESS_V2_CWD_HPP
  7. #define BOOST_PROCESS_V2_CWD_HPP
  8. #include <boost/process/v2/detail/config.hpp>
  9. #include <boost/process/v2/detail/throw_error.hpp>
  10. #include <boost/process/v2/pid.hpp>
  11. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  12. namespace ext {
  13. #if defined(BOOST_PROCESS_V2_WINDOWS)
  14. BOOST_PROCESS_V2_DECL filesystem::path cwd(HANDLE handle, error_code & ec);
  15. BOOST_PROCESS_V2_DECL filesystem::path cwd(HANDLE handle);
  16. #endif
  17. /// @{
  18. /// Obtain the current path of another process
  19. BOOST_PROCESS_V2_DECL filesystem::path cwd(pid_type pid, error_code & ec);
  20. BOOST_PROCESS_V2_DECL filesystem::path cwd(pid_type pid);
  21. template<typename Executor>
  22. BOOST_PROCESS_V2_DECL filesystem::path cwd(basic_process_handle<Executor> & handle, error_code & ec)
  23. {
  24. #if defined(BOOST_PROCESS_V2_WINDOWS)
  25. return cwd(handle.native_handle(), ec);
  26. #else
  27. return cwd(handle.id(), ec);
  28. #endif
  29. }
  30. template<typename Executor>
  31. BOOST_PROCESS_V2_DECL filesystem::path cwd(basic_process_handle<Executor> & handle)
  32. {
  33. #if defined(BOOST_PROCESS_V2_WINDOWS)
  34. return cwd(handle.native_handle());
  35. #else
  36. return cwd(handle.id());
  37. #endif
  38. }
  39. /// @}
  40. } // namespace ext
  41. BOOST_PROCESS_V2_END_NAMESPACE
  42. #if defined(BOOST_PROCESS_V2_HEADER_ONLY)
  43. #include <boost/process/v2/ext/impl/cwd.ipp>
  44. #endif
  45. #endif // BOOST_PROCESS_V2_CWD_HPP