diff --git a/fat-bits/src/dir.rs b/fat-bits/src/dir.rs index 98ff94c..bc8e7a4 100644 --- a/fat-bits/src/dir.rs +++ b/fat-bits/src/dir.rs @@ -192,10 +192,30 @@ impl DirEntry { self.is_dot() || self.is_dotdot() || self.attr.contains(Attr::Hidden) } + pub fn is_readonly(&self) -> bool { + self.attr.contains(Attr::ReadOnly) + } + pub fn name(&self) -> &[u8] { &self.name } + pub fn stem(&self) -> &[u8] { + &self.name()[..8] + } + + pub fn stem_str(&self) -> Option<&str> { + std::str::from_utf8(self.stem()).ok() + } + + pub fn extension(&self) -> &[u8] { + &self.name()[8..] + } + + pub fn extension_str(&self) -> Option<&str> { + std::str::from_utf8(self.extension()).ok() + } + pub fn name_string(&self) -> Option { if let Some(long_filename) = self.long_name() { return Some(long_filename.to_owned());