aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / uefi / src / fs / path / mod.rs
| 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | |
| 3 | //! This module offers the [`Path`] and [`PathBuf`] abstractions. |
| 4 | //! |
| 5 | //! # Interoperability with Rust Strings |
| 6 | //! |
| 7 | //! To use Rust strings - `String` and `str` - with this API, first convert them |
| 8 | //! to [`CString16`] or [`CStr16`]. Rust strings do not directly convert to |
| 9 | //! [`Path`] or [`PathBuf`]. |
| 10 | //! |
| 11 | //! # Path Structure |
| 12 | //! |
| 13 | //! Paths use the [`SEPARATOR`] character as separator. Paths are absolute and |
| 14 | //! do not contain `.` or `..` components. However, this can be implemented in |
| 15 | //! the future. |
| 16 | //! |
| 17 | //! [`CString16`]: uefi::data_types::CString16 |
| 18 | |
| 19 | mod path; |
| 20 | mod pathbuf; |
| 21 | mod validation; |
| 22 | |
| 23 | pub use path::{Components, Path}; |
| 24 | pub use pathbuf::PathBuf; |
| 25 | |
| 26 | use crate::data_types::chars::NUL_16; |
| 27 | use crate::{CStr16, Char16, char16, cstr16}; |
| 28 | pub use validation::PathError; |
| 29 | pub(super) use validation::validate_path; |
| 30 | |
| 31 | /// The default separator for paths. |
| 32 | pub const SEPARATOR: Char16 = char16!('\\'); |
| 33 | |
| 34 | /// Stringified version of [`SEPARATOR`]. |
| 35 | pub const SEPARATOR_STR: &CStr16 = cstr16!("\\"); |
| 36 | |
| 37 | /// Deny list of characters for path components. UEFI supports FAT-like file |
| 38 | /// systems. According to <https://en.wikipedia.org/wiki/Comparison_of_file_systems>, |
| 39 | /// paths should not contain these symbols. |
| 40 | pub const CHARACTER_DENY_LIST: [Char16; 10] = { |
| 41 | [ |
| 42 | NUL_16, |
| 43 | char16!('"'), |
| 44 | char16!('*'), |
| 45 | char16!('/'), |
| 46 | char16!(':'), |
| 47 | char16!('<'), |
| 48 | char16!('>'), |
| 49 | char16!('?'), |
| 50 | SEPARATOR, |
| 51 | char16!('|'), |
| 52 | ] |
| 53 | }; |