Skip to content

Commit b58c844

Browse files
tree: add two new accessors
We need these for the (soon to arrive) FUSE backend and for mutating the filesystem tree for flatpak images. Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent 1459f29 commit b58c844

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

crates/composefs/src/tree.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,26 @@ impl<ObjectID: FsVerityHashValue> Directory<ObjectID> {
388388
self.entries.remove(filename);
389389
}
390390

391+
/// Does a directory lookup on the given filename, returning the Inode if it exists.
392+
///
393+
/// # Arguments
394+
///
395+
/// * `filename`: the filename in the current directory. If you need to support full
396+
/// pathnames then you should call `Directory::split()` first.
397+
pub fn lookup(&self, filename: &OsStr) -> Option<&Inode<ObjectID>> {
398+
self.entries.get(filename)
399+
}
400+
401+
/// Removes an item from the directory, if it exists, returning the Inode value.
402+
///
403+
/// # Arguments
404+
///
405+
/// * `filename`: the filename in the current directory. If you need to support full
406+
/// pathnames then you should call `Directory::split_mut()` first.
407+
pub fn pop(&mut self, filename: &OsStr) -> Option<Inode<ObjectID>> {
408+
self.entries.remove(filename)
409+
}
410+
391411
/// Removes all content from this directory, making the directory empty. The `stat` data
392412
/// remains unmodified.
393413
pub fn clear(&mut self) {

0 commit comments

Comments
 (0)