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
14 s/([^\w\/.+-])/\\$1/g;
22 $mcopy = "mcopy -noQ";
27 $ENV{MTOOLS_DATE_STRING} = "mm-dd-yyyy";
28 $ENV{MTOOLS_TWENTY_FOUR_HOUR_CLOCK} = "1";
30 SWITCH: for ( $ARGV[0] ) {
33 while ($dir = shift(@dirs)) {
34 push @dirs, get_dirs("$dir/");
38 exit 1 if scalar(@ARGV) != 1;
39 $qname = quote($ARGV[0]);
40 system("$mmd $qdisk:/$qname >/dev/null");
44 exit 1 if scalar(@ARGV) != 1;
45 $qname = quote($ARGV[0]);
46 system("$mrd $qdisk:/$qname >/dev/null");
50 exit 1 if scalar(@ARGV) != 1;
51 $qname = quote($ARGV[0]);
52 system("$mdel $qdisk:/$qname >/dev/null");
56 exit 1 if scalar(@ARGV) != 2;
57 ( $qsrc, $qdest ) = @ARGV;
59 $qdest = quote($qdest);
60 system("$mcopy $qdisk:/$qsrc $qdest >/dev/null");
64 exit 1 if scalar(@ARGV) != 2;
65 ( $qdest, $qsrc ) = @ARGV;
67 $qdest = quote($qdest);
68 system("$mcopy $qsrc $qdisk:/$qdest >/dev/null");
70 /.*/ && do { # an unfamiliar command
75 my ($path, $name, $size, $date, $time, $longname, @lst, @rv);
77 my $qpath = quote($path);
80 open(FILE,"$mdir $qdisk:/$qpath |");
83 /^ / && next; # ignore `non-file' lines
84 m{^Directory for $0:/}i && next; # ignore `non-file' lines
85 /^$/ && next; # ignore empty lines
86 /^\.\.?/ && next; # ignore `.' and `..'
88 $name = substr($_,0,12);
89 $name =~ s/^([^ ]*) +([^ ]+)[ \t]*$/$1.$2/;
95 ($size,$date,$time,$longname) = split(/[ \t]+/, $_, 4);
97 defined $time || next;
99 # process "am" and "pm". Should not be needed if
100 # MTOOLS_TWENTY_FOUR_HOUR_CLOCK is respected.
101 @lst = split(/([:ap])/, $time);
102 $lst[0] += 12 if (defined $lst[3] && $lst[3] eq "p");
104 $time = sprintf("%02d:%02d", $lst[0], $lst[2]);
105 @lst = split(/-/, $date);
106 $lst[2] %= 100 if ($lst[2] > 100);
107 $date = sprintf ("%02d-%02d-%02d", @lst);
109 $name = $path . lc(($longname) ? $longname : $name);
111 if ($size =~ /DIR/) {
112 printf("drwxr-xr-x 1 %-8d %-8d %8d %s %s %s\n",
113 0, 0, 0, $date, $time, $name);
116 printf("-rw-r--r-- 1 %-8d %-8d %8d %s %s %s\n",
117 0, 0, $size, $date, $time, $name);