FileInfo

Struct FileInfo 

Source
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: SizeColumn

File size as a String, already human formated. For char devices and block devices we display major & minor like ls.

§true_size: u64

True 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

Source

pub fn new(path: &Path, users: &Users) -> Result<Self>

Source

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.

Source

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.

Source

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.

Source

pub fn ino(&self) -> u64

Returns the Inode number.

Returns 0 if the metadata can’t be read.

Source

pub fn permissions(&self) -> Result<Arc<str>>

String representation of file permissions

Source

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.

Source

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.

Source

pub fn format_no_group(&self, owner_col_width: usize) -> String

Source

pub fn format_no_permissions(&self, owner_col_width: usize) -> String

Source

pub fn format_no_owner(&self) -> String

Source

pub fn format_base( &self, owner_col_width: usize, group_col_width: usize, ) -> String

Source

pub fn format_no_filename(&self) -> String

Format the metadata line, without the filename. Owned & Group have fixed width of 6.

Source

pub fn dir_symbol(&self) -> char

Source

pub fn is_hidden(&self) -> bool

True iff the file is hidden (aka starts with a ‘.’).

Source

pub fn is_dir(&self) -> bool

Source

pub fn filename_without_dot_dotdot(&self) -> String

Formated proper name. “/ “ for .

Source

pub fn style(&self) -> Style

Trait Implementations§

Source§

impl Clone for FileInfo

Source§

fn clone(&self) -> FileInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
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.

Source§

fn selected(&self) -> Option<&FileInfo>

Returns a reference to the selected content.

Source§

fn content(&self) -> &Vec<FileInfo>

A reference to the content.

Source§

fn style(&self, index: usize, style: &Style) -> Style

Reverse the received effect if the index match the selected index.

Source§

fn push(&mut self, element: FileInfo)

Push a new element at the end of content

Source§

impl Debug for FileInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Icon for FileInfo

Source§

fn icon(&self) -> &'static str

Icon for a file given by its fileinfo.

Source§

impl IndexToIndex<FileInfo> for Directory

Source§

fn index_to_index( &self, ) -> Chain<Skip<Iter<'_, FileInfo>>, Take<Iter<'_, FileInfo>>>

Iterate over line from current index to bottom then from top to current index.

Useful when going to next match in search results

Source§

impl ToPath for FileInfo

Source§

fn to_path(&self) -> &Path

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSend for T
where T: Send,