simple_fatfs/fat/
options.rs

1use crate::*;
2
3#[cfg(not(feature = "std"))]
4use alloc::boxed::Box;
5
6#[derive(Debug)]
7/// FileSystem mount options
8pub struct FSOptions {
9    pub(crate) clock: Box<dyn Clock>,
10    pub(crate) codepage: codepage::Codepage,
11    pub(crate) update_file_fields: bool,
12}
13
14impl FSOptions {
15    #[inline]
16    /// Create a new options struct with the default options
17    ///
18    /// This is just an alias to [`Self::default`]
19    pub fn new() -> Self {
20        Self::default()
21    }
22
23    /// Set the codepage to be used by the filesystem
24    pub fn set_codepage(&mut self, codepage: Codepage) {
25        self.codepage = codepage
26    }
27
28    /// Set the codepage to be used by the filesystem (chainable)
29    pub fn with_codepage(mut self, codepage: Codepage) -> Self {
30        self.set_codepage(codepage);
31
32        self
33    }
34
35    /// Whether to update the last accessed/modified file fields
36    pub fn set_update_file_fields(&mut self, update: bool) {
37        self.update_file_fields = update
38    }
39
40    /// Whether to update the last accessed/modified file fields (chainable)
41    pub fn with_update_file_fields(mut self, update: bool) -> Self {
42        self.update_file_fields = update;
43
44        self
45    }
46}
47
48impl Default for FSOptions {
49    fn default() -> Self {
50        Self {
51            clock: Box::new(DefaultClock),
52            codepage: codepage::Codepage::CP437,
53            update_file_fields: false,
54        }
55    }
56}