it.po converted in UTF-8, changed some upper/lower convention in a more 'italian...
[midnight-commander.git] / vfs / extfs / a.in
blobcdf0df3a07eedab004a10c0c716aa8b990765fef
1 #! @PERL@ -w
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
8
10 # These mtools components must be in PATH for this to work
11 $mmd = "mmd";
12 $mrd = "mrd";
13 $mdel = "mdel";
14 $mdir = "mdir -a";
15 $mcopy = "mcopy -noQ";
17 $0 =~ s|.*/||;
18 $disk = $0;
20 $ENV{MTOOLS_DATE_STRING} = "mm-dd-yyyy";
21 $ENV{MTOOLS_TWENTY_FOUR_HOUR_CLOCK} = "1";
23 SWITCH: for ( $ARGV[0] ) {
24   /list/ && do {
25     @dirs = get_dirs("");
26     while ($dir = shift(@dirs)) {
27       push @dirs, get_dirs("$dir/");
28     } exit 0; };
29   /mkdir/ && do {
30     shift; shift;
31     exit 1 if scalar(@ARGV) != 1;
32     system("$mmd $disk:/$ARGV[0] >/dev/null");
33     exit 0; };
34   /rmdir/ && do {
35     shift; shift;
36     exit 1 if scalar(@ARGV) != 1;
37     system("$mrd $disk:/$ARGV[0] >/dev/null");
38     exit 0; };
39   /rm/ && do {
40     shift; shift;
41     exit 1 if scalar(@ARGV) != 1;
42     system("$mdel $disk:/$ARGV[0] >/dev/null");
43     exit 0; };
44   /copyout/ && do {
45     shift; shift;
46     exit 1 if scalar(@ARGV) != 2;
47     ( $src, $dest ) = @ARGV;
48     system("$mcopy $disk:/$src $dest >/dev/null");
49     exit 0; };
50   /copyin/ && do {
51     shift; shift;
52     exit 1 if scalar(@ARGV) != 2;
53     ( $dest, $src ) = @ARGV;
54     system("$mcopy $src $disk:/$dest >/dev/null");
55     exit 0; };
56   /.*/ && do {                               # an unfamiliar command
57     exit 1; };
60 sub get_dirs {
61   my ($path, $name, $size, $date, $time, $longname, @lst, @rv);
63   $path = shift(@_);
64   @rv = ();
66   open(FILE,"$mdir $disk:/$path |");
67   while ( <FILE> ) {
68     chomp();
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/;
76     $name =~ s/[ .]+$//;
78     $_ = substr($_,12);
79     s/^[ ]+//;
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);
97     if ($size =~ /DIR/) {
98       printf("drwxr-xr-x   1 %-8d %-8d %8d %s %s %s\n",
99         0, 0, 0, $date, $time, $name);
100       push @rv, $name;
101     } else {
102       printf("-rw-r--r--   1 %-8d %-8d %8d %s %s %s\n",
103         0, 0, $size, $date, $time, $name);
104     }
105   }
106   close(FILE);
107   return @rv;