DirEntry: added more methods

This commit is contained in:
Moritz Gmeiner 2025-07-27 23:15:28 +02:00
commit b3d87687dd

View file

@ -192,10 +192,30 @@ impl DirEntry {
self.is_dot() || self.is_dotdot() || self.attr.contains(Attr::Hidden) 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] { pub fn name(&self) -> &[u8] {
&self.name &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<String> { pub fn name_string(&self) -> Option<String> {
if let Some(long_filename) = self.long_name() { if let Some(long_filename) = self.long_name() {
return Some(long_filename.to_owned()); return Some(long_filename.to_owned());