summaryrefslogtreecommitdiffstats
path: root/scripts/timestamp.pl
blob: 10892219196ce7c164cbd069ea59635cf93890a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl
use strict;

sub get_ts($) {
	my $path = shift;
	my $ts = 0;
	open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* 2>/dev/null |";
	while (<FIND>) {
		open FILE, "<$_";
		my @stat = stat FILE;
		close FILE;
		$ts = $stat[9] if ($stat[9] > $ts);
	}
	close FIND;
	return $ts;
}

(@ARGV > 0) or push @ARGV, ".";
my $ts = 0;
my $n = ".";
my %options;
foreach my $path (@ARGV) {
	if ($path =~ /^-/) {
		$options{$path} = 1;
	} else {
		my $tmp = get_ts($path);
		if ($tmp > $ts) {
			$n = $path;
			$ts = $tmp;
		}
	}
}

if ($options{"-p"}) {
	print "$n\n";
} elsif ($options{"-t"}) {
	print "$ts\n";
} else {
	print "$n\t$ts\n";
}