Serenity Operating System
at master 46 lines 1.1 kB view raw
1/* 2 * Copyright (c) 2021, sin-ack <sin-ack@protonmail.com> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/Types.h> 10#include <Kernel/FileSystem/ISO9660FS/Definitions.h> 11#include <Kernel/FileSystem/ISO9660FS/DirectoryEntry.h> 12#include <Kernel/FileSystem/ISO9660FS/FileSystem.h> 13#include <Kernel/KBuffer.h> 14 15namespace Kernel { 16 17class ISO9660DirectoryIterator { 18public: 19 ISO9660DirectoryIterator(ISO9660FS& fs, ISO::DirectoryRecordHeader const& header); 20 21 ISO::DirectoryRecordHeader const* operator*() { return m_current_header; } 22 23 // Recurses into subdirectories. May fail. 24 ErrorOr<bool> next(); 25 26 // Skips to the directory in the list, returns whether there was a next one. 27 // No allocation here, cannot fail. 28 bool skip(); 29 30 bool go_up(); 31 bool done() const; 32 33private: 34 ErrorOr<void> read_directory_contents(); 35 36 void get_header(); 37 38 ISO9660FS& m_fs; 39 40 ISO9660FSDirectoryState m_current_directory; 41 ISO::DirectoryRecordHeader const* m_current_header { nullptr }; 42 43 Vector<ISO9660FSDirectoryState> m_directory_stack; 44}; 45 46}