From 758085571fdfcd89a30fa1986050407da7c4ae83 Mon Sep 17 00:00:00 2001 From: Mart G Date: Fri, 14 May 2021 21:05:18 +0200 Subject: LibCore: Expose DirIterator's underlying file descriptor --- Userland/Libraries/LibCore/DirIterator.cpp | 7 +++++++ Userland/Libraries/LibCore/DirIterator.h | 1 + 2 files changed, 8 insertions(+) (limited to 'Userland/Libraries/LibCore') diff --git a/Userland/Libraries/LibCore/DirIterator.cpp b/Userland/Libraries/LibCore/DirIterator.cpp index 3483101025..deb3f17d04 100644 --- a/Userland/Libraries/LibCore/DirIterator.cpp +++ b/Userland/Libraries/LibCore/DirIterator.cpp @@ -99,4 +99,11 @@ String find_executable_in_path(String filename) return {}; } +int DirIterator::fd() const +{ + if (!m_dir) + return -1; + return dirfd(m_dir); +} + } diff --git a/Userland/Libraries/LibCore/DirIterator.h b/Userland/Libraries/LibCore/DirIterator.h index 088bcb59e6..18fc8a218b 100644 --- a/Userland/Libraries/LibCore/DirIterator.h +++ b/Userland/Libraries/LibCore/DirIterator.h @@ -29,6 +29,7 @@ public: bool has_next(); String next_path(); String next_full_path(); + int fd() const; private: DIR* m_dir = nullptr; -- cgit v1.2.3