diff --git a/io_win32.cpp b/io_win32.cpp index 5736705b..3eea0eb9 100644 --- a/io_win32.cpp +++ b/io_win32.cpp @@ -135,10 +135,10 @@ mapped_file::mapped_file ( //----------------------------------------------------------------------------- -mapped_file::mapped_file (const cruft::posix::fd &src, +mapped_file::mapped_file (cruft::posix::fd const &src, int fflags, int mflags): - mapped_file (cruft::win32::handle (reinterpret_cast (_get_osfhandle (src))), + mapped_file (cruft::win32::handle (src.dup ()), fflags, mflags) { }; diff --git a/io_win32.hpp b/io_win32.hpp index e1bd52ae..17fcef02 100644 --- a/io_win32.hpp +++ b/io_win32.hpp @@ -62,7 +62,7 @@ namespace cruft { mapped_file (const std::experimental::filesystem::path &path, int fflags = O_RDONLY, int mflags = PROT_READ); - mapped_file (const cruft::posix::fd&, + mapped_file (cruft::posix::fd const&, int fflag = O_RDONLY, int mflags = PROT_READ); diff --git a/win32/handle.cpp b/win32/handle.cpp index 40f275b2..2d81b172 100644 --- a/win32/handle.cpp +++ b/win32/handle.cpp @@ -25,6 +25,14 @@ handle::handle (handle &&rhs): } +//----------------------------------------------------------------------------- +handle::handle (posix::fd &&rhs): + m_native (reinterpret_cast (_get_osfhandle (rhs.release ()))) +{ + win32::error::try_value (m_native); +} + + //----------------------------------------------------------------------------- handle::~handle () { diff --git a/win32/handle.hpp b/win32/handle.hpp index 874a5998..4fc6741e 100644 --- a/win32/handle.hpp +++ b/win32/handle.hpp @@ -8,12 +8,15 @@ #include +#include "../posix/fd.hpp" + namespace cruft::win32 { struct handle { handle (); explicit handle (HANDLE&&); handle (handle&&); handle (const handle&) = delete; + handle (posix::fd&&); ~handle (); operator HANDLE& (void) &;