From f64c662ab9053720a426b6aa8ecb013989df3148 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Wed, 12 Jul 2023 21:40:21 +0300 Subject: [PATCH] Stop lying to people --- include/fs/archive_base.hpp | 27 ++++++++++++------------ src/core/kernel/directory_operations.cpp | 4 ++-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/fs/archive_base.hpp b/include/fs/archive_base.hpp index 4bd877f0..0b0f65a1 100644 --- a/include/fs/archive_base.hpp +++ b/include/fs/archive_base.hpp @@ -122,29 +122,28 @@ struct DirectoryEntry { }; struct DirectorySession { - ArchiveBase* archive = nullptr; - // For directories which are mirrored to a specific path on the disk, this contains that path - // Otherwise this is a nullopt - std::optional pathOnDisk; + ArchiveBase* archive = nullptr; + // For directories which are mirrored to a specific path on the disk, this contains that path + // Otherwise this is a nullopt + std::optional pathOnDisk; - // Iterators for traversing the directory in Directory::Read + // The list of directory entries + the index of the entry we're currently inspecting std::vector entries; size_t currentEntry; - bool isOpen; + bool isOpen; - DirectorySession(ArchiveBase* archive, std::filesystem::path path, bool isOpen = true) : archive(archive), pathOnDisk(path), - isOpen(isOpen) { - currentEntry = 0; // Start from entry 0 - - // Read all directory entries, cache them - for (auto& e : std::filesystem::directory_iterator(path)) { + DirectorySession(ArchiveBase* archive, std::filesystem::path path, bool isOpen = true) : archive(archive), pathOnDisk(path), isOpen(isOpen) { + currentEntry = 0; // Start from entry 0 + + // Read all directory entries, cache them + for (auto& e : std::filesystem::directory_iterator(path)) { DirectoryEntry entry; entry.path = e.path(); entry.isDirectory = std::filesystem::is_directory(e); entries.push_back(entry); - } - } + } + } }; // Represents a file descriptor obtained from OpenFile. If the optional is nullopt, opening the file failed. diff --git a/src/core/kernel/directory_operations.cpp b/src/core/kernel/directory_operations.cpp index fca1e108..462b7e75 100644 --- a/src/core/kernel/directory_operations.cpp +++ b/src/core/kernel/directory_operations.cpp @@ -35,7 +35,6 @@ void Kernel::readDirectory(u32 messagePointer, Handle directory) { const u32 entryCount = mem.read32(messagePointer + 4); const u32 outPointer = mem.read32(messagePointer + 12); logFileIO("Directory::Read (handle = %X, entry count = %d, out pointer = %08X)\n", directory, entryCount, outPointer); - Helpers::panicDev("Unimplemented FsDir::Read"); const auto p = getObject(directory, KernelObjectType::Directory); if (p == nullptr) [[unlikely]] { @@ -56,7 +55,6 @@ void Kernel::readDirectory(u32 messagePointer, Handle directory) { std::filesystem::path extension = path.extension(); std::filesystem::path relative = path.lexically_relative(dirPath); bool isDirectory = std::filesystem::is_directory(relative); - std::cout << "Relative path: " << relative << "\nIs directory: " << isDirectory << "\n"; std::u16string nameU16 = relative.u16string(); std::string nameString = relative.string(); @@ -76,6 +74,8 @@ void Kernel::readDirectory(u32 messagePointer, Handle directory) { mem.write16(utfPointer, 0); // Null terminate the UTF16 name for (auto c : nameString) { + //if (c == '.') continue; // Ignore initial dot + mem.write8(namePointer, u8(c)); namePointer += sizeof(u8); }