@@ -115,15 +115,15 @@ fn output() -> Result<(), Box<dyn std::error::Error>> {
115115 for e in & entries {
116116 if e
117117 . file_name ( )
118- . unwrap ( )
119- . to_str ( )
120- . unwrap ( )
121- . to_lowercase ( )
122- . contains ( & args. path . display ( ) . to_string ( ) . to_lowercase ( ) )
123- {
124- let _ = single ( e, size_count, * wide_mode, time_format) ;
125- singly_found = true ;
126- }
118+ . unwrap ( )
119+ . to_str ( )
120+ . unwrap ( )
121+ . to_lowercase ( )
122+ . contains ( & args. path . display ( ) . to_string ( ) . to_lowercase ( ) )
123+ {
124+ let _ = single ( e, size_count, * wide_mode, time_format) ;
125+ singly_found = true ;
126+ }
127127 }
128128 if !singly_found {
129129 if !* colors_on {
@@ -132,11 +132,11 @@ fn output() -> Result<(), Box<dyn std::error::Error>> {
132132 println ! (
133133 "{}" ,
134134 Style :: new( ) . bold( ) . paint( format!(
135- "{} could not be found" ,
136- & args. path. display( ) . to_string( )
135+ "{} could not be found" ,
136+ & args. path. display( ) . to_string( )
137137 ) )
138138 ) ;
139- std:: process:: exit ( 1 ) ;
139+ std:: process:: exit ( 1 ) ;
140140 }
141141 std:: process:: exit ( 0 ) ;
142142 }
@@ -150,16 +150,16 @@ fn output() -> Result<(), Box<dyn std::error::Error>> {
150150 . map ( |res| res. map ( |e| e. path ( ) ) )
151151 . collect :: < Result < Vec < _ > , io:: Error > > ( ) ?;
152152
153- if * by_modified {
154- entries. sort_by ( |a, b| FileTime :: from_last_modification_time ( & fs:: symlink_metadata ( & a) . unwrap ( ) ) . seconds ( ) . cmp ( & FileTime :: from_last_modification_time ( & fs:: symlink_metadata ( & b) . unwrap ( ) ) . seconds ( ) ) ) ;
155- }
156- if !* by_name {
157- entries. sort_by ( |a, b| a. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_lowercase ( ) . cmp ( & b. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_lowercase ( ) ) ) ;
158- }
153+ if * by_modified {
154+ entries. sort_by ( |a, b| FileTime :: from_last_modification_time ( & fs:: symlink_metadata ( & a) . unwrap ( ) ) . seconds ( ) . cmp ( & FileTime :: from_last_modification_time ( & fs:: symlink_metadata ( & b) . unwrap ( ) ) . seconds ( ) ) ) ;
155+ }
156+ if !* by_name {
157+ entries. sort_by ( |a, b| a. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_lowercase ( ) . cmp ( & b. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_lowercase ( ) ) ) ;
158+ }
159159 let mut size_count = 4 ;
160160 let mut group_size = 8 ;
161161 for s in & entries {
162- if ( fs:: symlink_metadata ( & s) ?. size ( ) ) . file_size ( options:: CONVENTIONAL ) . unwrap ( ) . len ( ) > size_count {
162+ if ( fs:: symlink_metadata ( & s) ?. size ( ) ) . file_size ( options:: CONVENTIONAL ) . unwrap ( ) . len ( ) > size_count {
163163 size_count = ( fs:: symlink_metadata ( & s) ?. size ( ) ) . file_size ( options:: CONVENTIONAL ) . unwrap ( ) . len ( ) ;
164164 } ;
165165
@@ -220,7 +220,7 @@ pub fn draw_headlines(
220220 time_on : bool ,
221221 group_on : bool ,
222222 user_on : bool ,
223- ) {
223+ ) {
224224 if headline_on {
225225 if !perms_on {
226226 draw_headline ( "permissions" , 0 , false ) ;
@@ -254,7 +254,7 @@ pub fn file_perms(e: &&std::path::PathBuf) -> Result<(), Box<dyn std::error::Err
254254pub fn file_size (
255255 size_count : usize ,
256256 e : & & std:: path:: PathBuf ,
257- ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
257+ ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
258258 if ( fs:: symlink_metadata ( & e) ?. size ( ) ) . file_size ( options:: CONVENTIONAL ) . unwrap ( ) . len ( ) < size_count {
259259 for _ in 0 ..( size_count - ( fs:: symlink_metadata ( & e) ?. size ( ) ) . file_size ( options:: CONVENTIONAL ) . unwrap ( ) . len ( ) )
260260 {
@@ -268,8 +268,8 @@ pub fn file_size(
268268 "{} " ,
269269 Style :: new( ) . bold( ) . paint(
270270 ( fs:: symlink_metadata( & e) ?. size( ) )
271- . file_size( options:: CONVENTIONAL )
272- . unwrap( )
271+ . file_size( options:: CONVENTIONAL )
272+ . unwrap( )
273273 )
274274 ) ;
275275 Ok ( ( ) )
@@ -278,21 +278,46 @@ pub fn file_size(
278278pub fn time_mod (
279279 e : & std:: path:: PathBuf ,
280280 time_format : & str ,
281- ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
281+ ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
282282 if e. symlink_metadata ( ) ?. modified ( ) . is_ok ( ) {
283283 let timestamp = fs:: symlink_metadata ( e) ?;
284284 let naive = NaiveDateTime :: from_timestamp (
285285 FileTime :: from_last_modification_time ( & timestamp) . seconds ( ) as i64 ,
286286 0 ,
287- ) ;
287+ ) ;
288288 //let now = Utc::now();
289289 //let back = NaiveDateTime::from_timestamp(FileTime::from_last_modification_time(×tamp).seconds() as i64, 0);
290290 //let d: DateTime<Utc> = DateTime::from_utc(back, Utc);
291- //let rel = now.signed_duration_since(d).num_seconds();
292- //println!("{}", chrono::Duration::seconds(rel).num_seconds());
293- //println!("{}", chrono::Duration::seconds(rel).num_hours());
294- //println!("{}", chrono::Duration::seconds(rel).num_days());
295- //println!("{}", chrono::Duration::seconds(rel).num_weeks());
291+ //let rel = chrono::Duration::seconds(now.signed_duration_since(d).num_seconds());
292+ //match rel.num_seconds() > 60 {
293+ //true => {
294+ //match rel.num_minutes() > 60 {
295+ //true => {
296+ //match rel.num_hours() > 24 {
297+ //true => {
298+ //match rel.num_days() > 7 {
299+ //true => {
300+ //print!("{} weeks", rel.num_weeks());
301+ //}
302+ //false => {
303+ //print!("{} days", rel.num_days());
304+ //}
305+ //}
306+ //}
307+ //false => {
308+ //print!("{} hours", rel.num_hours());
309+ //}
310+ //}
311+ //}
312+ //false => {
313+ //print!("{} min", rel.num_minutes());
314+ //}
315+ //}
316+ //}
317+ //false => {
318+ //print!("{} secs", rel.num_seconds());
319+ //}
320+ //}
296321 let datetime: DateTime < Local > = DateTime :: from_utc ( naive, * Local :: now ( ) . offset ( ) ) ;
297322 if !Cli :: from_args ( ) . colors_on {
298323 print ! ( "{}" , color:: Fg ( color:: LightRed ) ) ;
@@ -338,7 +363,7 @@ pub fn show_user_name(e: &std::path::PathBuf) -> Result<(), Box<dyn std::error::
338363pub fn show_file_name (
339364 e : & & std:: path:: PathBuf ,
340365 wide_mode : bool ,
341- ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
366+ ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
342367 let colors_on = Cli :: from_args ( ) . colors_on ;
343368 if !colors_on {
344369 print ! ( "{}" , color:: Fg ( color:: White ) ) ;
@@ -360,8 +385,8 @@ pub fn show_file_name(
360385 print ! (
361386 "{} -> " ,
362387 Style :: new( )
363- . bold( )
364- . paint( e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) )
388+ . bold( )
389+ . paint( e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) )
365390 ) ;
366391 match fs:: canonicalize ( fs:: read_link ( e) ?) {
367392 Ok ( _n) => {
@@ -371,9 +396,9 @@ pub fn show_file_name(
371396 print ! (
372397 "{}/" ,
373398 fs:: canonicalize( fs:: read_link( e) ?)
374- . unwrap( )
375- . to_str( )
376- . unwrap( )
399+ . unwrap( )
400+ . to_str( )
401+ . unwrap( )
377402 )
378403 }
379404 } else {
@@ -382,9 +407,9 @@ pub fn show_file_name(
382407 print ! (
383408 "{}" ,
384409 fs:: canonicalize( fs:: read_link( e) ?)
385- . unwrap( )
386- . to_str( )
387- . unwrap( )
410+ . unwrap( )
411+ . to_str( )
412+ . unwrap( )
388413 )
389414 }
390415 }
@@ -421,8 +446,8 @@ pub fn show_file_name(
421446 print ! (
422447 "{}" ,
423448 Style :: new( )
424- . bold( )
425- . paint( e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) )
449+ . bold( )
450+ . paint( e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) )
426451 ) ;
427452 if !wide_mode {
428453 println ! ( ) ;
@@ -461,7 +486,7 @@ pub fn single(
461486 size_count : usize ,
462487 wide_mode : bool ,
463488 time_format : & str ,
464- ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
489+ ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
465490 let args = Cli :: from_args ( ) ;
466491
467492 if !& args. perms_on {
@@ -497,7 +522,7 @@ pub fn perms(mode: u16) -> String {
497522 format ! ( "{}{}" , color:: Fg ( color:: LightRed ) , group) ,
498523 format ! ( "{}{}" , color:: Fg ( color:: Yellow ) , other) ,
499524 ]
500- . join ( "" )
525+ . join ( "" )
501526 } else {
502527 [ user, group, other] . join ( "" )
503528 }
0 commit comments