1998-02-27 07:54:42 +03:00
|
|
|
#! /usr/bin/perl
|
|
|
|
#
|
|
|
|
# External filesystem for mc, using mtools
|
|
|
|
# Written Ludek Brukner (lubr@barco.cz), 1997
|
|
|
|
#
|
|
|
|
# WARNING - This software is ALPHA - Absolutely NO WARRANTY
|
|
|
|
#
|
|
|
|
|
|
|
|
### Change this when the commands are outside PATH
|
|
|
|
$mdir = "mdir";
|
1999-04-01 04:29:27 +04:00
|
|
|
$mcopy = "mcopy -noQ";
|
1998-02-27 07:54:42 +03:00
|
|
|
###
|
|
|
|
|
|
|
|
$disk = $0;
|
|
|
|
$disk =~ s/^.*\/([^\/]*)$/\1/;
|
|
|
|
|
|
|
|
sub get_dirs {
|
|
|
|
my ($path, $name, $size, $date, $time, $longname, @lst, @rv);
|
|
|
|
|
|
|
|
$path = shift(@_);
|
|
|
|
@rv = ();
|
|
|
|
|
|
|
|
open(FILE,"$mdir $disk:/$path |");
|
|
|
|
while ( <FILE> ) {
|
|
|
|
chomp();
|
|
|
|
/^ / && next; # ignore `non-file' lines
|
|
|
|
/^$/ && next; # ignore empty lines
|
|
|
|
/^\.\.?/ && next; # ignore `.' and `..'
|
|
|
|
|
|
|
|
$name = substr($_,0,12);
|
|
|
|
$name =~ s/^([^ ]*) +([^ ]+)[ \t]*$/$1.$2/;
|
|
|
|
$name =~ s/[ .]+$//;
|
|
|
|
|
|
|
|
$_ = substr($_,12);
|
|
|
|
s/^[ ]+//;
|
|
|
|
|
|
|
|
($size,$date,$time,$longname) = split(/[ \t]+/);
|
|
|
|
|
|
|
|
@lst = split(/([:ap])/, $time);
|
|
|
|
$lst[0] += 12 if ($lst[3] eq "p");
|
|
|
|
$time = sprintf("%02d:%02d", $lst[0], $lst[2]);
|
|
|
|
@lst = split(/-/, $date);
|
|
|
|
$lst[2] %= 100 if ($lst[2] > 100);
|
|
|
|
$date = sprintf ("%02d-%02d-%02d", @lst);
|
|
|
|
|
|
|
|
$name = $path . lc(($longname) ? $longname : $name);
|
|
|
|
|
|
|
|
if ($size =~ /DIR/) {
|
|
|
|
printf("drwxr-xr-x 1 %-8d %-8d %8d %s %s %s\n", 0, 0, 0, $date, $time, $name);
|
|
|
|
push @rv, $name;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("-rw-r--r-- 1 %-8d %-8d %8d %s %s %s\n", 0, 0, $size, $date, $time, $name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(FILE);
|
|
|
|
return @rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub a_list
|
|
|
|
{
|
|
|
|
my (@files, $file);
|
|
|
|
|
|
|
|
@files = get_dirs("");
|
|
|
|
while ($file = shift(@files)) {
|
|
|
|
push @files, get_dirs("$file/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub a_copyout
|
|
|
|
{
|
|
|
|
my($archname,$filename,$dest) = @_;
|
1999-04-01 04:29:27 +04:00
|
|
|
system "$mcopy $disk:/$filename $dest >& /dev/null";
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# system "touch /tmp/deb";
|
|
|
|
|
1999-04-01 04:29:27 +04:00
|
|
|
sub a_copyin
|
|
|
|
{
|
|
|
|
my($archname,$filename,$dest) = @_;
|
|
|
|
system "$mcopy $dest $disk:/$filename >& /dev/null";
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if($ARGV[0] eq "list") { shift; &a_list(@ARGV); exit 0; }
|
|
|
|
elsif($ARGV[0] eq "copyout") { shift; &a_copyout(@ARGV); exit 0; }
|
1999-04-01 04:29:27 +04:00
|
|
|
elsif($ARGV[0] eq "copyin") { shift; &a_copyin(@ARGV); exit 0; }
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
exit 1;
|
|
|
|
|