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
|
|
|
|
2019-01-04 17:11:53 +11:00
|
|
|
#include <winbase.h>
|
|
|
|
|
2018-08-05 14:42:02 +10:00
|
|
|
using cruft::detail::win32::library;
|
2015-08-10 15:45:56 +10:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2018-12-05 19:12:03 +11:00
|
|
|
library::library (const std::filesystem::path &path):
|
2019-01-04 17:11:53 +11:00
|
|
|
m_handle (cruft::win32::error::try_call (LoadLibraryW, path.c_str ()))
|
|
|
|
{ ; }
|
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
|
|
|
}
|