diff options
Diffstat (limited to 'src/index_entry.rs')
-rw-r--r-- | src/index_entry.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/index_entry.rs b/src/index_entry.rs index 804a5d6..c84b67f 100644 --- a/src/index_entry.rs +++ b/src/index_entry.rs @@ -2,14 +2,18 @@ // SPDX-License-Identifier: GPL-2.0-or-later use crate::error::Result; +use crate::file::NtfsFile; use crate::file_reference::NtfsFileReference; use crate::indexes::{ NtfsIndexEntryData, NtfsIndexEntryHasData, NtfsIndexEntryHasFileReference, NtfsIndexEntryKey, NtfsIndexEntryType, }; +use crate::ntfs::Ntfs; use crate::types::Vcn; +use binread::io::{Read, Seek}; use bitflags::bitflags; use byteorder::{ByteOrder, LittleEndian}; +use core::convert::TryInto; use core::iter::FusedIterator; use core::marker::PhantomData; use core::mem; @@ -43,6 +47,7 @@ bitflags! { } } +#[derive(Clone, Debug)] pub(crate) struct IndexEntryRange<E> where E: NtfsIndexEntryType, @@ -128,6 +133,7 @@ where LittleEndian::read_u16(&self.slice[start..]) } + /// Returns an [`NtfsFileReference`] for the file referenced by this index entry. pub fn file_reference(&self) -> NtfsFileReference where E: NtfsIndexEntryHasFileReference, @@ -186,6 +192,15 @@ where Some(vcn) } + + /// Returns an [`NtfsFile`] for the file referenced by this index entry. + pub fn to_file<'n, T>(&self, ntfs: &'n Ntfs, fs: &mut T) -> Result<NtfsFile<'n>> + where + E: NtfsIndexEntryHasFileReference, + T: Read + Seek, + { + self.file_reference().to_file(ntfs, fs) + } } pub(crate) struct IndexNodeEntryRanges<E> |