DirEntry: added more methods
This commit is contained in:
parent
9ad94e9634
commit
b3d87687dd
1 changed files with 20 additions and 0 deletions
|
|
@ -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());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue