Revision: | 1.2 |
Committed: | Fri Sep 15 14:17:44 2000 UTC (24 years, 7 months ago) by williamc |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | v102p1, V1_0_1, V1_0_0, V1_pre0, SCRAM_V1, SCRAMV1_IMPORT, V0_19_7, V0_19_6, V0_19_6p1, V0_19_5, SFATEST, V0_19_4, V0_19_4_pre3, V0_19_4_pre2, V0_19_4_pre1, V0_19_3, V0_19_2, V0_19_1, V0_19_0, V0_18_5, V0_18_4, V0_18_2, V0_18_1 |
Branch point for: | V1_pre1, SCRAM_V1_BRANCH, V0_19_4_B, V0_16branch |
Changes since 1.1: | +3 -1 lines |
Log Message: | Return contents in added order |
# | Content |
---|---|
1 | # |
2 | # twigmaker - a substitue compiler for testing make rules |
3 | # use : |
4 | # perl twigmaker outfile infiles |
5 | # |
6 | # - interface |
7 | # filedate(file) : return the date of the given file stored in twig |
8 | # contents() : retunr list of all elements in twig |
9 | |
10 | package BuildSystem::test::twigmaker; |
11 | use FileHandle; |
12 | require 5.004; |
13 | |
14 | sub new { |
15 | my $class=shift; |
16 | my $self={}; |
17 | bless $self, $class; |
18 | if ( @_ ) { |
19 | my $file=shift; |
20 | $self->_loadtwig($file); |
21 | } |
22 | return $self; |
23 | } |
24 | |
25 | sub maketwig { |
26 | my $self=shift; |
27 | my $out=shift; |
28 | |
29 | undef $self->{dates}; |
30 | # -- open file for output |
31 | my $fh=FileHandle->new(); |
32 | $fh->open(">".$out) || die "Unable to open $out $!"; |
33 | |
34 | # -- compile a list of all files with their datestamps |
35 | foreach $file ( @_ ) { |
36 | if ( -f $file ) { |
37 | $date=(stat($file))[9]; |
38 | } |
39 | else { |
40 | $date="not_file"; |
41 | } |
42 | print $fh $file." ".$date."\n"; |
43 | $self->{dates}{$file}=$date; |
44 | push @{$self->{dateorder}}, $file; |
45 | } |
46 | |
47 | undef $fh; |
48 | } |
49 | |
50 | sub contents { |
51 | my $self=shift; |
52 | return @{$self->{dateorder}}; |
53 | } |
54 | |
55 | sub filedate { |
56 | my $self=shift; |
57 | my $file=shift; |
58 | |
59 | return $self->{dates}{$file}; |
60 | } |
61 | |
62 | sub _loadtwig { |
63 | my $self=shift; |
64 | my $infile=shift; |
65 | |
66 | my $fh=FileHandle->new(); |
67 | $fh->open("<".$infile) || die "Unable to open $infile $!"; |
68 | while (<$fh>) { |
69 | chomp; |
70 | ($file,$date)=split / /; |
71 | $self->{dates}{$file}=$date; |
72 | push @{$self->{dateorder}}, $file; |
73 | } |
74 | undef $fh; |
75 | } |