|
1 | 1 | //! A high-level file system API for UEFI applications close to the `std::fs`
|
2 |
| -//! module from Rust's standard library. The main type by this module is |
| 2 | +//! module from Rust's standard library. The main export of this module is |
3 | 3 | //! [`FileSystem`].
|
4 | 4 | //!
|
5 | 5 | //! # Difference to typical File System Abstractions
|
|
20 | 20 | //! files with plain linear paths to them. For more information, see
|
21 | 21 | //! [`Path`] and [`PathBuf`].
|
22 | 22 | //!
|
| 23 | +//! ## Use `&str` as Path |
| 24 | +//! A `&str` known at compile time can be converted to a [`Path`] using the |
| 25 | +//! [`cstr16!`] macro. During runtime, you can create a path like this: |
| 26 | +//! |
| 27 | +//! ```no_run |
| 28 | +//! use uefi::CString16; |
| 29 | +//! use uefi::fs::{FileSystem, FileSystemResult}; |
| 30 | +//! use uefi::prelude::BootServices; |
| 31 | +//! use uefi::proto::media::fs::SimpleFileSystem; |
| 32 | +//! use uefi::table::boot::ScopedProtocol; |
| 33 | +//! |
| 34 | +//! fn read_file(bs: BootServices, path: &str) -> FileSystemResult<Vec<u8>> { |
| 35 | +//! let path: CString16 = CString16::try_from(path).unwrap(); |
| 36 | +//! let fs: ScopedProtocol<SimpleFileSystem> = bs.get_image_file_system(bs.image_handle()).unwrap(); |
| 37 | +//! let mut fs = FileSystem::new(fs); |
| 38 | +//! fs.read(path.as_ref()) |
| 39 | +//! } |
| 40 | +//! ``` |
| 41 | +//! |
23 | 42 | //! # API Hints
|
24 | 43 | //! There is no `File` abstraction as in the Rust `std` library. Instead, it is
|
25 | 44 | //! intended to work with the file system via dedicated functions, similar to
|
26 | 45 | //! the public functions of the `std::fs` module.
|
27 | 46 | //!
|
28 | 47 | //! There is no automatic synchronization of the file system for concurrent
|
29 | 48 | //! accesses. This is in the responsibility of the user.
|
| 49 | +//! |
| 50 | +//! [`cstr16!`]: uefi_macros::cstr16 |
30 | 51 |
|
31 | 52 | mod dir_entry_iter;
|
32 | 53 | mod file_system;
|
|
0 commit comments