2006-04-20 00:25:17 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
|
|
|
2006-04-20 03:45:03 +00:00
|
|
|
sub get_ts($$) {
|
2006-04-20 00:25:17 +00:00
|
|
|
my $path = shift;
|
2006-04-20 03:45:03 +00:00
|
|
|
my $options = shift;
|
2006-04-20 00:25:17 +00:00
|
|
|
my $ts = 0;
|
2006-04-20 03:45:03 +00:00
|
|
|
my $fn = "";
|
|
|
|
open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |";
|
2006-04-20 00:25:17 +00:00
|
|
|
while (<FIND>) {
|
2006-04-20 03:45:03 +00:00
|
|
|
chomp;
|
|
|
|
my $file = $_;
|
|
|
|
open FILE, "<$file";
|
2006-04-20 00:25:17 +00:00
|
|
|
my @stat = stat FILE;
|
|
|
|
close FILE;
|
2006-04-20 03:45:03 +00:00
|
|
|
if ($stat[9] > $ts) {
|
|
|
|
$ts = $stat[9];
|
|
|
|
$fn = $file;
|
|
|
|
}
|
2006-04-20 00:25:17 +00:00
|
|
|
}
|
|
|
|
close FIND;
|
2006-04-20 03:45:03 +00:00
|
|
|
return ($ts, $fn);
|
2006-04-20 00:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(@ARGV > 0) or push @ARGV, ".";
|
|
|
|
my $ts = 0;
|
|
|
|
my $n = ".";
|
|
|
|
my %options;
|
2006-04-20 03:45:03 +00:00
|
|
|
while (@ARGV > 0) {
|
|
|
|
my $path = shift @ARGV;
|
|
|
|
if ($path =~ /^-x/) {
|
|
|
|
my $str = shift @ARGV;
|
|
|
|
$options{"-x"} .= " -and -not -path \\*".$str."\\*"
|
|
|
|
} elsif ($path =~ /^-/) {
|
2006-04-20 00:25:17 +00:00
|
|
|
$options{$path} = 1;
|
|
|
|
} else {
|
2006-04-20 03:45:03 +00:00
|
|
|
my ($tmp, $fname) = get_ts($path, $options{"-x"});
|
2006-04-20 00:25:17 +00:00
|
|
|
if ($tmp > $ts) {
|
2006-04-20 03:45:03 +00:00
|
|
|
if ($options{'-f'}) {
|
|
|
|
$n = $fname;
|
|
|
|
} else {
|
|
|
|
$n = $path;
|
|
|
|
}
|
2006-04-20 00:25:17 +00:00
|
|
|
$ts = $tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($options{"-p"}) {
|
|
|
|
print "$n\n";
|
|
|
|
} elsif ($options{"-t"}) {
|
|
|
|
print "$ts\n";
|
|
|
|
} else {
|
|
|
|
print "$n\t$ts\n";
|
|
|
|
}
|