pub struct FileInfo {
pub path: Arc<Path>,
pub filename: Arc<str>,
pub size_column: SizeColumn,
pub true_size: u64,
pub owner: Arc<str>,
pub group: Arc<str>,
pub system_time: Arc<str>,
pub file_kind: FileKind<bool>,
pub extension: Arc<str>,
}Expand description
Infos about a file We read and keep tracks every displayable information about a file.
Fields§
§path: Arc<Path>Full path of the file
filename: Arc<str>Filename
size_column: SizeColumnFile size as a String, already human formated.
For char devices and block devices we display major & minor like ls.
true_size: u64True size of a file, not formated
owner: Arc<str>Owner name of the file.
group: Arc<str>Group name of the file.
system_time: Arc<str>System time of last modification
file_kind: FileKind<bool>What kind of file is this ?
extension: Arc<str>Extension of the file. "" for a directory.
Implementations§
Source§impl FileInfo
impl FileInfo
pub fn new(path: &Path, users: &Users) -> Result<Self>
Sourcepub fn from_direntry(direntry: &DirEntry, users: &Users) -> Result<FileInfo>
pub fn from_direntry(direntry: &DirEntry, users: &Users) -> Result<FileInfo>
Reads every information about a file from its metadata and returs
a new FileInfo object if we can create one.
Sourcepub fn from_path_with_name(
path: &Path,
filename: &str,
users: &Users,
) -> Result<Self>
pub fn from_path_with_name( path: &Path, filename: &str, users: &Users, ) -> Result<Self>
Creates a fileinfo from a path and a filename. The filename is used when we create the fileinfo for “.” and “..” in every folder.
Sourcepub fn metadata(&self) -> Result<Metadata>
pub fn metadata(&self) -> Result<Metadata>
Symlink metadata of the file.
Doesn’t follow the symlinks.
Correspond to lstat function on Linux.
See std::fs::symlink_metadata.
§Errors
Could return an error if the file doesn’t exist or if the user can’t stat it.
Sourcepub fn permissions(&self) -> Result<Arc<str>>
pub fn permissions(&self) -> Result<Arc<str>>
String representation of file permissions
Sourcepub fn kind_format(&self) -> String
pub fn kind_format(&self) -> String
A formated filename where the “kind” of file (directory, char device, block devive, fifo, socket, normal) is prepend to the name, allowing a “sort by kind” method.
Sourcepub fn format_metadata(
&self,
owner_col_width: usize,
group_col_width: usize,
) -> String
pub fn format_metadata( &self, owner_col_width: usize, group_col_width: usize, ) -> String
Format the file line. Since files can have different owners in the same directory, we need to know the maximum size of owner column for formatting purpose.
pub fn format_no_group(&self, owner_col_width: usize) -> String
pub fn format_no_permissions(&self, owner_col_width: usize) -> String
pub fn format_no_owner(&self) -> String
pub fn format_base( &self, owner_col_width: usize, group_col_width: usize, ) -> String
Sourcepub fn format_no_filename(&self) -> String
pub fn format_no_filename(&self) -> String
Format the metadata line, without the filename. Owned & Group have fixed width of 6.
pub fn dir_symbol(&self) -> char
True iff the file is hidden (aka starts with a ‘.’).
pub fn is_dir(&self) -> bool
Sourcepub fn filename_without_dot_dotdot(&self) -> String
pub fn filename_without_dot_dotdot(&self) -> String
Formated proper name.
“/ “ for .
pub fn style(&self) -> Style
Trait Implementations§
Source§impl Content<FileInfo> for Directory
Implement a selectable content for this struct.
This trait allows to navigate through a vector of element content_type.
It implements: is_empty, len, next, prev, selected.
selected returns an optional reference to the value.
impl Content<FileInfo> for Directory
Implement a selectable content for this struct.
This trait allows to navigate through a vector of element content_type.
It implements: is_empty, len, next, prev, selected.
selected returns an optional reference to the value.
Source§impl IndexToIndex<FileInfo> for Directory
impl IndexToIndex<FileInfo> for Directory
Auto Trait Implementations§
impl Freeze for FileInfo
impl RefUnwindSafe for FileInfo
impl Send for FileInfo
impl Sync for FileInfo
impl Unpin for FileInfo
impl UnwindSafe for FileInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more