libcruft-util/library_win32.cpp

47 lines
1.1 KiB
C++
Raw Normal View History

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"
#include "win32/except.hpp"
2015-08-10 15:45:56 +10:00
#include <winbase.h>
using cruft::detail::win32::library;
2015-08-10 15:45:56 +10:00
///////////////////////////////////////////////////////////////////////////////
library::library (const std::filesystem::path &path):
m_handle (cruft::win32::error::try_call (LoadLibraryW, path.c_str ()))
{ ; }
2015-08-10 15:45:56 +10:00
//-----------------------------------------------------------------------------
library::library (library &&rhs):
m_handle (nullptr)
2015-08-10 15:45:56 +10:00
{
std::swap (m_handle, rhs.m_handle);
2015-08-10 15:45:56 +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
{
if (m_handle)
FreeLibrary (m_handle);
2015-08-10 15:45:56 +10:00
}