mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
Kernel: Add DirectoryEntryView for VFS directory traversal
Unlike DirectoryEntry (which is used when constructing directories), DirectoryEntryView does not manage storage for file names. Names are just StringViews. This is much more suited to the directory traversal API and makes it easier to implement this in file system classes since they no longer need to create temporary name copies while traversing.
This commit is contained in:
@@ -136,18 +136,18 @@ InodeMetadata DevPtsFSInode::metadata() const
|
||||
return m_metadata;
|
||||
}
|
||||
|
||||
KResult DevPtsFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)> callback) const
|
||||
KResult DevPtsFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
|
||||
{
|
||||
if (identifier().index() > 1)
|
||||
return KResult(-ENOTDIR);
|
||||
|
||||
callback({ ".", 1, identifier(), 0 });
|
||||
callback({ "..", 2, identifier(), 0 });
|
||||
callback({ ".", identifier(), 0 });
|
||||
callback({ "..", identifier(), 0 });
|
||||
|
||||
for (unsigned pty_index : *ptys) {
|
||||
String name = String::number(pty_index);
|
||||
InodeIdentifier identifier = { fsid(), pty_index_to_inode_index(pty_index) };
|
||||
callback({ name.characters(), name.length(), identifier, 0 });
|
||||
callback({ name, identifier, 0 });
|
||||
}
|
||||
|
||||
return KSuccess;
|
||||
|
||||
Reference in New Issue
Block a user