diff options
author | Mike Baker <mbm@openwrt.org> | 2006-05-15 22:42:04 +0000 |
---|---|---|
committer | Mike Baker <mbm@openwrt.org> | 2006-05-15 22:42:04 +0000 |
commit | 063e1cc4b6c761db71dbfba30bff6b501f710f22 (patch) | |
tree | 3d421e0769109eda27641d57c5d3e81a670b42c6 /openwrt/scripts/timestamp.pl | |
parent | 4414005acdd2cd916e74be2964ca75d7a01f0b2f (diff) | |
download | mtk-20170518-063e1cc4b6c761db71dbfba30bff6b501f710f22.zip mtk-20170518-063e1cc4b6c761db71dbfba30bff6b501f710f22.tar.gz mtk-20170518-063e1cc4b6c761db71dbfba30bff6b501f710f22.tar.bz2 |
replace find call with perl code
SVN-Revision: 3782
Diffstat (limited to 'openwrt/scripts/timestamp.pl')
-rwxr-xr-x | openwrt/scripts/timestamp.pl | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/openwrt/scripts/timestamp.pl b/openwrt/scripts/timestamp.pl index dc47e24..9735dd6 100755 --- a/openwrt/scripts/timestamp.pl +++ b/openwrt/scripts/timestamp.pl @@ -1,24 +1,35 @@ #!/usr/bin/perl 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($$) { my $path = shift; my $options = shift; my $ts = 0; my $fn = ""; - open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |"; - while (<FIND>) { - chomp; - my $file = $_; - open FILE, "<$file"; - my @stat = stat FILE; - close FILE; - if ($stat[9] > $ts) { - $ts = $stat[9]; + my @search = crawl($path,$options); + while (@search) { + my $file = shift @search; + my $mtime = stat($file)->mtime; + if ($mtime > $ts) { + $ts = $mtime; $fn = $file; } } - close FIND; return ($ts, $fn); } @@ -30,7 +41,7 @@ while (@ARGV > 0) { my $path = shift @ARGV; if ($path =~ /^-x/) { my $str = shift @ARGV; - $options{"-x"} .= " -and -not -path \\*".$str."\\*" + $options{"-x"} .= "|".$str; } elsif ($path =~ /^-/) { $options{$path} = 1; } else { |