From 42399167b3d2284ba09e57a845264d35c668b01c Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 16 Feb 2020 14:10:47 +1300 Subject: [PATCH] LibCore: Add DirIterator::next_full_path() --- Libraries/LibCore/DirIterator.cpp | 8 +++++++- Libraries/LibCore/DirIterator.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Libraries/LibCore/DirIterator.cpp b/Libraries/LibCore/DirIterator.cpp index b2f2dcea9a..de9707c0ff 100644 --- a/Libraries/LibCore/DirIterator.cpp +++ b/Libraries/LibCore/DirIterator.cpp @@ -30,7 +30,8 @@ namespace Core { DirIterator::DirIterator(const StringView& path, Flags flags) - : m_flags(flags) + : m_path(path) + , m_flags(flags) { m_dir = opendir(String(path).characters()); if (!m_dir) { @@ -92,4 +93,9 @@ String DirIterator::next_path() return tmp; } +String DirIterator::next_full_path() +{ + return String::format("%s/%s", m_path.characters(), next_path().characters()); +} + } diff --git a/Libraries/LibCore/DirIterator.h b/Libraries/LibCore/DirIterator.h index acbbe453e0..184dda654f 100644 --- a/Libraries/LibCore/DirIterator.h +++ b/Libraries/LibCore/DirIterator.h @@ -47,11 +47,13 @@ public: const char* error_string() const { return strerror(m_error); } bool has_next(); String next_path(); + String next_full_path(); private: DIR* m_dir = nullptr; int m_error = 0; String m_next; + String m_path; int m_flags; bool advance_next();