@@ -115,15 +115,15 @@ fn output() -> Result<(), Box<dyn std::error::Error>> {
115
115
for e in & entries {
116
116
if e
117
117
. 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
+ }
127
127
}
128
128
if !singly_found {
129
129
if !* colors_on {
@@ -132,11 +132,11 @@ fn output() -> Result<(), Box<dyn std::error::Error>> {
132
132
println ! (
133
133
"{}" ,
134
134
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( )
137
137
) )
138
138
) ;
139
- std:: process:: exit ( 1 ) ;
139
+ std:: process:: exit ( 1 ) ;
140
140
}
141
141
std:: process:: exit ( 0 ) ;
142
142
}
@@ -150,16 +150,16 @@ fn output() -> Result<(), Box<dyn std::error::Error>> {
150
150
. map ( |res| res. map ( |e| e. path ( ) ) )
151
151
. collect :: < Result < Vec < _ > , io:: Error > > ( ) ?;
152
152
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
+ }
159
159
let mut size_count = 4 ;
160
160
let mut group_size = 8 ;
161
161
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 {
163
163
size_count = ( fs:: symlink_metadata ( & s) ?. size ( ) ) . file_size ( options:: CONVENTIONAL ) . unwrap ( ) . len ( ) ;
164
164
} ;
165
165
@@ -220,7 +220,7 @@ pub fn draw_headlines(
220
220
time_on : bool ,
221
221
group_on : bool ,
222
222
user_on : bool ,
223
- ) {
223
+ ) {
224
224
if headline_on {
225
225
if !perms_on {
226
226
draw_headline ( "permissions" , 0 , false ) ;
@@ -254,7 +254,7 @@ pub fn file_perms(e: &&std::path::PathBuf) -> Result<(), Box<dyn std::error::Err
254
254
pub fn file_size (
255
255
size_count : usize ,
256
256
e : & & std:: path:: PathBuf ,
257
- ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
257
+ ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
258
258
if ( fs:: symlink_metadata ( & e) ?. size ( ) ) . file_size ( options:: CONVENTIONAL ) . unwrap ( ) . len ( ) < size_count {
259
259
for _ in 0 ..( size_count - ( fs:: symlink_metadata ( & e) ?. size ( ) ) . file_size ( options:: CONVENTIONAL ) . unwrap ( ) . len ( ) )
260
260
{
@@ -268,8 +268,8 @@ pub fn file_size(
268
268
"{} " ,
269
269
Style :: new( ) . bold( ) . paint(
270
270
( fs:: symlink_metadata( & e) ?. size( ) )
271
- . file_size( options:: CONVENTIONAL )
272
- . unwrap( )
271
+ . file_size( options:: CONVENTIONAL )
272
+ . unwrap( )
273
273
)
274
274
) ;
275
275
Ok ( ( ) )
@@ -278,21 +278,46 @@ pub fn file_size(
278
278
pub fn time_mod (
279
279
e : & std:: path:: PathBuf ,
280
280
time_format : & str ,
281
- ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
281
+ ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
282
282
if e. symlink_metadata ( ) ?. modified ( ) . is_ok ( ) {
283
283
let timestamp = fs:: symlink_metadata ( e) ?;
284
284
let naive = NaiveDateTime :: from_timestamp (
285
285
FileTime :: from_last_modification_time ( & timestamp) . seconds ( ) as i64 ,
286
286
0 ,
287
- ) ;
287
+ ) ;
288
288
//let now = Utc::now();
289
289
//let back = NaiveDateTime::from_timestamp(FileTime::from_last_modification_time(×tamp).seconds() as i64, 0);
290
290
//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
+ //}
296
321
let datetime: DateTime < Local > = DateTime :: from_utc ( naive, * Local :: now ( ) . offset ( ) ) ;
297
322
if !Cli :: from_args ( ) . colors_on {
298
323
print ! ( "{}" , color:: Fg ( color:: LightRed ) ) ;
@@ -338,7 +363,7 @@ pub fn show_user_name(e: &std::path::PathBuf) -> Result<(), Box<dyn std::error::
338
363
pub fn show_file_name (
339
364
e : & & std:: path:: PathBuf ,
340
365
wide_mode : bool ,
341
- ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
366
+ ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
342
367
let colors_on = Cli :: from_args ( ) . colors_on ;
343
368
if !colors_on {
344
369
print ! ( "{}" , color:: Fg ( color:: White ) ) ;
@@ -360,8 +385,8 @@ pub fn show_file_name(
360
385
print ! (
361
386
"{} -> " ,
362
387
Style :: new( )
363
- . bold( )
364
- . paint( e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) )
388
+ . bold( )
389
+ . paint( e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) )
365
390
) ;
366
391
match fs:: canonicalize ( fs:: read_link ( e) ?) {
367
392
Ok ( _n) => {
@@ -371,9 +396,9 @@ pub fn show_file_name(
371
396
print ! (
372
397
"{}/" ,
373
398
fs:: canonicalize( fs:: read_link( e) ?)
374
- . unwrap( )
375
- . to_str( )
376
- . unwrap( )
399
+ . unwrap( )
400
+ . to_str( )
401
+ . unwrap( )
377
402
)
378
403
}
379
404
} else {
@@ -382,9 +407,9 @@ pub fn show_file_name(
382
407
print ! (
383
408
"{}" ,
384
409
fs:: canonicalize( fs:: read_link( e) ?)
385
- . unwrap( )
386
- . to_str( )
387
- . unwrap( )
410
+ . unwrap( )
411
+ . to_str( )
412
+ . unwrap( )
388
413
)
389
414
}
390
415
}
@@ -421,8 +446,8 @@ pub fn show_file_name(
421
446
print ! (
422
447
"{}" ,
423
448
Style :: new( )
424
- . bold( )
425
- . paint( e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) )
449
+ . bold( )
450
+ . paint( e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) )
426
451
) ;
427
452
if !wide_mode {
428
453
println ! ( ) ;
@@ -461,7 +486,7 @@ pub fn single(
461
486
size_count : usize ,
462
487
wide_mode : bool ,
463
488
time_format : & str ,
464
- ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
489
+ ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
465
490
let args = Cli :: from_args ( ) ;
466
491
467
492
if !& args. perms_on {
@@ -497,7 +522,7 @@ pub fn perms(mode: u16) -> String {
497
522
format ! ( "{}{}" , color:: Fg ( color:: LightRed ) , group) ,
498
523
format ! ( "{}{}" , color:: Fg ( color:: Yellow ) , other) ,
499
524
]
500
- . join ( "" )
525
+ . join ( "" )
501
526
} else {
502
527
[ user, group, other] . join ( "" )
503
528
}
0 commit comments