3 # External filesystem for mc, using mtools
4 # Written Ludek Brukner <lubr@barco.cz>, 1997
5 # Much improved by Tom Perkins <968794022@noid.net>, 2000
7 # WARNING - This software is ALPHA - Absolutely NO WARRANTY
10 # These mtools components must be in PATH for this to work
15 $mcopy = "mcopy -noQ";
20 $ENV{MTOOLS_DATE_STRING} = "mm-dd-yyyy";
21 $ENV{MTOOLS_TWENTY_FOUR_HOUR_CLOCK} = "1";
23 SWITCH: for ( $ARGV[0] ) {
26 while ($dir = shift(@dirs)) {
27 push @dirs, get_dirs("$dir/");
31 exit 1 if scalar(@ARGV) != 1;
32 system("$mmd $disk:/$ARGV[0] >/dev/null");
36 exit 1 if scalar(@ARGV) != 1;
37 system("$mrd $disk:/$ARGV[0] >/dev/null");
41 exit 1 if scalar(@ARGV) != 1;
42 system("$mdel $disk:/$ARGV[0] >/dev/null");
46 exit 1 if scalar(@ARGV) != 2;
47 ( $src, $dest ) = @ARGV;
48 system("$mcopy $disk:/$src $dest >/dev/null");
52 exit 1 if scalar(@ARGV) != 2;
53 ( $dest, $src ) = @ARGV;
54 system("$mcopy $src $disk:/$dest >/dev/null");
56 /.*/ && do { # an unfamiliar command
61 my ($path, $name, $size, $date, $time, $longname, @lst, @rv);
66 open(FILE,"$mdir $disk:/$path |");
69 /^ / && next; # ignore `non-file' lines
70 m{^Directory for $0:/}i && next; # ignore `non-file' lines
71 /^$/ && next; # ignore empty lines
72 /^\.\.?/ && next; # ignore `.' and `..'
74 $name = substr($_,0,12);
75 $name =~ s/^([^ ]*) +([^ ]+)[ \t]*$/$1.$2/;
81 ($size,$date,$time,$longname) = split(/[ \t]+/, $_, 4);
83 defined $time || next;
85 # process "am" and "pm". Should not be needed if
86 # MTOOLS_TWENTY_FOUR_HOUR_CLOCK is respected.
87 @lst = split(/([:ap])/, $time);
88 $lst[0] += 12 if (defined $lst[3] && $lst[3] eq "p");
90 $time = sprintf("%02d:%02d", $lst[0], $lst[2]);
91 @lst = split(/-/, $date);
92 $lst[2] %= 100 if ($lst[2] > 100);
93 $date = sprintf ("%02d-%02d-%02d", @lst);
95 $name = $path . lc(($longname) ? $longname : $name);
98 printf("drwxr-xr-x 1 %-8d %-8d %8d %s %s %s\n",
99 0, 0, 0, $date, $time, $name);
102 printf("-rw-r--r-- 1 %-8d %-8d %8d %s %s %s\n",
103 0, 0, $size, $date, $time, $name);