Add FileAttr
This commit is contained in:
parent
34f1c2ccf7
commit
d371dabecd
@ -24,6 +24,8 @@ primitive_enum!(
|
||||
NotImplemented = 9,
|
||||
#[doc = "Entry is not a directory"]
|
||||
NotADirectory = 10,
|
||||
#[doc = "Directory is not empty"]
|
||||
DirectoryNotEmpty = 11,
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -63,14 +63,26 @@ primitive_enum!(
|
||||
}
|
||||
);
|
||||
|
||||
/// Describes metadata associated with a filesystem entry
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[repr(C)]
|
||||
pub struct FileAttr {
|
||||
/// Data size for files, UNSPECIFIED for the rest
|
||||
pub size: u64,
|
||||
/// Entry type
|
||||
pub ty: FileType,
|
||||
/// Entry access permissions
|
||||
pub mode: FileMode,
|
||||
}
|
||||
|
||||
impl FileMode {
|
||||
/// File mode with all access bits set
|
||||
pub const fn all() -> Self {
|
||||
Self(0o777)
|
||||
/// Default mode for a regular file
|
||||
pub const fn default_file() -> Self {
|
||||
Self(0o666)
|
||||
}
|
||||
|
||||
/// Default file mode for a regular file
|
||||
pub const fn default_file() -> Self {
|
||||
Self::all()
|
||||
/// Default mode for a directory
|
||||
pub const fn default_dir() -> Self {
|
||||
Self(0o777)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
mod file;
|
||||
mod terminal;
|
||||
|
||||
pub use file::{FileMode, FileType, OpenOptions};
|
||||
pub use file::{FileAttr, FileMode, FileType, OpenOptions};
|
||||
pub use terminal::{
|
||||
TerminalInputOptions, TerminalLineOptions, TerminalOptions, TerminalOutputOptions,
|
||||
};
|
||||
|
@ -24,6 +24,12 @@ primitive_enum!(
|
||||
OpenDirectory = 9,
|
||||
#[doc = "Read entries from a directory descriptor"]
|
||||
ReadDirectory = 10,
|
||||
#[doc = "Create a directory"]
|
||||
CreateDirectory = 11,
|
||||
#[doc = "Remove a file, directory or other entry"]
|
||||
Remove = 12,
|
||||
#[doc = "Retrieves metadata for a filesystem entry"]
|
||||
GetMetadata = 13,
|
||||
|
||||
#[doc = "Mount a filesystem"]
|
||||
Mount = 101,
|
||||
|
Loading…
x
Reference in New Issue
Block a user