ソースを参照

LibCore: Add DirIterator::next_full_path()

Shannon Booth 5 年 前
コミット
42399167b3
2 ファイル変更9 行追加1 行削除
  1. 7 1
      Libraries/LibCore/DirIterator.cpp
  2. 2 0
      Libraries/LibCore/DirIterator.h

+ 7 - 1
Libraries/LibCore/DirIterator.cpp

@@ -30,7 +30,8 @@
 namespace Core {
 namespace Core {
 
 
 DirIterator::DirIterator(const StringView& path, Flags flags)
 DirIterator::DirIterator(const StringView& path, Flags flags)
-    : m_flags(flags)
+    : m_path(path)
+    , m_flags(flags)
 {
 {
     m_dir = opendir(String(path).characters());
     m_dir = opendir(String(path).characters());
     if (!m_dir) {
     if (!m_dir) {
@@ -92,4 +93,9 @@ String DirIterator::next_path()
     return tmp;
     return tmp;
 }
 }
 
 
+String DirIterator::next_full_path()
+{
+    return String::format("%s/%s", m_path.characters(), next_path().characters());
+}
+
 }
 }

+ 2 - 0
Libraries/LibCore/DirIterator.h

@@ -47,11 +47,13 @@ public:
     const char* error_string() const { return strerror(m_error); }
     const char* error_string() const { return strerror(m_error); }
     bool has_next();
     bool has_next();
     String next_path();
     String next_path();
+    String next_full_path();
 
 
 private:
 private:
     DIR* m_dir = nullptr;
     DIR* m_dir = nullptr;
     int m_error = 0;
     int m_error = 0;
     String m_next;
     String m_next;
+    String m_path;
     int m_flags;
     int m_flags;
 
 
     bool advance_next();
     bool advance_next();