|
1 #!/usr/bin/perl |
|
2 |
|
3 # Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 # All rights reserved. |
|
5 # This component and the accompanying materials are made available |
|
6 # under the terms of "Eclipse Public License v1.0" |
|
7 # which accompanies this distribution, and is available |
|
8 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 # |
|
10 # Initial Contributors: |
|
11 # Nokia Corporation - initial contribution. |
|
12 # |
|
13 # Contributors: |
|
14 # |
|
15 # Description: |
|
16 # testold.pl - check the last modified date of all files under a path to see if |
|
17 # the last modified date is after 00:00 1 Jan 1970 |
|
18 # |
|
19 # |
|
20 |
|
21 $date = 500000000; |
|
22 |
|
23 my ($path) = readOpts(@ARGV); |
|
24 |
|
25 print "*DIR:$path\n"; |
|
26 |
|
27 testOld($path, "", $date); |
|
28 |
|
29 exit 0; |
|
30 |
|
31 sub readOpts(@) |
|
32 { |
|
33 my (@args) = @_; |
|
34 |
|
35 my $path = undef; |
|
36 |
|
37 foreach my $arg (@args) |
|
38 { |
|
39 if ($arg =~ /^-/) |
|
40 { |
|
41 if ((lc($arg) eq "--help") |
|
42 ||(lc($arg) eq "-h") |
|
43 ) |
|
44 { |
|
45 showHelp(); |
|
46 exit 0; |
|
47 } |
|
48 else |
|
49 { |
|
50 print STDERR "Option '$arg' not recognised.\n\n"; |
|
51 print STDERR "Try 'testold.pl --help' for help.\n"; |
|
52 exit 1; |
|
53 } |
|
54 } |
|
55 else |
|
56 { |
|
57 if (defined($path)) |
|
58 { |
|
59 print STDERR "Testold accepts only one argument.\n\n"; |
|
60 print STDERR "Try 'testold.pl --help' for help.\n"; |
|
61 exit 1; |
|
62 } |
|
63 else |
|
64 { |
|
65 $path = $arg; |
|
66 } |
|
67 } |
|
68 } |
|
69 |
|
70 if (!defined($path)) |
|
71 { |
|
72 print STDERR "Testold must be given a path to set.\n\n"; |
|
73 print STDERR "Try 'testold.pl --help' for help.\n"; |
|
74 exit 1; |
|
75 } |
|
76 |
|
77 return ($path); |
|
78 } |
|
79 |
|
80 sub testOld($$$) |
|
81 { |
|
82 my ($root, $path, $date) = @_; |
|
83 |
|
84 opendir(PATH, $root."\\".$path); |
|
85 my @dir = readdir(PATH); |
|
86 closedir(PATH); |
|
87 |
|
88 foreach $entry (@dir) |
|
89 { |
|
90 if ($entry =~ /^\.\.?$/) |
|
91 { |
|
92 } |
|
93 elsif (-d $root."\\".$path."\\".$entry) |
|
94 { |
|
95 testOld($root, $path."\\".$entry, $date); |
|
96 } |
|
97 else |
|
98 { |
|
99 # Check file's last modified stamp |
|
100 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($root."\\".$path."\\".$entry); |
|
101 |
|
102 if ($mtime > $date) |
|
103 { |
|
104 print $path."\\".$entry."\n"; |
|
105 } |
|
106 } |
|
107 } |
|
108 } |
|
109 |
|
110 sub showHelp() |
|
111 { |
|
112 print "testold.pl [options] Path\n"; |
|
113 print " - checks the last modified date of all files under a path to see\n"; |
|
114 print " if it's newer than ".localtime($date)."\n\n"; |
|
115 print " Path - The path to the root of the files to be modified\n"; |
|
116 print "Options:\n"; |
|
117 print " --help or -h - Display this message\n\n"; |
|
118 } |
|
119 |