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/structured_values/attribute_list.rs')
-rw-r--r--src/structured_values/attribute_list.rs42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/structured_values/attribute_list.rs b/src/structured_values/attribute_list.rs
index 334b17c..27b502f 100644
--- a/src/structured_values/attribute_list.rs
+++ b/src/structured_values/attribute_list.rs
@@ -7,13 +7,11 @@ use crate::file::NtfsFile;
use crate::file_reference::NtfsFileReference;
use crate::ntfs::Ntfs;
use crate::string::NtfsString;
-use crate::structured_values::{
- NtfsStructuredValue, NtfsStructuredValueFromNonResidentAttributeValue,
- NtfsStructuredValueFromSlice,
-};
+use crate::structured_values::NtfsStructuredValue;
use crate::traits::NtfsReadSeek;
use crate::types::Vcn;
use crate::value::non_resident_attribute::NtfsNonResidentAttributeValue;
+use crate::value::NtfsValue;
use arrayvec::ArrayVec;
use binread::io::{Cursor, Read, Seek, SeekFrom};
use binread::{BinRead, BinReaderExt};
@@ -66,27 +64,27 @@ impl<'n, 'f> NtfsAttributeList<'n, 'f> {
}
}
-impl<'n, 'f> NtfsStructuredValue for NtfsAttributeList<'n, 'f> {
+impl<'n, 'f> NtfsStructuredValue<'n, 'f> for NtfsAttributeList<'n, 'f> {
const TY: NtfsAttributeType = NtfsAttributeType::AttributeList;
-}
-impl<'n, 'f> NtfsStructuredValueFromSlice<'f> for NtfsAttributeList<'n, 'f> {
- fn from_slice(slice: &'f [u8], position: u64) -> Result<Self> {
- Ok(Self::Resident(slice, position))
- }
-}
-
-impl<'n, 'f> NtfsStructuredValueFromNonResidentAttributeValue<'n, 'f>
- for NtfsAttributeList<'n, 'f>
-{
- fn from_non_resident_attribute_value<T>(
- _fs: &mut T,
- value: NtfsNonResidentAttributeValue<'n, 'f>,
- ) -> Result<Self>
+ fn from_value<T>(_fs: &mut T, value: NtfsValue<'n, 'f>) -> Result<Self>
where
T: Read + Seek,
{
- Ok(Self::NonResident(value))
+ match value {
+ NtfsValue::Slice(value) => {
+ let slice = value.data();
+ let position = value.data_position().unwrap();
+ Ok(Self::Resident(slice, position))
+ }
+ NtfsValue::NonResidentAttribute(value) => Ok(Self::NonResident(value)),
+ NtfsValue::AttributeListNonResidentAttribute(value) => {
+ // Attribute Lists are never nested.
+ // Hence, we must not create this attribute from an attribute that is already part of Attribute List.
+ let position = value.data_position().unwrap();
+ Err(NtfsError::UnexpectedAttributeListAttribute { position })
+ }
+ }
}
}
@@ -270,8 +268,8 @@ impl NtfsAttributeListEntry {
return Err(NtfsError::InvalidStructuredValueSize {
position: self.position(),
ty: NtfsAttributeType::AttributeList,
- expected: self.list_entry_length() as usize,
- actual: total_size,
+ expected: self.list_entry_length() as u64,
+ actual: total_size as u64,
});
}