added regex to sh/files

fixed dir
This commit is contained in:
djk 1999-05-23 14:03:13 +00:00
parent f3688be5d3
commit 2c55d933fc
2 changed files with 49 additions and 14 deletions

View File

@ -12,7 +12,18 @@ my @ref;
my $ref;
my @out;
my $f;
my $n;
my $n = 10;
if (!@f) {
my @all = (DXMsg::get_all());
my ($i, $count);
for ($i = $#all; $i > 0; $i--) {
$ref = $all[$i];
next if $self->priv < 5 && $ref->private && $ref->to ne $self->call && $ref->from ne $self->call;
unshift @ref, $ref;
last if ++$count >= $n;
}
}
while (@f) {
$f = uc shift @f;
@ -21,6 +32,7 @@ while (@f) {
next if $self->priv < 5 && $ref->private && $ref->to ne $self->call && $ref->from ne $self->call;
push @ref, $ref;
}
last;
} elsif ($f =~ /^O/o) { # dir/own
foreach $ref (DXMsg::get_all()) {
push @ref, $ref if $ref->private && ($ref->to eq $self->call || $ref->from eq $self->call);
@ -29,22 +41,41 @@ while (@f) {
foreach $ref (DXMsg::get_all()) {
push @ref, $ref if $ref->private && !$ref->read && $ref->to eq $self->call;
}
} elsif ($f > 0) { # a number of items
$n = $f;
} else {
my @all = (DXMsg::get_all());
my ($i, $count);
for ($i = $#all; $i > 0; $i--) {
$ref = $all[$i];
next if $self->priv < 5 && $ref->private && $ref->to ne $self->call && $ref->from ne $self->call;
unshift @ref, $ref;
last if ++$count > $n;
} elsif ($f eq '>' || $f eq 'TO'){
$f = uc shift @f;
if ($f) {
$f = shellregex($f);
foreach $ref (DXMsg::get_all()) {
next if $self->priv < 5 && $ref->private && $ref->to ne $self->call && $ref->from ne $self->call;
next unless $ref->to =~ m{$f};
push @ref, $ref;
}
}
} elsif ($f eq '<' || $f eq 'FROM'){
$f = uc shift @f;
if ($f) {
$f = shellregex($f);
foreach $ref (DXMsg::get_all()) {
next if $self->priv < 5 && $ref->private && $ref->to ne $self->call && $ref->from ne $self->call;
next unless $ref->from =~ m{$f};
push @ref, $ref;
}
}
} elsif ($f =~ /^\d+$/ && $f > 0) { # a number of items
$n = $f;
}
}
foreach $ref (@ref) {
push @out, $ref->dir;
if (@ref) {
my $i = @ref - $n;
$i = 0 unless $i > 0;
my $count;
while ($i < @ref) {
$ref = $ref[$i++];
push @out, $ref->dir;
last if ++$count >= $n;
}
} else {
push @out, $self->msg('e3', 'directory', $line);
}
return (1, @out);

View File

@ -15,6 +15,7 @@ my @out;
my @file;
my @d;
my @slot;
my $patt = '^.*$';
if (@f) {
my $fn = lc $f[0];
@ -22,6 +23,8 @@ if (@f) {
$fn =~ s/\.//og;
$fn =~ s/^\///og;
$root = "$root/$fn";
$patt = shellregex(lc $f[1]) if defined $f[1];
}
opendir(DIR, $root) or return (1, $self->msg('e3', 'show/files', $f[0]));
@ -31,6 +34,7 @@ closedir(DIR);
my $flag = 0;
for (@file) {
next if /^\./;
next unless m{$patt};
my $fn = "$root/$_";
my $size;