1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
use snafu::{Backtrace, Snafu};
use std::path::PathBuf;
use std::{io, result};
pub type Result<T> = result::Result<T, Error>;
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(crate)))]
pub enum Error {
#[snafu(display("An I/O error has occurred: {}", source))]
IoError {
source: std::io::Error,
backtrace: Backtrace,
},
#[snafu(display("Failed to open file {}: {}", path.display(), source))]
FailedToOpenFile {
path: PathBuf,
source: std::io::Error,
},
#[snafu(display("Error while decoding name in filename attribute"))]
InvalidFilename,
#[snafu(display(
"Bad signature: {:x?}, expected one of [b\"FILE\", b\"BAAD\", b\"0000\"]",
bad_sig
))]
InvalidEntrySignature { bad_sig: Vec<u8> },
#[snafu(display("Unknown `AttributeType`: {:04X}", attribute_type))]
UnknownAttributeType { attribute_type: u32 },
#[snafu(display("Unknown filename namespace {}", namespace))]
UnknownNamespace { namespace: u8 },
#[snafu(display("Unhandled resident flag: {} (offset: {})", flag, offset))]
UnhandledResidentFlag { flag: u8, offset: u64 },
#[snafu(display(
"Fixup bytes do not match bytes at end of stride {} {:x?}: {:x?}",
stride_number,
end_of_sector_bytes,
fixup_bytes
))]
FailedToApplyFixup {
stride_number: usize,
end_of_sector_bytes: Vec<u8>,
fixup_bytes: Vec<u8>,
},
#[snafu(display("Failed to read MftReference: `{}`", source))]
FailedToReadMftReference { source: winstructs::err::Error },
#[snafu(display("Failed to read WindowsTime: `{}`", source))]
FailedToReadWindowsTime { source: winstructs::err::Error },
#[snafu(display("Failed to read GUID: `{}`", source))]
FailedToReadGuid { source: winstructs::err::Error },
#[snafu(display("An unexpected error has occurred: {}", detail))]
Any { detail: String },
}
impl From<io::Error> for Error {
fn from(err: io::Error) -> Self {
Error::IoError {
source: err,
backtrace: Backtrace::new(),
}
}
}
|