1 //! This module offers the [`Path`] and [`PathBuf`] abstractions.
2 //!
3 //! # Interoperability with Rust strings
4 //!
5 //! For the interoperability with Rust strings, i.e., `String` and `str` from
6 //! the standard library, the API is intended to transform these types first to
7 //! `CString16` respectively `CStr16`. They do not directly translate to
8 //! [`Path`] and [`PathBuf`].
9 //!
10 //! # Path Structure
11 //!
12 //! Paths use the [`SEPARATOR`] character as separator. Paths are absolute and
13 //! do not contain `.` or `..` components. However, this can be implemented in
14 //! the future.
15 
16 mod path;
17 mod pathbuf;
18 mod validation;
19 
20 pub use path::{Components, Path};
21 pub use pathbuf::PathBuf;
22 
23 use crate::data_types::chars::NUL_16;
24 use crate::{cstr16, CStr16, Char16};
25 pub(super) use validation::validate_path;
26 pub use validation::PathError;
27 
28 /// The default separator for paths.
29 pub const SEPARATOR: Char16 = unsafe { Char16::from_u16_unchecked('\\' as u16) };
30 
31 /// Stringified version of [`SEPARATOR`].
32 pub const SEPARATOR_STR: &CStr16 = cstr16!("\\");
33 
34 /// Deny list of characters for path components. UEFI supports FAT-like file
35 /// systems. According to <https://en.wikipedia.org/wiki/Comparison_of_file_systems>,
36 /// paths should not contain these symbols.
37 pub const CHARACTER_DENY_LIST: [Char16; 10] = unsafe {
38     [
39         NUL_16,
40         Char16::from_u16_unchecked('"' as u16),
41         Char16::from_u16_unchecked('*' as u16),
42         Char16::from_u16_unchecked('/' as u16),
43         Char16::from_u16_unchecked(':' as u16),
44         Char16::from_u16_unchecked('<' as u16),
45         Char16::from_u16_unchecked('>' as u16),
46         Char16::from_u16_unchecked('?' as u16),
47         SEPARATOR,
48         Char16::from_u16_unchecked('|' as u16),
49     ]
50 };
51