Stop lying to people

This commit is contained in:
wheremyfoodat 2023-07-12 21:40:21 +03:00
parent 3a1a612e8b
commit f64c662ab9
2 changed files with 15 additions and 16 deletions

View file

@ -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<std::filesystem::path> 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<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;
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.