2015-08-10 15:46:13 +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:46:13 +10:00
|
|
|
*
|
|
|
|
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
|
|
|
|
*/
|
|
|
|
|
2017-11-22 16:49:37 +11:00
|
|
|
#include "dir.hpp"
|
2015-08-10 15:46:13 +10:00
|
|
|
|
2017-12-18 15:46:52 +11:00
|
|
|
#include "except.hpp"
|
2015-08-10 15:46:13 +10:00
|
|
|
|
2018-08-05 14:42:02 +10:00
|
|
|
using cruft::posix::dir;
|
2015-08-10 15:46:13 +10:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2018-12-05 19:12:03 +11:00
|
|
|
dir::dir (const std::filesystem::path &p):
|
2018-08-13 14:51:33 +10:00
|
|
|
m_handle (::opendir (p.u8string ().c_str ()))
|
2015-08-10 15:46:13 +10:00
|
|
|
{
|
|
|
|
if (!m_handle)
|
2017-12-18 15:46:52 +11:00
|
|
|
error::throw_code ();
|
2015-08-10 15:46:13 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
dir::~dir ()
|
|
|
|
{
|
2017-12-18 15:46:52 +11:00
|
|
|
error::try_code (closedir (m_handle));
|
2015-08-10 15:46:13 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
dir::operator DIR* (void)
|
|
|
|
{
|
|
|
|
return m_handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
void
|
|
|
|
dir::rewind (void)
|
|
|
|
{
|
|
|
|
rewinddir (m_handle);
|
|
|
|
}
|