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

github.com/windirstat/mft.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorforensicsmatt <matthew.seyer@gmail.com>2019-09-14 17:23:27 +0300
committerforensicsmatt <matthew.seyer@gmail.com>2019-09-14 17:23:27 +0300
commit65785ba2fc5dcf5589dfad40d5693d3bba1e6369 (patch)
tree7d9bcb0c15667db51e1527c3fcd241cd5223055a
parent4eb72316bdca2277248ea3802a68d4274432ad09 (diff)
Better doc; Use ensure! for error return;
Better doc; Use ensure! for error return;
-rw-r--r--src/entry.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/entry.rs b/src/entry.rs
index a0a4a99..f1b2a63 100644
--- a/src/entry.rs
+++ b/src/entry.rs
@@ -187,22 +187,21 @@ impl MftEntry {
})
}
- /// Initializes an MFT Entry from a buffer but skips applying fixups
- /// It is not recommended to use this function unless you know what you are doing.
- /// The main purpose of it is for use when you have buffers that already have fixup
- /// already applied. For example, using Windows API
- /// (https://docs.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-fsctl_get_ntfs_file_record)
+ /// Initializes an MFT Entry from a buffer but skips checking and fixing the
+ /// fixup array. This will throw InvalidEntrySignature error if the entry header
+ /// is not valid.
pub fn from_buffer_skip_fixup(buffer: Vec<u8>, entry_number: u64) -> Result<MftEntry> {
let mut cursor = Cursor::new(&buffer);
// Get Header
let entry_header = EntryHeader::from_reader(&mut cursor, entry_number)?;
trace!("Number of sectors: {:#?}", entry_header);
- if !entry_header.is_valid() {
- return Err(err::Error::InvalidEntrySignature {
+ ensure!(
+ entry_header.is_valid(),
+ err::InvalidEntrySignature {
bad_sig: entry_header.signature.to_vec()
- });
- }
+ }
+ );
Ok(MftEntry {
header: entry_header,