cwd.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /// @{
  14. /// Obtain the current path of another process
  15. BOOST_PROCESS_V2_DECL filesystem::path cwd(pid_type pid, error_code & ec);
  16. BOOST_PROCESS_V2_DECL filesystem::path cwd(pid_type pid);
  17. template<typename Executor>
  18. BOOST_PROCESS_V2_DECL filesystem::path cwd(basic_process_handle<Executor> & handle, error_code & ec)
  19. {
  20. #if defined(BOOST_PROCESS_V2_WINDOWS)
  21. return cwd(handle.native_handle(), ec);
  22. #else
  23. return cwd(handle.id(), ec);
  24. #endif
  25. }
  26. template<typename Executor>
  27. BOOST_PROCESS_V2_DECL filesystem::path cwd(basic_process_handle<Executor> & handle)
  28. {
  29. #if defined(BOOST_PROCESS_V2_WINDOWS)
  30. return cwd(handle.native_handle());
  31. #else
  32. return cwd(handle.id());
  33. #endif
  34. }
  35. /// @}
  36. #if defined(BOOST_PROCESS_V2_WINDOWS)
  37. BOOST_PROCESS_V2_DECL filesystem::path cwd(HANDLE handle, error_code & ec);
  38. BOOST_PROCESS_V2_DECL filesystem::path cwd(HANDLE handle);
  39. #endif
  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