2015-08-10 15:45:56 +10:00
|
|
|
/*
|
2018-08-04 15:14:06 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2015-08-10 15:45:56 +10:00
|
|
|
*
|
|
|
|
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "library_win32.hpp"
|
|
|
|
|
2017-12-18 15:46:52 +11:00
|
|
|
#include "win32/except.hpp"
|
2015-08-10 15:45:56 +10:00
|
|
|
|
2018-08-05 14:42:02 +10:00
|
|
|
using cruft::detail::win32::library;
|
2015-08-10 15:45:56 +10:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2016-11-17 18:07:57 +11:00
|
|
|
library::library (const std::experimental::filesystem::path &path):
|
2018-08-13 14:51:33 +10:00
|
|
|
m_handle (LoadLibraryA (path.u8string ().c_str ()))
|
2015-08-10 15:45:56 +10:00
|
|
|
{
|
|
|
|
if (!m_handle)
|
2018-08-13 14:51:33 +10:00
|
|
|
::cruft::win32::error::throw_code ();
|
2015-08-10 15:45:56 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2018-08-20 16:13:49 +10:00
|
|
|
library::library (library &&rhs):
|
|
|
|
m_handle (nullptr)
|
2015-08-10 15:45:56 +10:00
|
|
|
{
|
2018-08-20 16:13:49 +10:00
|
|
|
std::swap (m_handle, rhs.m_handle);
|
2015-08-10 15:45:56 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-20 16:13:49 +10:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
library&
|
|
|
|
library::operator= (cruft::library &&rhs)
|
|
|
|
{
|
|
|
|
std::swap (m_handle, rhs.m_handle);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
library::~library ()
|
2015-08-10 15:45:56 +10:00
|
|
|
{
|
2018-08-20 16:13:49 +10:00
|
|
|
if (m_handle)
|
|
|
|
FreeLibrary (m_handle);
|
2015-08-10 15:45:56 +10:00
|
|
|
}
|