1 //! A high-level file system API for UEFI applications close to the `std::fs`
2 //! module from Rust's standard library. The main export of this module is
3 //! [`FileSystem`].
4 //!
5 //! # Difference to typical File System Abstractions
6 //! Users perform actions on dedicated volumes: For example, the boot volume,
7 //! such as a CD-rom, USB-stick, or any other storage device.
8 //!
9 //! Unlike in the API of typical UNIX file system abstractions, there is
10 //! no virtual file system. Unlike in Windows, there is no way to access volumes
11 //! by a dedicated name.
12 //!
13 //! # Paths
14 //! All paths are absolute and follow the FAT-like file system conventions for
15 //! paths. Thus, there is no current working directory and path components
16 //! like `.` and `..` are not supported. In other words, the current working
17 //! directory is always `/`, i.e., the root, of the opened volume.
18 //!
19 //! Symlinks or hard-links are not supported but only directories and regular
20 //! files with plain linear paths to them. For more information, see
21 //! [`Path`] and [`PathBuf`].
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::proto::media::fs::SimpleFileSystem;
31 //! use uefi::boot::{self, ScopedProtocol};
32 //!
33 //! fn read_file(path: &str) -> FileSystemResult<Vec<u8>> {
34 //!     let path: CString16 = CString16::try_from(path).unwrap();
35 //!     let fs: ScopedProtocol<SimpleFileSystem> = boot::get_image_file_system(boot::image_handle()).unwrap();
36 //!     let mut fs = FileSystem::new(fs);
37 //!     fs.read(path.as_ref())
38 //! }
39 //! ```
40 //!
41 //! # API Hints
42 //! There is no `File` abstraction as in the Rust `std` library. Instead, it is
43 //! intended to work with the file system via dedicated functions, similar to
44 //! the public functions of the `std::fs` module.
45 //!
46 //! There is no automatic synchronization of the file system for concurrent
47 //! accesses. This is in the responsibility of the user.
48 //!
49 //! [`cstr16!`]: crate::cstr16
50 
51 mod dir_entry_iter;
52 mod file_system;
53 mod path;
54 mod uefi_types;
55 
56 pub use dir_entry_iter::*;
57 pub use file_system::*;
58 pub use path::*;
59 
60 use uefi_types::*;
61