1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-30 17:40:16 +02:00

replace find call with perl code

git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@3782 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
mbm 2006-05-15 22:42:04 +00:00
parent 7da0467731
commit 7eceaccf83

View File

@ -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 {