Skip to content

Commit 42e2013

Browse files
committed
fs info: add is_directory() and is_regular_file()
1 parent 12e2da2 commit 42e2013

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
- Added `CStr16::as_bytes`
2626
- Added `AsRef<[u8]>` and `Borrow<[u8]>` for `Cstr8` and `CStr16`.
2727
- Added `LoadedImageDevicePath` protocol.
28+
- Added `FileAttribute::is_directory(&self)` and
29+
`FileAttribute::is_regular_file(&self)`
2830

2931
### Changed
3032

uefi/src/proto/media/file/info.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,18 @@ impl FileInfo {
229229
pub fn file_name(&self) -> &CStr16 {
230230
unsafe { CStr16::from_ptr(self.file_name.as_ptr()) }
231231
}
232+
233+
/// Returns if the file is a directory.
234+
#[must_use]
235+
pub fn is_directory(&self) -> bool {
236+
self.attribute.contains(FileAttribute::DIRECTORY)
237+
}
238+
239+
/// Returns if the file is a regular file.
240+
#[must_use]
241+
pub fn is_regular_file(&self) -> bool {
242+
!self.is_directory()
243+
}
232244
}
233245

234246
impl Align for FileInfo {

0 commit comments

Comments
 (0)