uefi: fs: Implement FileType
- Similar to FilePermissions, using bool to represent the bitfield. - FileType cannot be changed, so no need to worry about converting back to attribute. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
This commit is contained in:
parent
1833737e16
commit
c717cc7cd2
1 changed files with 10 additions and 30 deletions
|
@ -1,6 +1,6 @@
|
||||||
use crate::ffi::OsString;
|
use crate::ffi::OsString;
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::hash::{Hash, Hasher};
|
use crate::hash::Hash;
|
||||||
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
|
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
|
||||||
use crate::path::{Path, PathBuf};
|
use crate::path::{Path, PathBuf};
|
||||||
use crate::sys::time::SystemTime;
|
use crate::sys::time::SystemTime;
|
||||||
|
@ -27,7 +27,9 @@ pub struct FileTimes {}
|
||||||
// Bool indicates if file is readonly
|
// Bool indicates if file is readonly
|
||||||
pub struct FilePermissions(bool);
|
pub struct FilePermissions(bool);
|
||||||
|
|
||||||
pub struct FileType(!);
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||||
|
// Bool indicates if directory
|
||||||
|
pub struct FileType(bool);
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DirBuilder {}
|
pub struct DirBuilder {}
|
||||||
|
@ -95,39 +97,17 @@ impl FileType {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_file(&self) -> bool {
|
pub fn is_file(&self) -> bool {
|
||||||
self.0
|
!self.is_dir()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Symlinks are not supported in UEFI
|
||||||
pub fn is_symlink(&self) -> bool {
|
pub fn is_symlink(&self) -> bool {
|
||||||
self.0
|
false
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for FileType {
|
#[expect(dead_code)]
|
||||||
fn clone(&self) -> FileType {
|
const fn from_attr(attr: u64) -> Self {
|
||||||
self.0
|
Self(attr & r_efi::protocols::file::DIRECTORY != 0)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Copy for FileType {}
|
|
||||||
|
|
||||||
impl PartialEq for FileType {
|
|
||||||
fn eq(&self, _other: &FileType) -> bool {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Eq for FileType {}
|
|
||||||
|
|
||||||
impl Hash for FileType {
|
|
||||||
fn hash<H: Hasher>(&self, _h: &mut H) {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for FileType {
|
|
||||||
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
self.0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue