mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00
LibCore: Allow moving, but not copying, DirIterator
An explicit move constructor is required to null-out the moved-from directory descriptor. Otherwise, we would call closedir() twice when using ErrorOr<DirIterator>::release_value().
This commit is contained in:
parent
55e0b91d8d
commit
7f780e43a6
2 changed files with 13 additions and 0 deletions
|
@ -29,6 +29,16 @@ DirIterator::~DirIterator()
|
|||
}
|
||||
}
|
||||
|
||||
DirIterator::DirIterator(DirIterator&& other)
|
||||
: m_dir(other.m_dir)
|
||||
, m_error(other.m_error)
|
||||
, m_next(move(other.m_next))
|
||||
, m_path(move(other.m_path))
|
||||
, m_flags(other.m_flags)
|
||||
{
|
||||
other.m_dir = nullptr;
|
||||
}
|
||||
|
||||
bool DirIterator::advance_next()
|
||||
{
|
||||
if (!m_dir)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue