diff --git a/src/core.rs b/src/core.rs index 07ce931e8..bd8d8c442 100644 --- a/src/core.rs +++ b/src/core.rs @@ -88,13 +88,14 @@ impl Core { }; for path in paths { - let mut meta = match Meta::from_path(&path, self.flags.dereference.0) { - Ok(meta) => meta, - Err(err) => { - print_error!("{}: {}.", path.display(), err); - continue; - } - }; + let mut meta = + match Meta::from_path(&path, self.flags.dereference.0, &self.flags.blocks) { + Ok(meta) => meta, + Err(err) => { + print_error!("{}: {}.", path.display(), err); + continue; + } + }; let recurse = self.flags.layout == Layout::Tree || self.flags.display != Display::DirectoryOnly; diff --git a/src/flags/blocks.rs b/src/flags/blocks.rs index e62182bbc..30d026e93 100644 --- a/src/flags/blocks.rs +++ b/src/flags/blocks.rs @@ -116,7 +116,7 @@ impl Blocks { /// /// It contains the [Block]s [Permission](Block::Permission), [User](Block::User), /// [Group](Block::Group), [Size](Block::Size), [Date](Block::Date) and [Name](Block::Name). - fn long() -> Self { + pub fn long() -> Self { Self(vec![ Block::Permission, Block::User, diff --git a/src/icon.rs b/src/icon.rs index 5a89dc3e2..db80e2766 100644 --- a/src/icon.rs +++ b/src/icon.rs @@ -346,6 +346,7 @@ impl Icons { #[cfg(test)] mod test { use super::{Icons, Theme}; + use crate::flags::Blocks; use crate::meta::Meta; use std::fs::File; use tempfile::tempdir; @@ -355,7 +356,7 @@ mod test { let tmp_dir = tempdir().expect("failed to create temp dir"); let file_path = tmp_dir.path().join("file.txt"); File::create(&file_path).expect("failed to create file"); - let meta = Meta::from_path(&file_path, false).unwrap(); + let meta = Meta::from_path(&file_path, false, &Blocks::long()).unwrap(); let icon = Icons::new(Theme::NoIcon, " ".to_string()); let icon = icon.get(&meta.name); @@ -368,7 +369,7 @@ mod test { let tmp_dir = tempdir().expect("failed to create temp dir"); let file_path = tmp_dir.path().join("file"); File::create(&file_path).expect("failed to create file"); - let meta = Meta::from_path(&file_path, false).unwrap(); + let meta = Meta::from_path(&file_path, false, &Blocks::long()).unwrap(); let icon = Icons::new(Theme::Fancy, " ".to_string()); let icon_str = icon.get(&meta.name); @@ -381,7 +382,7 @@ mod test { let tmp_dir = tempdir().expect("failed to create temp dir"); let file_path = tmp_dir.path().join("file"); File::create(&file_path).expect("failed to create file"); - let meta = Meta::from_path(&file_path, false).unwrap(); + let meta = Meta::from_path(&file_path, false, &Blocks::long()).unwrap(); let icon = Icons::new(Theme::Unicode, " ".to_string()); let icon_str = icon.get(&meta.name); @@ -393,7 +394,7 @@ mod test { fn get_directory_icon() { let tmp_dir = tempdir().expect("failed to create temp dir"); let file_path = tmp_dir.path(); - let meta = Meta::from_path(&file_path.to_path_buf(), false).unwrap(); + let meta = Meta::from_path(&file_path.to_path_buf(), false, &Blocks::long()).unwrap(); let icon = Icons::new(Theme::Fancy, " ".to_string()); let icon_str = icon.get(&meta.name); @@ -405,7 +406,7 @@ mod test { fn get_directory_icon_unicode() { let tmp_dir = tempdir().expect("failed to create temp dir"); let file_path = tmp_dir.path(); - let meta = Meta::from_path(&file_path.to_path_buf(), false).unwrap(); + let meta = Meta::from_path(&file_path.to_path_buf(), false, &Blocks::long()).unwrap(); let icon = Icons::new(Theme::Unicode, " ".to_string()); let icon_str = icon.get(&meta.name); @@ -417,7 +418,7 @@ mod test { fn get_directory_icon_with_ext() { let tmp_dir = tempdir().expect("failed to create temp dir"); let file_path = tmp_dir.path(); - let meta = Meta::from_path(&file_path.to_path_buf(), false).unwrap(); + let meta = Meta::from_path(&file_path.to_path_buf(), false, &Blocks::long()).unwrap(); let icon = Icons::new(Theme::Fancy, " ".to_string()); let icon_str = icon.get(&meta.name); @@ -432,7 +433,7 @@ mod test { for (file_name, file_icon) in &Icons::get_default_icons_by_name() { let file_path = tmp_dir.path().join(file_name); File::create(&file_path).expect("failed to create file"); - let meta = Meta::from_path(&file_path, false).unwrap(); + let meta = Meta::from_path(&file_path, false, &Blocks::long()).unwrap(); let icon = Icons::new(Theme::Fancy, " ".to_string()); let icon_str = icon.get(&meta.name); @@ -448,7 +449,7 @@ mod test { for (ext, file_icon) in &Icons::get_default_icons_by_extension() { let file_path = tmp_dir.path().join(format!("file.{}", ext)); File::create(&file_path).expect("failed to create file"); - let meta = Meta::from_path(&file_path, false).unwrap(); + let meta = Meta::from_path(&file_path, false, &Blocks::long()).unwrap(); let icon = Icons::new(Theme::Fancy, " ".to_string()); let icon_str = icon.get(&meta.name); diff --git a/src/meta/filetype.rs b/src/meta/filetype.rs index e7c275f8c..4ad2a4262 100644 --- a/src/meta/filetype.rs +++ b/src/meta/filetype.rs @@ -108,6 +108,7 @@ impl FileType { mod test { use super::FileType; use crate::color::{Colors, Theme}; + use crate::flags::Blocks; use crate::meta::Meta; #[cfg(unix)] use crate::meta::Permissions; @@ -141,7 +142,7 @@ mod test { #[test] fn test_dir_type() { let tmp_dir = tempdir().expect("failed to create temp dir"); - let meta = Meta::from_path(&tmp_dir.path().to_path_buf(), false) + let meta = Meta::from_path(&tmp_dir.path().to_path_buf(), false, &Blocks::long()) .expect("failed to get tempdir path"); let metadata = tmp_dir.path().metadata().expect("failed to get metas"); diff --git a/src/meta/mod.rs b/src/meta/mod.rs index a7f05f2e1..9e3ddca92 100644 --- a/src/meta/mod.rs +++ b/src/meta/mod.rs @@ -22,7 +22,7 @@ pub use self::size::Size; pub use self::symlink::SymLink; pub use crate::icon::Icons; -use crate::flags::{Display, Flags, Layout}; +use crate::flags::{Block, Blocks, Display, Flags, Layout}; use crate::print_error; use std::fs::read_link; @@ -84,8 +84,11 @@ impl Meta { current_meta = self.clone(); current_meta.name.name = ".".to_owned(); - let parent_meta = - Self::from_path(&self.path.join(Component::ParentDir), flags.dereference.0)?; + let parent_meta = Self::from_path( + &self.path.join(Component::ParentDir), + flags.dereference.0, + &flags.blocks, + )?; content.push(current_meta); content.push(parent_meta); @@ -109,7 +112,7 @@ impl Meta { } } - let mut entry_meta = match Self::from_path(&path, flags.dereference.0) { + let mut entry_meta = match Self::from_path(&path, flags.dereference.0, &flags.blocks) { Ok(res) => res, Err(err) => { print_error!("{}: {}.", path.display(), err); @@ -200,7 +203,11 @@ impl Meta { } } - pub fn from_path(path: &Path, dereference: bool) -> Result { + pub fn from_path( + path: &Path, + dereference: bool, + blocks: &Blocks, + ) -> Result { // If the file is a link then retrieve link metadata instead with target metadata (if present). let (metadata, symlink_meta) = if read_link(path).is_ok() && !dereference { (path.symlink_metadata()?, path.metadata().ok()) @@ -208,13 +215,18 @@ impl Meta { (path.metadata()?, None) }; + let get_owner = blocks.0.contains(&Block::User); + let get_group = blocks.0.contains(&Block::Group); + let get_permissions = blocks.0.contains(&Block::Permission); + #[cfg(unix)] let owner = Owner::from(&metadata); #[cfg(unix)] let permissions = Permissions::from(&metadata); #[cfg(windows)] - let (owner, permissions) = windows_utils::get_file_data(&path)?; + let (owner, permissions) = + windows_utils::get_file_data(&path, get_owner, get_group, get_permissions)?; let file_type = FileType::new(&metadata, symlink_meta.as_ref(), &permissions); let name = Name::new(&path, file_type); diff --git a/src/meta/name.rs b/src/meta/name.rs index ecb932813..fd3a76784 100644 --- a/src/meta/name.rs +++ b/src/meta/name.rs @@ -166,6 +166,7 @@ mod test { use super::DisplayOption; use super::Name; use crate::color::{self, Colors}; + use crate::flags::Blocks; use crate::icon::{self, Icons}; use crate::meta::FileType; use crate::meta::Meta; @@ -210,7 +211,7 @@ mod test { // Chreate the directory let dir_path = tmp_dir.path().join("directory"); fs::create_dir(&dir_path).expect("failed to create the dir"); - let meta = Meta::from_path(&dir_path, false).unwrap(); + let meta = Meta::from_path(&dir_path, false, &Blocks::long()).unwrap(); let colors = Colors::new(color::Theme::NoLscolors); @@ -310,7 +311,7 @@ mod test { // Create the file; let file_path = tmp_dir.path().join("file.txt"); File::create(&file_path).expect("failed to create file"); - let meta = Meta::from_path(&file_path, false).unwrap(); + let meta = Meta::from_path(&file_path, false, &Blocks::long()).unwrap(); let colors = Colors::new(color::Theme::NoColor); diff --git a/src/meta/permissions.rs b/src/meta/permissions.rs index 4b3450a79..bb3dbf059 100644 --- a/src/meta/permissions.rs +++ b/src/meta/permissions.rs @@ -2,7 +2,7 @@ use crate::color::{ColoredString, Colors, Elem}; use ansi_term::ANSIStrings; use std::fs::Metadata; -#[derive(Debug, PartialEq, Eq, Copy, Clone)] +#[derive(Debug, PartialEq, Eq, Copy, Clone, Default)] pub struct Permissions { pub user_read: bool, pub user_write: bool, diff --git a/src/meta/windows_utils.rs b/src/meta/windows_utils.rs index 8ae8585f6..78a6a0c1f 100644 --- a/src/meta/windows_utils.rs +++ b/src/meta/windows_utils.rs @@ -13,7 +13,12 @@ use super::{Owner, Permissions}; const BUF_SIZE: u32 = 256; -pub fn get_file_data(path: &Path) -> Result<(Owner, Permissions), io::Error> { +pub fn get_file_data( + path: &Path, + get_owner: bool, + get_group: bool, + get_permissions: bool, +) -> Result<(Owner, Permissions), io::Error> { // Overall design: // This function allocates some data with GetNamedSecurityInfoW, // manipulates it only through WinAPI calls (treating the pointers as @@ -25,6 +30,13 @@ pub fn get_file_data(path: &Path) -> Result<(Owner, Permissions), io::Error> { // - LocalFree must be called before returning // - No pointer is valid after the call to LocalFree + if !get_owner && !get_group && !get_permissions { + return Ok(( + Owner::new(String::new(), String::new()), + Permissions::default(), + )); + } + let windows_path = buf_from_os(path.as_os_str()); // These pointers will be populated by GetNamedSecurityInfoW @@ -65,107 +77,126 @@ pub fn get_file_data(path: &Path) -> Result<(Owner, Permissions), io::Error> { // - owner_sid_ptr is valid // - group_sid_ptr is valid // (both OK because GetNamedSecurityInfoW returned success) - let (owner_name, owner_domain) = unsafe { lookup_account_sid(owner_sid_ptr) }?; - let (group_name, group_domain) = unsafe { lookup_account_sid(group_sid_ptr) }?; - - let owner_name = os_from_buf(&owner_name); - let owner_domain = os_from_buf(&owner_domain); - let group_name = os_from_buf(&group_name); - let group_domain = os_from_buf(&group_domain); - - // Format into domain\name format - let mut owner = owner_domain.to_string_lossy().into_owned(); - owner.push('\\'); - owner.push_str(&owner_name.to_string_lossy()); - - let mut group = group_domain.to_string_lossy().into_owned(); - group.push('\\'); - group.push_str(&group_name.to_string_lossy()); + let owner = if get_owner || get_permissions { + let (owner_name, owner_domain) = unsafe { lookup_account_sid(owner_sid_ptr) }?; + let owner_name = os_from_buf(&owner_name); + let owner_domain = os_from_buf(&owner_domain); + + // Format into domain\name format + let mut owner = owner_domain.to_string_lossy().into_owned(); + owner.push('\\'); + owner.push_str(&owner_name.to_string_lossy()); + owner + } else { + String::new() + }; + let group = if get_group || get_permissions { + let (group_name, group_domain) = unsafe { lookup_account_sid(group_sid_ptr) }?; + let group_name = os_from_buf(&group_name); + let group_domain = os_from_buf(&group_domain); + // Format into domain\name format + let mut group = group_domain.to_string_lossy().into_owned(); + group.push('\\'); + group.push_str(&group_name.to_string_lossy()); + group + } else { + String::new() + }; // This structure will be returned let owner = Owner::new(owner, group); - // Get the size and allocate bytes for a 1-sub-authority SID - // 1 sub-authority because the Windows World SID is always S-1-1-0, with - // only a single sub-authority. - // - // Assumptions: None - // "This function cannot fail" - // -- Windows Dev Center docs - let mut world_sid_len: u32 = unsafe { winapi::um::securitybaseapi::GetSidLengthRequired(1) }; - let mut world_sid = vec![0u8; world_sid_len as usize]; + let permissions = if get_permissions { + // Get the size and allocate bytes for a 1-sub-authority SID + // 1 sub-authority because the Windows World SID is always S-1-1-0, with + // only a single sub-authority. + // + // Assumptions: None + // "This function cannot fail" + // -- Windows Dev Center docs + let mut world_sid_len: u32 = + unsafe { winapi::um::securitybaseapi::GetSidLengthRequired(1) }; + let mut world_sid = vec![0u8; world_sid_len as usize]; - // Assumptions: - // - world_sid_len is no larger than the number of bytes available at - // world_sid - // - world_sid is appropriately aligned (if there are strange crashes this - // might be why) - let result = unsafe { - winapi::um::securitybaseapi::CreateWellKnownSid( - winnt::WinWorldSid, - null_mut(), - world_sid.as_mut_ptr() as *mut _, - &mut world_sid_len, - ) - }; + // Assumptions: + // - world_sid_len is no larger than the number of bytes available at + // world_sid + // - world_sid is appropriately aligned (if there are strange crashes this + // might be why) + let result = unsafe { + winapi::um::securitybaseapi::CreateWellKnownSid( + winnt::WinWorldSid, + null_mut(), + world_sid.as_mut_ptr() as *mut _, + &mut world_sid_len, + ) + }; + + if result == 0 { + // Failed to create the SID + // Assumptions: Same as the other identical calls + unsafe { + winapi::um::winbase::LocalFree(sd_ptr); + } - if result == 0 { - // Failed to create the SID - // Assumptions: Same as the other identical calls - unsafe { - winapi::um::winbase::LocalFree(sd_ptr); + // Assumptions: None (GetLastError shouldn't ever fail) + return Err(io::Error::from_raw_os_error(unsafe { + winapi::um::errhandlingapi::GetLastError() + } as i32)); } - // Assumptions: None (GetLastError shouldn't ever fail) - return Err(io::Error::from_raw_os_error(unsafe { - winapi::um::errhandlingapi::GetLastError() - } as i32)); - } - - // Assumptions: - // - xxxxx_sid_ptr are valid pointers to SIDs - // - xxxxx_trustee is only valid as long as its SID pointer is - let mut owner_trustee = unsafe { trustee_from_sid(owner_sid_ptr) }; - let mut group_trustee = unsafe { trustee_from_sid(group_sid_ptr) }; - let mut world_trustee = unsafe { trustee_from_sid(world_sid.as_mut_ptr() as *mut _) }; + // Assumptions: + // - xxxxx_sid_ptr are valid pointers to SIDs + // - xxxxx_trustee is only valid as long as its SID pointer is + let mut owner_trustee = unsafe { trustee_from_sid(owner_sid_ptr) }; + let mut group_trustee = unsafe { trustee_from_sid(group_sid_ptr) }; + let mut world_trustee = unsafe { trustee_from_sid(world_sid.as_mut_ptr() as *mut _) }; - // Assumptions: - // - xxxxx_trustee are still valid (including underlying SID) - // - dacl_ptr is still valid - let owner_access_mask = unsafe { get_acl_access_mask(dacl_ptr as *mut _, &mut owner_trustee) }?; + // Assumptions: + // - xxxxx_trustee are still valid (including underlying SID) + // - dacl_ptr is still valid + let owner_access_mask = + unsafe { get_acl_access_mask(dacl_ptr as *mut _, &mut owner_trustee) }?; - let group_access_mask = unsafe { get_acl_access_mask(dacl_ptr as *mut _, &mut group_trustee) }?; + let group_access_mask = + unsafe { get_acl_access_mask(dacl_ptr as *mut _, &mut group_trustee) }?; - let world_access_mask = unsafe { get_acl_access_mask(dacl_ptr as *mut _, &mut world_trustee) }?; + let world_access_mask = + unsafe { get_acl_access_mask(dacl_ptr as *mut _, &mut world_trustee) }?; - let has_bit = |field: u32, bit: u32| field & bit != 0; + let has_bit = |field: u32, bit: u32| field & bit != 0; - let permissions = Permissions { - user_read: has_bit(owner_access_mask, winnt::FILE_GENERIC_READ), - user_write: has_bit(owner_access_mask, winnt::FILE_GENERIC_WRITE), - user_execute: has_bit(owner_access_mask, winnt::FILE_GENERIC_EXECUTE), + Permissions { + user_read: has_bit(owner_access_mask, winnt::FILE_GENERIC_READ), + user_write: has_bit(owner_access_mask, winnt::FILE_GENERIC_WRITE), + user_execute: has_bit(owner_access_mask, winnt::FILE_GENERIC_EXECUTE), - group_read: has_bit(group_access_mask, winnt::FILE_GENERIC_READ), - group_write: has_bit(group_access_mask, winnt::FILE_GENERIC_WRITE), - group_execute: has_bit(group_access_mask, winnt::FILE_GENERIC_EXECUTE), + group_read: has_bit(group_access_mask, winnt::FILE_GENERIC_READ), + group_write: has_bit(group_access_mask, winnt::FILE_GENERIC_WRITE), + group_execute: has_bit(group_access_mask, winnt::FILE_GENERIC_EXECUTE), - other_read: has_bit(world_access_mask, winnt::FILE_GENERIC_READ), - other_write: has_bit(world_access_mask, winnt::FILE_GENERIC_WRITE), - other_execute: has_bit(world_access_mask, winnt::FILE_GENERIC_EXECUTE), + other_read: has_bit(world_access_mask, winnt::FILE_GENERIC_READ), + other_write: has_bit(world_access_mask, winnt::FILE_GENERIC_WRITE), + other_execute: has_bit(world_access_mask, winnt::FILE_GENERIC_EXECUTE), - sticky: false, - setuid: false, - setgid: false, + sticky: false, + setuid: false, + setgid: false, + } + } else { + Permissions::default() }; - // Assumptions: - // - sd_ptr was previously allocated with WinAPI functions - // - All pointers into the memory are now invalid - // - The free succeeds (currently unchecked -- there's no real recovery - // options. It's not much memory, so leaking it on failure is - // *probably* fine) - unsafe { - winapi::um::winbase::LocalFree(sd_ptr); + if sd_ptr != null_mut() { + // Assumptions: + // - sd_ptr was previously allocated with WinAPI functions + // - All pointers into the memory are now invalid + // - The free succeeds (currently unchecked -- there's no real recovery + // options. It's not much memory, so leaking it on failure is + // *probably* fine) + unsafe { + winapi::um::winbase::LocalFree(sd_ptr); + } } Ok((owner, permissions)) diff --git a/src/sort.rs b/src/sort.rs index 99812e588..d3a0cc931 100644 --- a/src/sort.rs +++ b/src/sort.rs @@ -69,7 +69,7 @@ fn by_extension(a: &Meta, b: &Meta) -> Ordering { #[cfg(test)] mod tests { use super::*; - use crate::flags::Flags; + use crate::flags::{Blocks, Flags}; use std::fs::{create_dir, File}; use std::process::Command; use tempfile::tempdir; @@ -81,12 +81,12 @@ mod tests { // Create the file; let path_a = tmp_dir.path().join("zzz"); File::create(&path_a).expect("failed to create file"); - let meta_a = Meta::from_path(&path_a, false).expect("failed to get meta"); + let meta_a = Meta::from_path(&path_a, false, &Blocks::long()).expect("failed to get meta"); // Create a dir; let path_z = tmp_dir.path().join("aaa"); create_dir(&path_z).expect("failed to create dir"); - let meta_z = Meta::from_path(&path_z, false).expect("failed to get meta"); + let meta_z = Meta::from_path(&path_z, false, &Blocks::long()).expect("failed to get meta"); let mut flags = Flags::default(); flags.sorting.dir_grouping = DirGrouping::First; @@ -109,12 +109,12 @@ mod tests { // Create the file; let path_a = tmp_dir.path().join("zzz"); File::create(&path_a).expect("failed to create file"); - let meta_a = Meta::from_path(&path_a, false).expect("failed to get meta"); + let meta_a = Meta::from_path(&path_a, false, &Blocks::long()).expect("failed to get meta"); // Create a dir; let path_z = tmp_dir.path().join("aaa"); create_dir(&path_z).expect("failed to create dir"); - let meta_z = Meta::from_path(&path_z, false).expect("failed to get meta"); + let meta_z = Meta::from_path(&path_z, false, &Blocks::long()).expect("failed to get meta"); let mut flags = Flags::default(); flags.sorting.dir_grouping = DirGrouping::Last; @@ -135,12 +135,12 @@ mod tests { // Create the file; let path_a = tmp_dir.path().join("aaa"); File::create(&path_a).expect("failed to create file"); - let meta_a = Meta::from_path(&path_a, false).expect("failed to get meta"); + let meta_a = Meta::from_path(&path_a, false, &Blocks::long()).expect("failed to get meta"); // Create a dir; let path_z = tmp_dir.path().join("zzz"); create_dir(&path_z).expect("failed to create dir"); - let meta_z = Meta::from_path(&path_z, false).expect("failed to get meta"); + let meta_z = Meta::from_path(&path_z, false, &Blocks::long()).expect("failed to get meta"); let mut flags = Flags::default(); flags.sorting.dir_grouping = DirGrouping::None; @@ -163,12 +163,12 @@ mod tests { // Create the file; let path_a = tmp_dir.path().join("zzz"); File::create(&path_a).expect("failed to create file"); - let meta_a = Meta::from_path(&path_a, false).expect("failed to get meta"); + let meta_a = Meta::from_path(&path_a, false, &Blocks::long()).expect("failed to get meta"); // Create a dir; let path_z = tmp_dir.path().join("aaa"); create_dir(&path_z).expect("failed to create dir"); - let meta_z = Meta::from_path(&path_z, false).expect("failed to get meta"); + let meta_z = Meta::from_path(&path_z, false, &Blocks::long()).expect("failed to get meta"); let mut flags = Flags::default(); flags.sorting.dir_grouping = DirGrouping::None; @@ -191,7 +191,7 @@ mod tests { // Create the file; let path_a = tmp_dir.path().join("aaa"); File::create(&path_a).expect("failed to create file"); - let meta_a = Meta::from_path(&path_a, false).expect("failed to get meta"); + let meta_a = Meta::from_path(&path_a, false, &Blocks::long()).expect("failed to get meta"); // Create the file; let path_z = tmp_dir.path().join("zzz"); @@ -217,7 +217,7 @@ mod tests { .success(); assert_eq!(true, success, "failed to change file timestamp"); - let meta_z = Meta::from_path(&path_z, false).expect("failed to get meta"); + let meta_z = Meta::from_path(&path_z, false, &Blocks::long()).expect("failed to get meta"); let mut flags = Flags::default(); flags.sorting.column = SortColumn::Time; @@ -239,22 +239,22 @@ mod tests { // Create the file with rs extension; let path_a = tmp_dir.path().join("aaa.rs"); File::create(&path_a).expect("failed to create file"); - let meta_a = Meta::from_path(&path_a, false).expect("failed to get meta"); + let meta_a = Meta::from_path(&path_a, false, &Blocks::long()).expect("failed to get meta"); // Create the file with rs extension; let path_z = tmp_dir.path().join("zzz.rs"); File::create(&path_z).expect("failed to create file"); - let meta_z = Meta::from_path(&path_z, false).expect("failed to get meta"); + let meta_z = Meta::from_path(&path_z, false, &Blocks::long()).expect("failed to get meta"); // Create the file with js extension; let path_j = tmp_dir.path().join("zzz.js"); File::create(&path_j).expect("failed to create file"); - let meta_j = Meta::from_path(&path_j, false).expect("failed to get meta"); + let meta_j = Meta::from_path(&path_j, false, &Blocks::long()).expect("failed to get meta"); // Create the file with txt extension; let path_t = tmp_dir.path().join("zzz.txt"); File::create(&path_t).expect("failed to create file"); - let meta_t = Meta::from_path(&path_t, false).expect("failed to get meta"); + let meta_t = Meta::from_path(&path_t, false, &Blocks::long()).expect("failed to get meta"); let mut flags = Flags::default(); flags.sorting.column = SortColumn::Extension; @@ -276,15 +276,15 @@ mod tests { let path_a = tmp_dir.path().join("2"); File::create(&path_a).expect("failed to create file"); - let meta_a = Meta::from_path(&path_a, false).expect("failed to get meta"); + let meta_a = Meta::from_path(&path_a, false, &Blocks::long()).expect("failed to get meta"); let path_b = tmp_dir.path().join("11"); File::create(&path_b).expect("failed to create file"); - let meta_b = Meta::from_path(&path_b, false).expect("failed to get meta"); + let meta_b = Meta::from_path(&path_b, false, &Blocks::long()).expect("failed to get meta"); let path_c = tmp_dir.path().join("12"); File::create(&path_c).expect("failed to create file"); - let meta_c = Meta::from_path(&path_c, false).expect("failed to get meta"); + let meta_c = Meta::from_path(&path_c, false, &Blocks::long()).expect("failed to get meta"); let mut flags = Flags::default(); flags.sorting.column = SortColumn::Version;