Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/ntfs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/file_reference.rs')
-rw-r--r--src/file_reference.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/file_reference.rs b/src/file_reference.rs
index aa18764..836bfbf 100644
--- a/src/file_reference.rs
+++ b/src/file_reference.rs
@@ -1,6 +1,9 @@
// Copyright 2021 Colin Finck <colin@reactos.org>
// SPDX-License-Identifier: GPL-2.0-or-later
+use crate::error::Result;
+use crate::file::NtfsFile;
+use crate::ntfs::Ntfs;
use binread::io::{Read, Seek};
use binread::BinRead;
@@ -19,4 +22,12 @@ impl NtfsFileReference {
pub fn sequence_number(&self) -> u16 {
(u64::from_le_bytes(self.0) >> 48) as u16
}
+
+ /// Returns an [`NtfsFile`] for the file referenced by this object.
+ pub fn to_file<'n, T>(&self, ntfs: &'n Ntfs, fs: &mut T) -> Result<NtfsFile<'n>>
+ where
+ T: Read + Seek,
+ {
+ ntfs.file(fs, self.file_record_number())
+ }
}