]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/process/detail/windows/compare_handles.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / process / detail / windows / compare_handles.hpp
1 // Copyright (c) 2016 Klemens D. Morgenstern
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef BOOST_PROCESS_DETAIL_WINDOWS_COMPARE_HANDLES_HPP_
7 #define BOOST_PROCESS_DETAIL_WINDOWS_COMPARE_HANDLES_HPP_
8
9 #include <boost/winapi/handles.hpp>
10 #include <boost/winapi/file_management.hpp>
11 #include <boost/process/detail/config.hpp>
12
13 namespace boost { namespace process { namespace detail { namespace windows {
14
15 inline bool compare_handles(boost::winapi::HANDLE_ lhs, boost::winapi::HANDLE_ rhs)
16 {
17 if ( (lhs == ::boost::winapi::INVALID_HANDLE_VALUE_)
18 || (rhs == ::boost::winapi::INVALID_HANDLE_VALUE_))
19 return false;
20
21 if (lhs == rhs)
22 return true;
23
24 ::boost::winapi::BY_HANDLE_FILE_INFORMATION_ lhs_info{0,{0,0},{0,0},{0,0},0,0,0,0,0,0};
25 ::boost::winapi::BY_HANDLE_FILE_INFORMATION_ rhs_info{0,{0,0},{0,0},{0,0},0,0,0,0,0,0};
26
27 if (!::boost::winapi::GetFileInformationByHandle(lhs, &lhs_info))
28 ::boost::process::detail::throw_last_error("GetFileInformationByHandle");
29
30 if (!::boost::winapi::GetFileInformationByHandle(rhs, &rhs_info))
31 ::boost::process::detail::throw_last_error("GetFileInformationByHandle");
32
33 return (lhs_info.nFileIndexHigh == rhs_info.nFileIndexHigh)
34 && (lhs_info.nFileIndexLow == rhs_info.nFileIndexLow);
35 }
36
37 }}}}
38
39
40
41 #endif /* BOOST_PROCESS_DETAIL_WINDOWS_COMPARE_HANDLES_HPP_ */