replace find call with perl code
SVN-Revision: 3782
This commit is contained in:
parent
4414005acd
commit
063e1cc4b6
1 changed files with 22 additions and 11 deletions
|
@ -1,24 +1,35 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
use strict;
|
use strict;
|
||||||
|
use File::stat;
|
||||||
|
|
||||||
|
sub crawl($$) {
|
||||||
|
my $path = shift;
|
||||||
|
my $options = shift;
|
||||||
|
my @results = $path;
|
||||||
|
opendir(DIR,$path);
|
||||||
|
foreach my $file (readdir(DIR)) {
|
||||||
|
if ($file !~m/^(\.(svn|\.?)|CVS$options)$/) {
|
||||||
|
push @results, crawl("$path/$file",$options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(DIR);
|
||||||
|
return @results;
|
||||||
|
}
|
||||||
|
|
||||||
sub get_ts($$) {
|
sub get_ts($$) {
|
||||||
my $path = shift;
|
my $path = shift;
|
||||||
my $options = shift;
|
my $options = shift;
|
||||||
my $ts = 0;
|
my $ts = 0;
|
||||||
my $fn = "";
|
my $fn = "";
|
||||||
open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |";
|
my @search = crawl($path,$options);
|
||||||
while (<FIND>) {
|
while (@search) {
|
||||||
chomp;
|
my $file = shift @search;
|
||||||
my $file = $_;
|
my $mtime = stat($file)->mtime;
|
||||||
open FILE, "<$file";
|
if ($mtime > $ts) {
|
||||||
my @stat = stat FILE;
|
$ts = $mtime;
|
||||||
close FILE;
|
|
||||||
if ($stat[9] > $ts) {
|
|
||||||
$ts = $stat[9];
|
|
||||||
$fn = $file;
|
$fn = $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close FIND;
|
|
||||||
return ($ts, $fn);
|
return ($ts, $fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +41,7 @@ while (@ARGV > 0) {
|
||||||
my $path = shift @ARGV;
|
my $path = shift @ARGV;
|
||||||
if ($path =~ /^-x/) {
|
if ($path =~ /^-x/) {
|
||||||
my $str = shift @ARGV;
|
my $str = shift @ARGV;
|
||||||
$options{"-x"} .= " -and -not -path \\*".$str."\\*"
|
$options{"-x"} .= "|".$str;
|
||||||
} elsif ($path =~ /^-/) {
|
} elsif ($path =~ /^-/) {
|
||||||
$options{$path} = 1;
|
$options{$path} = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue