5
0
mirror of git://git.proxmox.com/git/pxar.git synced 2024-12-22 21:33:50 +03:00

accessor: expose lookup_self

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-05-06 09:41:01 +02:00
parent 6b9e2478e5
commit a5922fbcdc
2 changed files with 10 additions and 1 deletions

View File

@ -375,7 +375,7 @@ impl<T: Clone + ReadAt> DirectoryImpl<T> {
binary_tree_array::search_by(&self.table, start, skip, |i| hash.cmp(&i.hash))
}
async fn lookup_self(&self) -> io::Result<FileEntryImpl<T>> {
pub async fn lookup_self(&self) -> io::Result<FileEntryImpl<T>> {
let (entry, _decoder) = self.decode_one_entry(self.entry_range(), None).await?;
Ok(FileEntryImpl {
input: self.input.clone(),

View File

@ -190,6 +190,15 @@ impl<T: Clone + ReadAt> Directory<T> {
)?))
}
/// Get a `FileEntry` referencing the directory itself.
///
/// Helper function for our fuse implementation.
pub fn lookup_self(&self) -> io::Result<FileEntry<T>> {
Ok(FileEntry {
inner: poll_result_once(self.inner.lookup_self())?,
})
}
/// Lookup an entry in a directory.
pub fn lookup<P: AsRef<Path>>(&self, path: P) -> io::Result<Option<FileEntry<T>>> {
if let Some(file_entry) = poll_result_once(self.inner.lookup(path.as_ref()))? {