mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibCore: Expose file type from DirIterator
Our `find` utility makes use of the `dirent::d_type` field for filtering results, which `Core::DirIterator` didn't expose. So, now it does. :^) We now store the name and type of the entry as the "next" value instead of just the name. The type is exposed as a `DirectoryEntry::Type` instead of a `DT_FOO` constant, so that we're not tied to posixy systems, and because proper enums are nice. :^)
This commit is contained in:
parent
bc0bb98c01
commit
a98ae8f357
5 changed files with 106 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -7,6 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <LibCore/DirectoryEntry.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -30,6 +32,7 @@ public:
|
|||
int error() const { return m_error; }
|
||||
char const* error_string() const { return strerror(m_error); }
|
||||
bool has_next();
|
||||
Optional<DirectoryEntry> next();
|
||||
DeprecatedString next_path();
|
||||
DeprecatedString next_full_path();
|
||||
int fd() const;
|
||||
|
@ -37,7 +40,7 @@ public:
|
|||
private:
|
||||
DIR* m_dir = nullptr;
|
||||
int m_error = 0;
|
||||
DeprecatedString m_next;
|
||||
Optional<DirectoryEntry> m_next;
|
||||
DeprecatedString m_path;
|
||||
int m_flags;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue