Struct fm::fileinfo::PathContent
source · pub struct PathContent {
pub path: PathBuf,
pub content: Vec<FileInfo>,
pub index: usize,
pub users_cache: UsersCache,
/* private fields */
}Expand description
Holds the information about file in the current directory. We know about the current path, the files themselves, the selected index, the “display all files including hidden” flag and the key to sort files.
Fields§
§path: PathBufThe current path
content: Vec<FileInfo>A vector of FileInfo with every file in current path
index: usizeThe index of the selected file.
users_cache: UsersCacheImplementations§
source§impl PathContent
impl PathContent
sourcepub fn new(
path: &Path,
users_cache: UsersCache,
filter: &FilterKind,
show_hidden: bool
) -> FmResult<Self>
pub fn new( path: &Path, users_cache: UsersCache, filter: &FilterKind, show_hidden: bool ) -> FmResult<Self>
Reads the paths and creates a new PathContent.
Files are sorted by filename by default.
Selects the first file if any.
pub fn change_directory( &mut self, path: &Path, filter: &FilterKind, show_hidden: bool ) -> FmResult<()>
sourcepub fn path_to_str(&self) -> FmResult<&str>
pub fn path_to_str(&self) -> FmResult<&str>
Convert a path to a &str. It may fails if the path contains non valid utf-8 chars.
sourcepub fn owner_column_width(&self) -> usize
pub fn owner_column_width(&self) -> usize
Calculates the size of the owner column.
sourcepub fn group_column_width(&self) -> usize
pub fn group_column_width(&self) -> usize
Calculates the size of the group column.
sourcepub fn select_index(&mut self, index: usize)
pub fn select_index(&mut self, index: usize)
Select the file from a given index.
sourcepub fn reset_files(
&mut self,
filter: &FilterKind,
show_hidden: bool
) -> Result<(), FmError>
pub fn reset_files( &mut self, filter: &FilterKind, show_hidden: bool ) -> Result<(), FmError>
Reset the current file content. Reads and sort the content with current key. Select the first file if any.
sourcepub fn selected_path_string(&self) -> Option<String>
pub fn selected_path_string(&self) -> Option<String>
Path of the currently selected file.
sourcepub fn is_selected_dir(&self) -> FmResult<bool>
pub fn is_selected_dir(&self) -> FmResult<bool>
Is the selected file a directory ? It may fails if the current path is empty, aka if nothing is selected.
pub fn true_len(&self) -> usize
sourcepub fn used_space(&self) -> String
pub fn used_space(&self) -> String
Human readable string representation of the space used by files in current path. No recursive exploration of directory.
sourcepub fn git_string(&self) -> FmResult<String>
pub fn git_string(&self) -> FmResult<String>
A string representation of the git status of the path.
sourcepub fn update_sort_from_char(&mut self, c: char)
pub fn update_sort_from_char(&mut self, c: char)
Update the kind of sort from a char typed by the user.
sourcepub fn unselect_current(&mut self)
pub fn unselect_current(&mut self)
Unselect the current item. Since we use a common trait to navigate the files, this method is required.
sourcepub fn select_current(&mut self)
pub fn select_current(&mut self)
Select the current item. Since we use a common trait to navigate the files, this method is required.
sourcepub fn enumerate(&mut self) -> Enumerate<Iter<'_, FileInfo>>
pub fn enumerate(&mut self) -> Enumerate<Iter<'_, FileInfo>>
Returns an enumeration of the files (FileInfo) in content.
sourcepub fn refresh_users(
&mut self,
users_cache: UsersCache,
filter: &FilterKind,
show_hidden: bool
) -> FmResult<()>
pub fn refresh_users( &mut self, users_cache: UsersCache, filter: &FilterKind, show_hidden: bool ) -> FmResult<()>
Refresh the existing users.
Trait Implementations§
source§impl SelectableContent<FileInfo> for PathContent
impl SelectableContent<FileInfo> for PathContent
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.