Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:13

0001 //
0002 // process/start_dir.hpp
0003 // ~~~~~~~~
0004 //
0005 // Copyright (c) 2021 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 
0010 #ifndef BOOST_PROCESS_v2_START_DIR_HPP
0011 #define BOOST_PROCESS_v2_START_DIR_HPP
0012 
0013 #include <boost/process/v2/detail/config.hpp>
0014 #include <boost/process/v2/detail/last_error.hpp>
0015 #include <boost/process/v2/default_launcher.hpp>
0016 
0017 BOOST_PROCESS_V2_BEGIN_NAMESPACE
0018 
0019 /// Initializer for the starting directory of a subprocess to be launched.
0020 struct process_start_dir
0021 {
0022   filesystem::path start_dir;
0023 
0024   process_start_dir(filesystem::path start_dir) : start_dir(std::move(start_dir))
0025   {
0026   }
0027 
0028 #if defined(BOOST_PROCESS_V2_WINDOWS)
0029   error_code on_setup(windows::default_launcher & launcher, 
0030                       const filesystem::path &, const std::wstring &)
0031   {
0032     launcher.current_directory = start_dir;
0033     return error_code {};
0034   };
0035 
0036 #else
0037   error_code on_exec_setup(posix::default_launcher & launcher, 
0038                            const filesystem::path &, const char * const *)
0039   {
0040     if (::chdir(start_dir.c_str()) == -1)
0041       return detail::get_last_error();
0042     else
0043       return error_code ();
0044   }
0045 #endif
0046 
0047 };
0048 
0049 BOOST_PROCESS_V2_END_NAMESPACE
0050 
0051 #endif //  BOOST_PROCESS_v2_START_DIR_HPP