pub struct NtfsFile<'n> { /* private fields */ }
Expand description
A single NTFS File Record.
These records are denoted via a FILE
signature on the filesystem.
NTFS uses File Records to manage all user-facing files and directories, as well as some internal files for housekeeping.
Every File Record consists of NtfsAttribute
s, which may reference additional File Records.
Even the Master File Table (MFT) itself is organized as a File Record.
Reference: https://flatcap.github.io/linux-ntfs/ntfs/concepts/file_record.html
Implementations§
source§impl<'n> NtfsFile<'n>
impl<'n> NtfsFile<'n>
sourcepub fn allocated_size(&self) -> u32
pub fn allocated_size(&self) -> u32
Returns the allocated size of this NTFS File Record, in bytes.
sourcepub fn attributes<'f>(&'f self) -> NtfsAttributes<'n, 'f>
pub fn attributes<'f>(&'f self) -> NtfsAttributes<'n, 'f>
Returns an iterator over all attributes of this file.
This provides a flattened “data-centric” view of the attributes and abstracts away the filesystem details
to deal with many or large attributes (Attribute Lists and connected attributes).
Use NtfsFile::attributes_raw
to iterate over the plain attributes on the filesystem.
Due to the abstraction, the iterator returns an NtfsAttributeItem
for each entry.
sourcepub fn attributes_raw<'f>(&'f self) -> NtfsAttributesRaw<'n, 'f> ⓘ
pub fn attributes_raw<'f>(&'f self) -> NtfsAttributesRaw<'n, 'f> ⓘ
Returns an iterator over all top-level attributes of this file.
Contrary to NtfsFile::attributes
, it does not traverse $ATTRIBUTE_LIST attributes, but returns
them as raw attributes.
Check that function if you want an iterator providing a flattened “data-centric” view over
the attributes by traversing Attribute Lists automatically.
The iterator returns an NtfsAttribute
for each entry.
sourcepub fn data<'f, T>(
&'f self,
fs: &mut T,
data_stream_name: &str
) -> Option<Result<NtfsAttributeItem<'n, 'f>>>where
T: Read + Seek,
pub fn data<'f, T>( &'f self, fs: &mut T, data_stream_name: &str ) -> Option<Result<NtfsAttributeItem<'n, 'f>>>where T: Read + Seek,
Convenience function to get a $DATA attribute of this file.
As NTFS supports multiple data streams per file, you can specify the name of the $DATA attribute to look up. Passing an empty string here looks up the default unnamed $DATA attribute (commonly known as the “file data”). The name is looked up case-insensitively.
If you need more control over which $DATA attribute is available and picked up,
you can use NtfsFile::attributes
to iterate over all attributes of this file.
Panics
Panics if data_stream_name
is non-empty and read_upcase_table
had not been
called on the passed Ntfs
object.
sourcepub fn data_size(&self) -> u32
pub fn data_size(&self) -> u32
Returns the size actually used by data of this NTFS File Record, in bytes.
This is less or equal than NtfsFile::allocated_size
.
sourcepub fn directory_index<'f, T>(
&'f self,
fs: &mut T
) -> Result<NtfsIndex<'n, 'f, NtfsFileNameIndex>>where
T: Read + Seek,
pub fn directory_index<'f, T>( &'f self, fs: &mut T ) -> Result<NtfsIndex<'n, 'f, NtfsFileNameIndex>>where T: Read + Seek,
Convenience function to return an NtfsIndex
if this file is a directory.
This structure can be used to iterate over all files of this directory or a find a specific one.
Apart from any propagated error, this function may return NtfsError::NotADirectory
if this NtfsFile
is not a directory.
If you need more control over the picked up $INDEX_ROOT and $INDEX_ALLOCATION attributes
you can use NtfsFile::attributes
to iterate over all attributes of this file.
sourcepub fn file_record_number(&self) -> u64
pub fn file_record_number(&self) -> u64
Returns the NTFS File Record Number of this file.
This number uniquely identifies this file and can be used to recreate this NtfsFile
object via Ntfs::file
.
sourcepub fn flags(&self) -> NtfsFileFlags
pub fn flags(&self) -> NtfsFileFlags
Returns flags set for this file as specified by NtfsFileFlags
.
sourcepub fn hard_link_count(&self) -> u16
pub fn hard_link_count(&self) -> u16
Returns the number of hard links to this NTFS File Record.
sourcepub fn info(&self) -> Result<NtfsStandardInformation>
pub fn info(&self) -> Result<NtfsStandardInformation>
Convenience function to get the $STANDARD_INFORMATION attribute of this file
(see NtfsStandardInformation
).
This internally calls NtfsFile::attributes_raw
to iterate through the file’s
attributes and pick up the first $STANDARD_INFORMATION attribute.
sourcepub fn is_directory(&self) -> bool
pub fn is_directory(&self) -> bool
Returns whether this NTFS File Record represents a directory.
sourcepub fn name<T>(
&self,
fs: &mut T,
match_namespace: Option<NtfsFileNamespace>,
match_parent_record_number: Option<u64>
) -> Option<Result<NtfsFileName>>where
T: Read + Seek,
pub fn name<T>( &self, fs: &mut T, match_namespace: Option<NtfsFileNamespace>, match_parent_record_number: Option<u64> ) -> Option<Result<NtfsFileName>>where T: Read + Seek,
Convenience function to get a $FILE_NAME attribute of this file (see NtfsFileName
).
A file may have multiple $FILE_NAME attributes for each NtfsFileNamespace
.
Files with hard links have further $FILE_NAME attributes for each directory they are in.
You may optionally filter for a namespace and parent directory via the parameters.
This internally calls NtfsFile::attributes
to iterate through the file’s
attributes and pick up the first matching $FILE_NAME attribute.
sourcepub fn position(&self) -> NtfsPosition
pub fn position(&self) -> NtfsPosition
Returns the absolute byte position of this File Record in the NTFS filesystem.
sourcepub fn sequence_number(&self) -> u16
pub fn sequence_number(&self) -> u16
Returns the sequence number of this file.
NTFS reuses records of deleted files when new files are created. This number is incremented every time a file is deleted. Hence, it gives a count how many time this File Record has been reused.