mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
Stop lying to people
This commit is contained in:
parent
3a1a612e8b
commit
f64c662ab9
2 changed files with 15 additions and 16 deletions
|
@ -122,29 +122,28 @@ struct DirectoryEntry {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DirectorySession {
|
struct DirectorySession {
|
||||||
ArchiveBase* archive = nullptr;
|
ArchiveBase* archive = nullptr;
|
||||||
// For directories which are mirrored to a specific path on the disk, this contains that path
|
// For directories which are mirrored to a specific path on the disk, this contains that path
|
||||||
// Otherwise this is a nullopt
|
// Otherwise this is a nullopt
|
||||||
std::optional<std::filesystem::path> pathOnDisk;
|
std::optional<std::filesystem::path> 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<DirectoryEntry> entries;
|
std::vector<DirectoryEntry> entries;
|
||||||
size_t currentEntry;
|
size_t currentEntry;
|
||||||
|
|
||||||
bool isOpen;
|
bool isOpen;
|
||||||
|
|
||||||
DirectorySession(ArchiveBase* archive, std::filesystem::path path, bool isOpen = true) : archive(archive), pathOnDisk(path),
|
DirectorySession(ArchiveBase* archive, std::filesystem::path path, bool isOpen = true) : archive(archive), pathOnDisk(path), isOpen(isOpen) {
|
||||||
isOpen(isOpen) {
|
currentEntry = 0; // Start from entry 0
|
||||||
currentEntry = 0; // Start from entry 0
|
|
||||||
|
// Read all directory entries, cache them
|
||||||
// Read all directory entries, cache them
|
for (auto& e : std::filesystem::directory_iterator(path)) {
|
||||||
for (auto& e : std::filesystem::directory_iterator(path)) {
|
|
||||||
DirectoryEntry entry;
|
DirectoryEntry entry;
|
||||||
entry.path = e.path();
|
entry.path = e.path();
|
||||||
entry.isDirectory = std::filesystem::is_directory(e);
|
entry.isDirectory = std::filesystem::is_directory(e);
|
||||||
entries.push_back(entry);
|
entries.push_back(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Represents a file descriptor obtained from OpenFile. If the optional is nullopt, opening the file failed.
|
// Represents a file descriptor obtained from OpenFile. If the optional is nullopt, opening the file failed.
|
||||||
|
|
|
@ -35,7 +35,6 @@ void Kernel::readDirectory(u32 messagePointer, Handle directory) {
|
||||||
const u32 entryCount = mem.read32(messagePointer + 4);
|
const u32 entryCount = mem.read32(messagePointer + 4);
|
||||||
const u32 outPointer = mem.read32(messagePointer + 12);
|
const u32 outPointer = mem.read32(messagePointer + 12);
|
||||||
logFileIO("Directory::Read (handle = %X, entry count = %d, out pointer = %08X)\n", directory, entryCount, outPointer);
|
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);
|
const auto p = getObject(directory, KernelObjectType::Directory);
|
||||||
if (p == nullptr) [[unlikely]] {
|
if (p == nullptr) [[unlikely]] {
|
||||||
|
@ -56,7 +55,6 @@ void Kernel::readDirectory(u32 messagePointer, Handle directory) {
|
||||||
std::filesystem::path extension = path.extension();
|
std::filesystem::path extension = path.extension();
|
||||||
std::filesystem::path relative = path.lexically_relative(dirPath);
|
std::filesystem::path relative = path.lexically_relative(dirPath);
|
||||||
bool isDirectory = std::filesystem::is_directory(relative);
|
bool isDirectory = std::filesystem::is_directory(relative);
|
||||||
std::cout << "Relative path: " << relative << "\nIs directory: " << isDirectory << "\n";
|
|
||||||
|
|
||||||
std::u16string nameU16 = relative.u16string();
|
std::u16string nameU16 = relative.u16string();
|
||||||
std::string nameString = relative.string();
|
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
|
mem.write16(utfPointer, 0); // Null terminate the UTF16 name
|
||||||
|
|
||||||
for (auto c : nameString) {
|
for (auto c : nameString) {
|
||||||
|
//if (c == '.') continue; // Ignore initial dot
|
||||||
|
|
||||||
mem.write8(namePointer, u8(c));
|
mem.write8(namePointer, u8(c));
|
||||||
namePointer += sizeof(u8);
|
namePointer += sizeof(u8);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue