diff options
author | Colin Finck <colin@reactos.org> | 2021-10-03 16:46:54 +0300 |
---|---|---|
committer | Colin Finck <colin@reactos.org> | 2021-10-03 16:46:54 +0300 |
commit | eaf86401ce5ee42153b70963fcbd67799926bf32 (patch) | |
tree | d3a14bc5db067448be77cbc11fadacbe519253d8 /src/ntfs.rs | |
parent | c134deb4335f7234ab2d057e9928845e7710766a (diff) |
Refactor structured values to work on any type of `NtfsValue`.
This makes `NtfsFile::directory_index` and `NtfsFile::name` work even if the attributes they are looking for are part of an Attribute List.
We keep a fast path for the few attribute types that are always resident.
Diffstat (limited to 'src/ntfs.rs')
-rw-r--r-- | src/ntfs.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/ntfs.rs b/src/ntfs.rs index 9ef8734..78fbd90 100644 --- a/src/ntfs.rs +++ b/src/ntfs.rs @@ -168,8 +168,7 @@ impl Ntfs { T: Read + Seek, { let volume_file = self.file(fs, KnownNtfsFileRecordNumber::Volume as u64)?; - let attribute = volume_file.attribute_by_ty(NtfsAttributeType::VolumeInformation)?; - attribute.resident_structured_value::<NtfsVolumeInformation>() + volume_file.find_resident_attribute_structured_value::<NtfsVolumeInformation>(None) } /// Returns an [`NtfsVolumeName`] to read the volume name (also called volume label) @@ -181,12 +180,12 @@ impl Ntfs { T: Read + Seek, { let volume_file = iter_try!(self.file(fs, KnownNtfsFileRecordNumber::Volume as u64)); - let attribute = volume_file - .attribute_by_ty(NtfsAttributeType::VolumeName) - .ok()?; - let volume_name = iter_try!(attribute.resident_structured_value::<NtfsVolumeName>()); - Some(Ok(volume_name)) + match volume_file.find_resident_attribute_structured_value::<NtfsVolumeName>(None) { + Ok(volume_name) => Some(Ok(volume_name)), + Err(NtfsError::AttributeNotFound { .. }) => None, + Err(e) => Some(Err(e)), + } } } |