2017-11-22 16:49:37 +11:00
|
|
|
#include "handle.hpp"
|
2016-04-19 16:08:25 +10:00
|
|
|
|
|
|
|
#include "../except.hpp"
|
|
|
|
|
|
|
|
using util::win32::handle;
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2016-04-27 17:01:45 +10:00
|
|
|
handle::handle ():
|
|
|
|
m_native (INVALID_HANDLE_VALUE)
|
|
|
|
{ ; }
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2016-04-19 16:08:25 +10:00
|
|
|
handle::handle (HANDLE &&h):
|
|
|
|
m_native (h)
|
|
|
|
{ ; }
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
handle::handle (handle &&rhs):
|
|
|
|
m_native (rhs.m_native)
|
|
|
|
{
|
|
|
|
rhs.m_native = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
handle::~handle ()
|
|
|
|
{
|
2016-04-27 17:01:45 +10:00
|
|
|
if (m_native != INVALID_HANDLE_VALUE)
|
|
|
|
CloseHandle (m_native);
|
2016-04-19 16:08:25 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
handle::operator HANDLE& (void) &
|
|
|
|
{
|
|
|
|
return native ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
HANDLE&
|
|
|
|
handle::native (void) &
|
|
|
|
{
|
|
|
|
return m_native;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
const HANDLE&
|
|
|
|
handle::native (void) const &
|
|
|
|
{
|
|
|
|
return m_native;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-27 17:01:45 +10:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
void
|
|
|
|
handle::reset (HANDLE rhs)
|
|
|
|
{
|
|
|
|
if (m_native != INVALID_HANDLE_VALUE)
|
|
|
|
CloseHandle (m_native);
|
|
|
|
m_native = rhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-19 16:08:25 +10:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
handle
|
|
|
|
handle::current_process (void)
|
|
|
|
{
|
2016-08-25 12:03:48 +10:00
|
|
|
return handle (GetCurrentProcess ());
|
2016-04-19 16:08:25 +10:00
|
|
|
}
|