44# Written by twojstaryzdomu (twojstaryzdomu@users.noreply.github.com), 2021
55#
66
7+ # Undefine to disable upper-casing short names
8+ my $uc = 1;
79my ( $cmd , $archive , @args ) = @ARGV ;
810die " $archive does not exist\n " unless -f " $archive " ;
911my $size_kb = ( -s $archive ) / 1024;
@@ -46,15 +48,9 @@ sub check_mtools {
4648sub default_handler {
4749 my ( $cmd , $archive , @args ) = ( @_ );
4850 print_debug " default_handler: @args " ;
49- if ( $cmd eq ' copyin' ) {
50- if ( my ( $name , $ext ) = $args [0] =~ / (\w +)\. (\w +)$ / ) {
51- die " filename $name .$ext too long to copy to $archive \n " if ( length ( $name ) > 8 || length ( $ext ) > 3 );
52- }
53- $args [0] = " ::$args [0]" ;
54- @args = reverse @args ;
55- }
56- elsif ( $cmd eq ' copyout' ) {
51+ if ( $cmd =~ / ^copy(\S +)/ ) {
5752 $args [0] = " ::$args [0]" ;
53+ @args = reverse @args if ( $1 eq ' in' );
5854 }
5955 my $input = run_cmd " $actions ->{ $cmd } @args " ;
6056 if ( $cmd eq ' list' ) {
@@ -67,7 +63,14 @@ sub default_handler {
6763 chomp ;
6864 next if / ^$ / ;
6965 if ( / $regex_dir / ) {
70- $dir = " $1 " ;
66+ @dir = split ( " /" , $1 );
67+ if ( $uc ) {
68+ foreach ( 0 .. $#dir ) {
69+ my $udir = uc ( $dir [$_ ] );
70+ $dir [$_ ] = $udir if exists $output -> { join ( " /" , @dir [0..$_ -1] ) . " /$udir " };
71+ }
72+ }
73+ $dir = join ( " /" , @dir );
7174 next ;
7275 }
7376 if ( my ( $name , $ext , $size , $year , $mon , $day , $hours , $mins , $longname ) = $_ =~ / $regex_list / ) {
@@ -78,10 +81,11 @@ sub default_handler {
7881 : ( $ext eq ' exe' || $ext eq ' com' || $ext eq ' bat' )
7982 ? $exec
8083 : ' -rw-r--r--' ;
84+ $name = uc ( $name ) if $uc ;
8185 my $path = ( $dir ? " /$dir /" : " /" )
82- . ( $longname ? $longname : $name )
83- . ( $ext ? " . $ext " : " " );
84- $path = uc ( $path ) unless $longname ;
86+ . ( $longname
87+ ? $longname
88+ : $name . ( $ext ? " . $ext " : " " ) ) ;
8589 $secs = defined $secs ? $secs : " 00" ;
8690 print_debug " list: path = $path " ;
8791 $output -> { $path } = sprintf " %-10s 1 %-8d %-8d %8s %s /%s /%s %s :%s :%s %s " , $perms , $< ,
@@ -96,7 +100,12 @@ sub default_handler {
96100 }
97101}
98102
103+ sub quote {
104+ map { ' "' . $_ . ' "' } @_
105+ }
106+
99107print_debug " $0 : cmd = $cmd ; archive = $archive ; args = @args " ;
108+ @args = quote( @args );
100109$actions -> { $cmd } = $ENV {MC_TEST_EXTFS_LIST_CMD } if exists $ENV {MC_TEST_EXTFS_LIST_CMD };
101110die " Cannot find command $cmd , are mtools installed?\n " unless check_mtools( $cmd );
102111exists $actions -> { $cmd } ? default_handler( $cmd , $archive , @args )
0 commit comments