Skip to content

Commit

Permalink
remove ctime for musl environment
Browse files Browse the repository at this point in the history
Signed-off-by: usamoi <[email protected]>
  • Loading branch information
usamoi committed Sep 28, 2024
1 parent 7712c07 commit 8269854
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 18 deletions.
11 changes: 2 additions & 9 deletions src/fs/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ pub struct JoshutoMetadata {
pub directory_size: Option<usize>,
pub modified: time::SystemTime,
pub accessed: time::SystemTime,
pub created: time::SystemTime,
pub mode: Mode,
pub file_type: FileType,
pub link_type: LinkType,
Expand All @@ -66,13 +65,12 @@ impl JoshutoMetadata {

let symlink_metadata = fs::symlink_metadata(path)?;
let metadata = fs::metadata(path);
let (len, modified, accessed, created) = match metadata.as_ref() {
Ok(m) => (m.len(), m.modified()?, m.accessed()?, m.created()?),
let (len, modified, accessed) = match metadata.as_ref() {
Ok(m) => (m.len(), m.modified()?, m.accessed()?),
Err(_) => (
symlink_metadata.len(),
symlink_metadata.modified()?,
symlink_metadata.accessed()?,
symlink_metadata.created()?,
),
};

Expand Down Expand Up @@ -125,7 +123,6 @@ impl JoshutoMetadata {
directory_size,
modified,
accessed,
created,
mode,
file_type,
link_type,
Expand Down Expand Up @@ -156,10 +153,6 @@ impl JoshutoMetadata {
self.accessed
}

pub fn created(&self) -> time::SystemTime {
self.created
}

pub fn file_type(&self) -> FileType {
self.file_type
}
Expand Down
2 changes: 0 additions & 2 deletions src/types/option/line_mode/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub enum LineModeArgs {
Size,
ModifyTime,
AccessTime,
BirthTime,
User,
Group,
Permission,
Expand All @@ -17,7 +16,6 @@ impl AsRef<str> for LineModeArgs {
LineModeArgs::Size => "size",
LineModeArgs::ModifyTime => "mtime",
LineModeArgs::AccessTime => "atime",
LineModeArgs::BirthTime => "ctime",
LineModeArgs::User => "user",
LineModeArgs::Group => "group",
LineModeArgs::Permission => "perm",
Expand Down
8 changes: 3 additions & 5 deletions src/types/option/line_mode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::error::{AppError, AppErrorKind, AppResult};

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct LineMode {
pub mode: [LineModeArgs; 8],
pub mode: [LineModeArgs; 7],
pub size: usize,
}

Expand All @@ -19,7 +19,6 @@ impl LineMode {
LineModeArgs::Size,
LineModeArgs::ModifyTime,
LineModeArgs::AccessTime,
LineModeArgs::BirthTime,
LineModeArgs::User,
LineModeArgs::Group,
LineModeArgs::Permission,
Expand All @@ -31,7 +30,7 @@ impl LineMode {

pub const fn empty() -> Self {
Self {
mode: [LineModeArgs::Null; 8],
mode: [LineModeArgs::Null; 7],
size: 0,
}
}
Expand All @@ -48,7 +47,7 @@ impl LineMode {

impl Default for LineMode {
fn default() -> Self {
let mut mode = [Default::default(); 8];
let mut mode = [Default::default(); 7];
mode[0] = LineModeArgs::Size;

Self { size: 1, mode }
Expand All @@ -68,7 +67,6 @@ impl LineMode {
"size" => line_mode.add_mode(LineModeArgs::Size),
"mtime" => line_mode.add_mode(LineModeArgs::ModifyTime),
"atime" => line_mode.add_mode(LineModeArgs::AccessTime),
"btime" => line_mode.add_mode(LineModeArgs::BirthTime),
"user" => line_mode.add_mode(LineModeArgs::User),
"group" => line_mode.add_mode(LineModeArgs::Group),
"perm" => line_mode.add_mode(LineModeArgs::Permission),
Expand Down
1 change: 0 additions & 1 deletion src/ui/widgets/tui_dirlist_detailed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ fn display_line_mode(mode: LineMode, entry: &JoshutoDirEntry) -> String {
LineModeArgs::Size => get_entry_size_string(entry),
LineModeArgs::ModifyTime => time_to_string(metadata.modified()),
LineModeArgs::AccessTime => time_to_string(metadata.accessed()),
LineModeArgs::BirthTime => time_to_string(metadata.created()),
LineModeArgs::User => unix::uid_to_string(metadata.uid).unwrap_or("unknown".into()),
LineModeArgs::Group => unix::gid_to_string(metadata.gid).unwrap_or("unknown".into()),
LineModeArgs::Permission => unix::mode_to_char_array(metadata.mode, metadata.file_type)
Expand Down
1 change: 0 additions & 1 deletion src/utils/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ where
"size" => line_mode.add_mode(LineModeArgs::Size),
"mtime" => line_mode.add_mode(LineModeArgs::ModifyTime),
"atime" => line_mode.add_mode(LineModeArgs::AccessTime),
"btime" => line_mode.add_mode(LineModeArgs::BirthTime),
"user" => line_mode.add_mode(LineModeArgs::User),
"group" => line_mode.add_mode(LineModeArgs::Group),
"perm" => line_mode.add_mode(LineModeArgs::Permission),
Expand Down

0 comments on commit 8269854

Please sign in to comment.