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:
authorOmer Ben-Amram <omerbenamram@gmail.com>2019-05-13 15:49:56 +0300
committerOmer Ben-Amram <omerbenamram@gmail.com>2019-05-13 15:49:56 +0300
commit4433fe6b87263e9eba82615240de0cc8e7d9c380 (patch)
treeeb088723eabcce0b1889d93ee6c125370fc68e61 /src/attribute
parent52e44e7ab39fae1b53eb437b43d21c9ebb5958e7 (diff)
add more flags
Diffstat (limited to 'src/attribute')
-rw-r--r--src/attribute/header.rs3
-rw-r--r--src/attribute/mod.rs12
-rw-r--r--src/attribute/x30.rs30
3 files changed, 28 insertions, 17 deletions
diff --git a/src/attribute/header.rs b/src/attribute/header.rs
index aea32f3..4920e9a 100644
--- a/src/attribute/header.rs
+++ b/src/attribute/header.rs
@@ -1,4 +1,4 @@
-use crate::attribute::{serialize_attr_data_flags, AttributeDataFlags, AttributeType};
+use crate::attribute::{AttributeDataFlags, AttributeType};
use crate::err::{self, Result};
use crate::utils::read_utf16_string;
use crate::ReadSeek;
@@ -26,7 +26,6 @@ pub struct AttributeHeader {
/// The offset of the attribute name from the start of the attribute record, in bytes.
/// If the NameLength member is 0, this member is undefined.
pub name_offset: Option<u16>,
- #[serde(serialize_with = "serialize_attr_data_flags")]
pub data_flags: AttributeDataFlags,
/// The unique instance for this attribute in the file record.
pub instance: u16,
diff --git a/src/attribute/mod.rs b/src/attribute/mod.rs
index 0aa97b3..dc1bd40 100644
--- a/src/attribute/mod.rs
+++ b/src/attribute/mod.rs
@@ -4,6 +4,8 @@ pub mod x10;
pub mod x30;
use crate::err::{self, Result};
+use crate::impl_serialize_for_bitflags;
+
use bitflags::bitflags;
use num_traits::FromPrimitive;
@@ -72,12 +74,4 @@ bitflags! {
}
}
-pub fn serialize_attr_data_flags<S>(
- item: &AttributeDataFlags,
- serializer: S,
-) -> ::std::result::Result<S::Ok, S::Error>
-where
- S: ser::Serializer,
-{
- serializer.serialize_str(&format!("{:?}", item))
-}
+impl_serialize_for_bitflags! {AttributeDataFlags}
diff --git a/src/attribute/x30.rs b/src/attribute/x30.rs
index 9ab6069..5ee0b96 100644
--- a/src/attribute/x30.rs
+++ b/src/attribute/x30.rs
@@ -1,6 +1,8 @@
use crate::err::{self, Result};
+use crate::impl_serialize_for_bitflags;
use log::trace;
+use bitflags::bitflags;
use byteorder::{LittleEndian, ReadBytesExt};
use encoding::all::UTF_16LE;
use encoding::{DecoderTrap, Encoding};
@@ -23,14 +25,33 @@ pub struct FileNameAttr {
pub accessed: DateTime<Utc>,
pub logical_size: u64,
pub physical_size: u64,
- pub flags: u32,
+ pub flags: FileAttributeFlags,
pub reparse_value: u32,
pub name_length: u8,
pub namespace: u8,
pub name: String,
- pub fullname: Option<String>,
}
+bitflags! {
+ pub struct FileAttributeFlags: u32 {
+ const FILE_ATTRIBUTE_READONLY = 0x0000_0001;
+ const FILE_ATTRIBUTE_HIDDEN = 0x0000_0002;
+ const FILE_ATTRIBUTE_SYSTEM = 0x0000_0004;
+ const FILE_ATTRIBUTE_ARCHIVE = 0x0000_0020;
+ const FILE_ATTRIBUTE_DEVICE = 0x0000_0040;
+ const FILE_ATTRIBUTE_NORMAL = 0x0000_0080;
+ const FILE_ATTRIBUTE_TEMPORARY = 0x0000_0100;
+ const FILE_ATTRIBUTE_SPARSE_FILE = 0x0000_0200;
+ const FILE_ATTRIBUTE_REPARSE_POINT = 0x0000_0400;
+ const FILE_ATTRIBUTE_COMPRESSED = 0x0000_0800;
+ const FILE_ATTRIBUTE_OFFLINE = 0x0000_1000;
+ const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x0000_2000;
+ const FILE_ATTRIBUTE_ENCRYPTED = 0x0000_4000;
+ }
+}
+
+impl_serialize_for_bitflags! {FileAttributeFlags}
+
impl FileNameAttr {
/// Parse a Filename attrbiute buffer.
///
@@ -84,7 +105,7 @@ impl FileNameAttr {
.to_datetime();
let logical_size = reader.read_u64::<LittleEndian>()?;
let physical_size = reader.read_u64::<LittleEndian>()?;
- let flags = reader.read_u32::<LittleEndian>()?;
+ let flags = FileAttributeFlags::from_bits_truncate(reader.read_u32::<LittleEndian>()?);
let reparse_value = reader.read_u32::<LittleEndian>()?;
let name_length = reader.read_u8()?;
let namespace = reader.read_u8()?;
@@ -97,8 +118,6 @@ impl FileNameAttr {
Err(_e) => return err::InvalidFilename {}.fail(),
};
- let fullname = None;
-
Ok(FileNameAttr {
parent,
created,
@@ -112,7 +131,6 @@ impl FileNameAttr {
name_length,
namespace,
name,
- fullname,
})
}
}