/
usr
/
include
/
boost
/
process
/
detail
/
windows
/
/usr/include/boost/process/detail/windows
mkdir
upload
Name
Size
Mode
Actions
asio_fwd.hpp
1354
0644
edit
dl
rm
async_handler.hpp
1195
0644
edit
dl
rm
async_in.hpp
3557
0644
edit
dl
rm
async_out.hpp
6079
0644
edit
dl
rm
async_pipe.hpp
17611
0644
edit
dl
rm
basic_cmd.hpp
5072
0644
edit
dl
rm
basic_pipe.hpp
8451
0644
edit
dl
rm
child_handle.hpp
3185
0644
edit
dl
rm
close_in.hpp
1040
0644
edit
dl
rm
close_out.hpp
1743
0644
edit
dl
rm
cmd.hpp
993
0644
edit
dl
rm
compare_handles.hpp
1488
0644
edit
dl
rm
environment.hpp
10976
0644
edit
dl
rm
env_init.hpp
1615
0644
edit
dl
rm
executor.hpp
8045
0644
edit
dl
rm
file_descriptor.hpp
3747
0644
edit
dl
rm
file_in.hpp
1735
0644
edit
dl
rm
file_out.hpp
2691
0644
edit
dl
rm
group_handle.hpp
6527
0644
edit
dl
rm
group_ref.hpp
1572
0644
edit
dl
rm
handler.hpp
566
0644
edit
dl
rm
handles.hpp
5746
0644
edit
dl
rm
handle_workaround.hpp
8924
0644
edit
dl
rm
io_context_ref.hpp
5043
0644
edit
dl
rm
is_running.hpp
1411
0644
edit
dl
rm
job_workaround.hpp
9721
0644
edit
dl
rm
locale.hpp
3154
0644
edit
dl
rm
null_in.hpp
1559
0644
edit
dl
rm
null_out.hpp
2576
0644
edit
dl
rm
on_exit.hpp
1202
0644
edit
dl
rm
pipe_in.hpp
2571
0644
edit
dl
rm
pipe_out.hpp
3535
0644
edit
dl
rm
search_path.hpp
2808
0644
edit
dl
rm
shell_path.hpp
1568
0644
edit
dl
rm
show_window.hpp
1308
0644
edit
dl
rm
start_dir.hpp
1026
0644
edit
dl
rm
terminate.hpp
1329
0644
edit
dl
rm
wait_for_exit.hpp
4048
0644
edit
dl
rm
wait_group.hpp
4337
0644
edit
dl
rm
Edit:
/usr/include/boost/process/detail/windows/basic_pipe.hpp
(8451B)
// Copyright (c) 2016 Klemens D. Morgenstern // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PROCESS_DETAIL_WINDOWS_PIPE_HPP #define BOOST_PROCESS_DETAIL_WINDOWS_PIPE_HPP #include <boost/winapi/basic_types.hpp> #include <boost/winapi/error_codes.hpp> #include <boost/winapi/pipes.hpp> #include <boost/winapi/handles.hpp> #include <boost/winapi/file_management.hpp> #include <boost/winapi/get_last_error.hpp> #include <boost/winapi/access_rights.hpp> #include <boost/winapi/process.hpp> #include <boost/process/detail/windows/compare_handles.hpp> #include <system_error> #include <string> namespace boost { namespace process { namespace detail { namespace windows { template<class CharT, class Traits = std::char_traits<CharT>> class basic_pipe { ::boost::winapi::HANDLE_ _source = ::boost::winapi::INVALID_HANDLE_VALUE_; ::boost::winapi::HANDLE_ _sink = ::boost::winapi::INVALID_HANDLE_VALUE_; public: typedef CharT char_type ; typedef Traits traits_type; typedef typename Traits::int_type int_type ; typedef typename Traits::pos_type pos_type ; typedef typename Traits::off_type off_type ; typedef ::boost::winapi::HANDLE_ native_handle_type; explicit basic_pipe(::boost::winapi::HANDLE_ source, ::boost::winapi::HANDLE_ sink) : _source(source), _sink(sink) {} inline explicit basic_pipe(const std::string & name); inline basic_pipe(const basic_pipe& p); basic_pipe(basic_pipe&& lhs) : _source(lhs._source), _sink(lhs._sink) { lhs._source = ::boost::winapi::INVALID_HANDLE_VALUE_; lhs._sink = ::boost::winapi::INVALID_HANDLE_VALUE_; } inline basic_pipe& operator=(const basic_pipe& p); inline basic_pipe& operator=(basic_pipe&& lhs); ~basic_pipe() { if (_sink != ::boost::winapi::INVALID_HANDLE_VALUE_) ::boost::winapi::CloseHandle(_sink); if (_source != ::boost::winapi::INVALID_HANDLE_VALUE_) ::boost::winapi::CloseHandle(_source); } native_handle_type native_source() const {return _source;} native_handle_type native_sink () const {return _sink;} void assign_source(native_handle_type h) { _source = h;} void assign_sink (native_handle_type h) { _sink = h;} basic_pipe() { if (!::boost::winapi::CreatePipe(&_source, &_sink, nullptr, 0)) throw_last_error("CreatePipe() failed"); } int_type write(const char_type * data, int_type count) { ::boost::winapi::DWORD_ write_len; if (!::boost::winapi::WriteFile( _sink, data, count * sizeof(char_type), &write_len, nullptr )) { auto ec = ::boost::process::detail::get_last_error(); if ((ec.value() == ::boost::winapi::ERROR_BROKEN_PIPE_) || (ec.value() == ::boost::winapi::ERROR_NO_DATA_)) return 0; else throw process_error(ec, "WriteFile failed"); } return static_cast<int_type>(write_len); } int_type read(char_type * data, int_type count) { ::boost::winapi::DWORD_ read_len; if (!::boost::winapi::ReadFile( _source, data, count * sizeof(char_type), &read_len, nullptr )) { auto ec = ::boost::process::detail::get_last_error(); if ((ec.value() == ::boost::winapi::ERROR_BROKEN_PIPE_) || (ec.value() == ::boost::winapi::ERROR_NO_DATA_)) return 0; else throw process_error(ec, "ReadFile failed"); } return static_cast<int_type>(read_len); } bool is_open() const { return (_source != ::boost::winapi::INVALID_HANDLE_VALUE_) || (_sink != ::boost::winapi::INVALID_HANDLE_VALUE_); } void close() { ::boost::winapi::CloseHandle(_source); ::boost::winapi::CloseHandle(_sink); _source = ::boost::winapi::INVALID_HANDLE_VALUE_; _sink = ::boost::winapi::INVALID_HANDLE_VALUE_; } }; template<class Char, class Traits> basic_pipe<Char, Traits>::basic_pipe(const basic_pipe & p) { auto proc = ::boost::winapi::GetCurrentProcess(); if (p._source == ::boost::winapi::INVALID_HANDLE_VALUE_) _source = ::boost::winapi::INVALID_HANDLE_VALUE_; else if (!::boost::winapi::DuplicateHandle( proc, p._source, proc, &_source, 0, static_cast<::boost::winapi::BOOL_>(true), ::boost::winapi::DUPLICATE_SAME_ACCESS_)) throw_last_error("Duplicate Pipe Failed"); if (p._sink == ::boost::winapi::INVALID_HANDLE_VALUE_) _sink = ::boost::winapi::INVALID_HANDLE_VALUE_; else if (!::boost::winapi::DuplicateHandle( proc, p._sink, proc, &_sink, 0, static_cast<::boost::winapi::BOOL_>(true), ::boost::winapi::DUPLICATE_SAME_ACCESS_)) throw_last_error("Duplicate Pipe Failed"); } template<class Char, class Traits> basic_pipe<Char, Traits>::basic_pipe(const std::string & name) { static constexpr int OPEN_EXISTING_ = 3; //temporary. static constexpr int FILE_FLAG_OVERLAPPED_ = 0x40000000; //temporary //static constexpr int FILE_ATTRIBUTE_NORMAL_ = 0x00000080; //temporary #if BOOST_NO_ANSI_APIS std::wstring name_ = boost::process::detail::convert(name); #else auto &name_ = name; #endif ::boost::winapi::HANDLE_ source = ::boost::winapi::create_named_pipe( name_.c_str(), ::boost::winapi::PIPE_ACCESS_INBOUND_ | FILE_FLAG_OVERLAPPED_, //write flag 0, ::boost::winapi::PIPE_UNLIMITED_INSTANCES_, 8192, 8192, 0, nullptr); if (source == boost::winapi::INVALID_HANDLE_VALUE_) ::boost::process::detail::throw_last_error("create_named_pipe() failed"); ::boost::winapi::HANDLE_ sink = boost::winapi::create_file( name.c_str(), ::boost::winapi::GENERIC_WRITE_, 0, nullptr, OPEN_EXISTING_, FILE_FLAG_OVERLAPPED_, //to allow read nullptr); if (sink == ::boost::winapi::INVALID_HANDLE_VALUE_) ::boost::process::detail::throw_last_error("create_file() failed"); _source = source; _sink = sink; } template<class Char, class Traits> basic_pipe<Char, Traits>& basic_pipe<Char, Traits>::operator=(const basic_pipe & p) { auto proc = ::boost::winapi::GetCurrentProcess(); if (p._source == ::boost::winapi::INVALID_HANDLE_VALUE_) _source = ::boost::winapi::INVALID_HANDLE_VALUE_; else if (!::boost::winapi::DuplicateHandle( proc, p._source, proc, &_source, 0, static_cast<::boost::winapi::BOOL_>(true), ::boost::winapi::DUPLICATE_SAME_ACCESS_)) throw_last_error("Duplicate Pipe Failed"); if (p._sink == ::boost::winapi::INVALID_HANDLE_VALUE_) _sink = ::boost::winapi::INVALID_HANDLE_VALUE_; else if (!::boost::winapi::DuplicateHandle( proc, p._sink, proc, &_sink, 0, static_cast<::boost::winapi::BOOL_>(true), ::boost::winapi::DUPLICATE_SAME_ACCESS_)) throw_last_error("Duplicate Pipe Failed"); return *this; } template<class Char, class Traits> basic_pipe<Char, Traits>& basic_pipe<Char, Traits>::operator=(basic_pipe && lhs) { if (_source != ::boost::winapi::INVALID_HANDLE_VALUE_) ::boost::winapi::CloseHandle(_source); if (_sink != ::boost::winapi::INVALID_HANDLE_VALUE_) ::boost::winapi::CloseHandle(_sink); _source = lhs._source; _sink = lhs._sink; lhs._source = ::boost::winapi::INVALID_HANDLE_VALUE_; lhs._sink = ::boost::winapi::INVALID_HANDLE_VALUE_; return *this; } template<class Char, class Traits> inline bool operator==(const basic_pipe<Char, Traits> & lhs, const basic_pipe<Char, Traits> & rhs) { return compare_handles(lhs.native_source(), rhs.native_source()) && compare_handles(lhs.native_sink(), rhs.native_sink()); } template<class Char, class Traits> inline bool operator!=(const basic_pipe<Char, Traits> & lhs, const basic_pipe<Char, Traits> & rhs) { return !compare_handles(lhs.native_source(), rhs.native_source()) || !compare_handles(lhs.native_sink(), rhs.native_sink()); } }}}} #endif
Save
cmd:
run