1pub trait BlockDevice {
7 #[allow(clippy::result_unit_err)]
16 fn read_block(&self, block: u32, buf: &mut [u8; 512]) -> Result<(), ()>;
17}
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21pub enum FsType {
22 Ofs,
24 Ffs,
26}
27
28impl FsType {
29 #[inline]
31 pub const fn data_block_size(self) -> usize {
32 match self {
33 Self::Ofs => crate::OFS_DATA_SIZE,
34 Self::Ffs => crate::FFS_DATA_SIZE,
35 }
36 }
37}
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41pub enum EntryType {
42 Root,
44 Dir,
46 File,
48 HardLinkFile,
50 HardLinkDir,
52 SoftLink,
54}
55
56impl EntryType {
57 pub const fn from_sec_type(sec_type: i32) -> Option<Self> {
59 match sec_type {
60 crate::ST_ROOT => Some(Self::Root),
61 crate::ST_DIR => Some(Self::Dir),
62 crate::ST_FILE => Some(Self::File),
63 crate::ST_LFILE => Some(Self::HardLinkFile),
64 crate::ST_LDIR => Some(Self::HardLinkDir),
65 crate::ST_LSOFT => Some(Self::SoftLink),
66 _ => None,
67 }
68 }
69
70 #[inline]
72 pub const fn is_dir(self) -> bool {
73 matches!(self, Self::Root | Self::Dir | Self::HardLinkDir)
74 }
75
76 #[inline]
78 pub const fn is_file(self) -> bool {
79 matches!(self, Self::File | Self::HardLinkFile)
80 }
81}
82
83#[derive(Debug, Clone, Copy, Default)]
85pub struct FsFlags {
86 pub intl: bool,
88 pub dircache: bool,
90}
91
92impl FsFlags {
93 #[inline]
95 pub const fn from_dos_type(dos_type: u8) -> Self {
96 Self {
97 intl: (dos_type & crate::DOSFS_INTL) != 0,
98 dircache: (dos_type & crate::DOSFS_DIRCACHE) != 0,
99 }
100 }
101}
102
103#[derive(Debug, Clone, Copy, Default)]
105pub struct Access(pub u32);
106
107impl Access {
108 #[inline]
110 pub const fn new(raw: u32) -> Self {
111 Self(raw)
112 }
113
114 #[inline]
116 pub const fn is_delete_protected(self) -> bool {
117 (self.0 & crate::ACC_DELETE) != 0
118 }
119
120 #[inline]
122 pub const fn is_execute_protected(self) -> bool {
123 (self.0 & crate::ACC_EXECUTE) != 0
124 }
125
126 #[inline]
128 pub const fn is_write_protected(self) -> bool {
129 (self.0 & crate::ACC_WRITE) != 0
130 }
131
132 #[inline]
134 pub const fn is_read_protected(self) -> bool {
135 (self.0 & crate::ACC_READ) != 0
136 }
137
138 #[inline]
140 pub const fn is_archived(self) -> bool {
141 (self.0 & crate::ACC_ARCHIVE) != 0
142 }
143
144 #[inline]
146 pub const fn is_pure(self) -> bool {
147 (self.0 & crate::ACC_PURE) != 0
148 }
149
150 #[inline]
152 pub const fn is_script(self) -> bool {
153 (self.0 & crate::ACC_SCRIPT) != 0
154 }
155
156 #[inline]
158 pub const fn is_hold(self) -> bool {
159 (self.0 & crate::ACC_HOLD) != 0
160 }
161}