4
4
# Written by twojstaryzdomu (twojstaryzdomu@users.noreply.github.com), 2021
5
5
#
6
6
7
+ # Undefine to disable upper-casing short names
8
+ my $uc = 1;
7
9
my ( $cmd , $archive , @args ) = @ARGV ;
8
10
die " $archive does not exist\n " unless -f " $archive " ;
9
11
my $size_kb = ( -s $archive ) / 1024;
@@ -47,15 +49,9 @@ sub default_handler {
47
49
my ( $cmd , $archive , @args ) = ( @_ );
48
50
print_debug " default_handler: @args " ;
49
51
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
52
$args [0] = " ::$args [0]" ;
54
53
@args = reverse @args ;
55
54
}
56
- elsif ( $cmd eq ' copyout' ) {
57
- $args [0] = " ::$args [0]" ;
58
- }
59
55
my $input = run_cmd " $actions ->{ $cmd } @args " ;
60
56
if ( $cmd eq ' list' ) {
61
57
my $output = {};
@@ -67,7 +63,14 @@ sub default_handler {
67
63
chomp ;
68
64
next if / ^$ / ;
69
65
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 );
71
74
next ;
72
75
}
73
76
if ( my ( $name , $ext , $size , $year , $mon , $day , $hours , $mins , $longname ) = $_ =~ / $regex_list / ) {
@@ -78,10 +81,11 @@ sub default_handler {
78
81
: ( $ext eq ' exe' || $ext eq ' com' || $ext eq ' bat' )
79
82
? $exec
80
83
: ' -rw-r--r--' ;
84
+ $name = uc ( $name ) if $uc ;
81
85
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 " : " " ) ) ;
85
89
$secs = defined $secs ? $secs : " 00" ;
86
90
print_debug " list: path = $path " ;
87
91
$output -> { $path } = sprintf " %-10s 1 %-8d %-8d %8s %s /%s /%s %s :%s :%s %s " , $perms , $< ,
@@ -96,7 +100,12 @@ sub default_handler {
96
100
}
97
101
}
98
102
103
+ sub quote {
104
+ map { ' "' . $_ . ' "' } @_
105
+ }
106
+
99
107
print_debug " $0 : cmd = $cmd ; archive = $archive ; args = @args " ;
108
+ @args = quote( @args );
100
109
$actions -> { $cmd } = $ENV {MC_TEST_EXTFS_LIST_CMD } if exists $ENV {MC_TEST_EXTFS_LIST_CMD };
101
110
die " Cannot find command $cmd , are mtools installed?\n " unless check_mtools( $cmd );
102
111
exists $actions -> { $cmd } ? default_handler( $cmd , $archive , @args )
0 commit comments