Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit 8461480

Browse files
author
twojstaryzdomu
committed
extfs/img: Simplify mdir parsing using MTOOLS_DOTTED_DIR.
1 parent 7d054ca commit 8461480

File tree

1 file changed

+9
-9
lines changed
  • src/vfs/extfs/helpers

1 file changed

+9
-9
lines changed

src/vfs/extfs/helpers/img

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ my $actions = {
2323
};
2424

2525
my $regex_dir = qr"(?<=^Directory for ::/)(.*)$";
26-
my $regex_list = qr"^(\S+)\s+(\S*)\s+(\S+)\s+(\d{4})-(\d{2})-(\d{2})\s+(\d{1,2}):(\d{1,2})\s\s?(.*)$";
26+
# Required for regex
27+
$ENV{MTOOLS_DOTTED_DIR} = 1;
28+
my $regex_list = qr"^(\S+)\s+(\S+)\s+(\d{4})-(\d{2})-(\d{2})\s+(\d{1,2}):(\d{1,2})\s\s?(.*)$";
2729

2830
sub print_debug {
2931
print "@_\n" if exists $ENV{DEBUG};
@@ -73,19 +75,17 @@ sub default_handler {
7375
$dir = join( "/", @dir );
7476
next;
7577
}
76-
if ( my ( $name, $ext, $size, $year, $mon, $day, $hours, $mins, $longname ) = $_ =~ /$regex_list/ ) {
77-
print_debug "list: dir = $dir, name = $name, ext = $ext, size = $size, year = $year, mon = $mon, day = $day, hours = $hours, mins = $mins, longname = $longname;";
78-
next if ( $name eq '.' || $name eq '..' );
78+
if ( my ( $filename, $size, $year, $mon, $day, $hours, $mins, $longname ) = $_ =~ /$regex_list/ ) {
79+
print_debug "list: dir = $dir, filename = $filename, size = $size, year = $year, mon = $mon, day = $day, hours = $hours, mins = $mins, longname = $longname;";
80+
next if ( $filename eq '.' || $filename eq '..' );
7981
my $perms = $size eq '<DIR>'
8082
? 'drwxr-xr-x'
81-
: ( $ext eq 'exe' || $ext eq 'com' || $ext eq 'bat' )
83+
: $filename =~ /com|exe|bat/i
8284
? $exec
8385
: '-rw-r--r--';
84-
$name = uc( $name ) if $uc;
86+
$filename = uc( $filename ) if $uc;
8587
my $path = ( $dir ? "/$dir/" : "/" )
86-
. ( $longname
87-
? $longname
88-
: $name . ( $ext ? ".$ext" : "" ) );
88+
. ( $longname ? $longname : $filename );
8989
$secs = defined $secs ? $secs : "00";
9090
print_debug "list: path = $path";
9191
$output->{ $path } = sprintf "%-10s 1 %-8d %-8d %8s %s/%s/%s %s:%s:%s %s", $perms, $<,

0 commit comments

Comments
 (0)