File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11.\" Manpage for Directory diSplay.
22.\" by ElCapitan, https://github.com/at-elcapitan
33
4- .TH "ds" 1 "30 July 2024 " "GNU" "Directory diSplay"
4+ .TH "ds" 1 "27 Feb 2026 " "GNU" "Directory diSplay"
55.SH NAME
66Directory diSplay (DS) - display current directory
77
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ fn get_file_type(file: &DirEntry) -> ObjectType {
3838
3939 if filetype. is_dir ( ) {
4040 ObjectType {
41- type_name : String :: from ( " DIR" ) ,
41+ type_name : String :: from ( "DIR" ) ,
4242 display_color : String :: from ( "\x1b [34;1m" )
4343 }
4444 } else if filetype. is_file ( )
@@ -56,7 +56,7 @@ fn get_file_type(file: &DirEntry) -> ObjectType {
5656 }
5757 } else if filetype. is_symlink ( ) {
5858 ObjectType {
59- type_name : String :: from ( "SYMLINK " ) ,
59+ type_name : String :: from ( "SYML " ) ,
6060 display_color : String :: from ( "\x1b [31;1m" ) ,
6161 }
6262 } else if filetype. is_block_device ( ) {
@@ -71,7 +71,7 @@ fn get_file_type(file: &DirEntry) -> ObjectType {
7171 }
7272 } else {
7373 ObjectType {
74- type_name : String :: from ( "UNKNOWN " ) ,
74+ type_name : String :: from ( "UNDEF " ) ,
7575 display_color : String :: from ( "" ) ,
7676 }
7777 }
Original file line number Diff line number Diff line change @@ -50,30 +50,30 @@ fn main() -> std::io::Result<()> {
5050 & parsed_args. full_name
5151 ) ;
5252
53- // Displaying the top line and setting the final size
54- if let Some ( dir_name) = current_dir. file_name ( ) {
55- let current_dir_name: Cow < str > = dir_name. to_string_lossy ( ) ;
56-
57- let current_dir_name_len: usize = current_dir_name. chars ( )
58- . count ( ) ;
53+ let current_dir_name: Cow < str > ;
54+ let current_dir_name_len: usize ;
5955
60- files . max_name_length = files . max_name_length . max ( current_dir_name_len ) ;
61- utils :: display_top_line (
62- & files . max_name_length ,
63- current_dir_name ,
64- current_dir_name_len ,
65- & parsed_args . access ,
66- & parsed_args . size
67- ) ;
56+ // Setting final max_length value
57+ if let Some ( dir_name ) = current_dir . file_name ( ) {
58+ current_dir_name = dir_name . to_string_lossy ( ) ;
59+ current_dir_name_len =
60+ current_dir_name . chars ( )
61+ . count ( ) ;
62+ files . max_name_length =
63+ files . max_name_length . max ( current_dir_name_len ) ;
6864 } else {
69- utils:: display_top_line (
70- & files. max_name_length ,
71- Cow :: Borrowed ( "" ) ,
72- 0 ,
73- & parsed_args. access ,
74- & parsed_args. size
75- ) ;
65+ current_dir_name = Cow :: Borrowed ( "" ) ;
66+ current_dir_name_len = 0 ;
7667 }
68+
69+ // Displaying the top line
70+ utils:: display_top_line (
71+ & files. max_name_length ,
72+ current_dir_name,
73+ current_dir_name_len,
74+ & parsed_args. access ,
75+ & parsed_args. size
76+ ) ;
7777
7878 // Printing empty line
7979 println ! ( " │" ) ;
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ pub fn display_help() {
5252}
5353
5454pub fn display_version ( ) {
55- println ! ( "ds (Directory diSplay) 2.1.0 " ) ;
55+ println ! ( "ds (Directory diSplay) 2.1.1 " ) ;
5656 println ! ( ) ;
5757 println ! (
5858 "This is free software; see the source for copying conditions. There is NO"
@@ -79,28 +79,22 @@ pub fn display_top_line(max_length: &usize,
7979 additional. push_str ( "PUSER\t GROUP\t OTHER" )
8080 }
8181
82- if current_dir_name_len > 0 {
83- let spaces = max_length + 7 - current_dir_name_len;
82+ let spaces = max_length + 7 - current_dir_name_len;
8483
85- println ! (
86- "{}/{}\t TYPE\t \t {}" ,
87- current_dir_name,
88- " " . repeat( spaces) ,
89- additional
90- ) ;
91-
92- return ;
93- }
94-
95- println ! ( "./{} \t TYPE\t \t {}" , " " . repeat( max_length + 6 ) , additional) ;
84+ println ! (
85+ "{}/{}\t TYPE\t \t {}" ,
86+ current_dir_name,
87+ " " . repeat( spaces) ,
88+ additional
89+ ) ;
9690}
9791
9892pub fn display_objects (
9993 objects : Vec < DisplayableObject > ,
10094 max_length : & usize ,
10195 flag_access : & bool ,
10296 flag_size : & bool ,
103- ending : bool
97+ final_objects : bool
10498 ) {
10599 for ( i, obj) in objects. iter ( ) . enumerate ( ) {
106100 let mut flags_data = String :: new ( ) ;
@@ -130,12 +124,12 @@ pub fn display_objects(
130124
131125 let symbol;
132126
133- if ending && i == objects. len ( ) - 1 {
127+ if final_objects && i == objects. len ( ) - 1 {
134128 symbol = String :: from ( "└" ) ;
135129 } else {
136130 symbol = String :: from ( "├" ) ;
137131 }
138-
132+
139133 println ! (
140134 " {} {}{:<width$}\x1b [0m\t {}\t \t {flags_data}" ,
141135 symbol,
You can’t perform that action at this time.
0 commit comments