Struct ntfs::NtfsFile

source ·
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 NtfsAttributes, 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>

source

pub fn allocated_size(&self) -> u32

Returns the allocated size of this NTFS File Record, in bytes.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn flags(&self) -> NtfsFileFlags

Returns flags set for this file as specified by NtfsFileFlags.

Returns the number of hard links to this NTFS File Record.

source

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.

source

pub fn is_directory(&self) -> bool

Returns whether this NTFS File Record represents a directory.

source

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.

source

pub fn ntfs(&self) -> &'n Ntfs

Returns the Ntfs object reference associated to this file.

source

pub fn position(&self) -> NtfsPosition

Returns the absolute byte position of this File Record in the NTFS filesystem.

source

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.

Trait Implementations§

source§

impl<'n> Clone for NtfsFile<'n>

source§

fn clone(&self) -> NtfsFile<'n>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'n> Debug for NtfsFile<'n>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'n> RefUnwindSafe for NtfsFile<'n>

§

impl<'n> Send for NtfsFile<'n>

§

impl<'n> Sync for NtfsFile<'n>

§

impl<'n> Unpin for NtfsFile<'n>

§

impl<'n> UnwindSafe for NtfsFile<'n>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.