Skip to content

Commit 92e9686

Browse files
committed
fs: add and export constant COMMON_SKIP_DIRS
1 parent e3c6331 commit 92e9686

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

uefi/src/fs/dir_entry_iter.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
//! Module for directory iteration. See [`UefiDirectoryIter`].
22
33
use super::*;
4-
use crate::Result;
4+
use crate::{CStr16, Result};
55
use alloc::boxed::Box;
6+
use uefi_macros::cstr16;
7+
8+
/// Common skip dirs in UEFI/FAT-style file systems.
9+
pub const COMMON_SKIP_DIRS: &[&CStr16] = &[cstr16!("."), cstr16!("..")];
610

711
/// Iterates over the entries of an UEFI directory. It returns boxed values of
812
/// type [`UefiFileInfo`].
@@ -14,6 +18,7 @@ pub struct UefiDirectoryIter(UefiDirectoryHandle);
1418

1519
impl UefiDirectoryIter {
1620
/// Constructor.
21+
#[must_use]
1722
pub fn new(handle: UefiDirectoryHandle) -> Self {
1823
Self(handle)
1924
}

uefi/src/fs/file_system/fs.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ use core::fmt;
1111
use core::fmt::{Debug, Formatter};
1212
use core::ops::Deref;
1313
use log::debug;
14-
use uefi::CStr16;
15-
use uefi_macros::cstr16;
1614

1715
/// Return type for public [`FileSystem`] operations.
1816
pub type FileSystemResult<T> = Result<T, Error>;
@@ -188,13 +186,12 @@ impl<'a> FileSystem<'a> {
188186
/// Removes a directory at this path, after removing all its contents. Use
189187
/// carefully!
190188
pub fn remove_dir_all(&mut self, path: impl AsRef<Path>) -> FileSystemResult<()> {
191-
const SKIP_DIRS: [&CStr16; 2] = [cstr16!("."), cstr16!("..")];
192189
let path = path.as_ref();
193190
for file_info in self
194191
.read_dir(path)?
195192
.filter_map(|file_info_result| file_info_result.ok())
196193
{
197-
if SKIP_DIRS.contains(&file_info.file_name()) {
194+
if COMMON_SKIP_DIRS.contains(&file_info.file_name()) {
198195
continue;
199196
}
200197

uefi/src/fs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ mod file_system;
3535
mod path;
3636
mod uefi_types;
3737

38+
pub use dir_entry_iter::*;
3839
pub use file_system::*;
3940
pub use path::*;
4041

41-
use dir_entry_iter::*;
4242
use uefi_types::*;

0 commit comments

Comments
 (0)