ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Cache/Cache.pm
(Generate patch)

Comparing COMP/SCRAM/src/Cache/Cache.pm (file contents):
Revision 1.4 by sashby, Tue Jun 28 19:08:55 2005 UTC vs.
Revision 1.11 by muzaffar, Fri Jan 14 17:36:42 2011 UTC

# Line 10 | Line 10
10   # Copyright: 2003 (C) Shaun Ashby
11   #
12   #--------------------------------------------------------------------
13 +
14 + =head1 NAME
15 +
16 + Cache::Cache - A generic directory cache object.
17 +
18 + =head1 SYNOPSIS
19 +  
20 +      my $cacheobject=Cache::Cache->new();
21 +
22 + =head1 DESCRIPTION
23 +
24 + A package to provide caching of directory information. Directory timestamps
25 + are tracked on further reading of an existing cache and lists of modified
26 + directories and BuildFiles can be obtained.
27 +
28 + =head1 METHODS
29 +
30 + =over
31 +
32 + =cut
33 +
34   package Cache::Cache;
35   require 5.004;
36  
37   use Exporter;
38 + use Utilities::AddDir;
39   @ISA=qw(Exporter);
40   #
41 +
42 + =item   C<new()>
43 +
44 + Create a new Cache::Cache object. The name of the cache is B<DirCache.db.gz> by default.
45 +
46 + =cut
47 +
48   sub new()
49     ###############################################################
50     # new                                                         #
# Line 31 | Line 60 | sub new()
60     my $class=ref($proto) || $proto;
61     my $self=
62        {
63 <      CACHENAME => "DirCache.db",     # Name of global file/dir cache;
63 >      CACHENAME => "DirCache.db.gz",     # Name of global file/dir cache;
64        BFCACHE => {},                  # BuildFile cache;
65        DIRCACHE => {},                 # Source code cache;
66 +      EXTRASUFFIX => {},              # path with extra suffix;
67        STATUS => 0,                    # Status of cache: 1 => something changed. If so, force save;
68        VERBOSE => 0                    # Verbose mode (0/1);
69        };
# Line 42 | Line 72 | sub new()
72     return $self;
73     }
74  
75 + =item   C<getdir($path)>
76 +
77 + Return a list of directories starting from $path.
78 +
79 + =cut
80 +
81   sub getdir()
82     {
83     my $self=shift;
84 <   my ($path) = @_;
84 >   my $path=shift;
85 >
86     opendir (DIR, $path) || die "$path: cannot read: $!\n";
87     # Skip .admin and CVS subdirectories too.
88     # Also skip files that look like backup files or files being modified with emacs:
89 <   my @items = map { "$path/$_" } grep (
53 <                                        $_ ne "." && $_ ne ".." && $_ ne "CVS" &&
54 <                                        $_ ne ".admin" && $_ !~ m|\.#*|,
55 <                                        readdir(DIR)
56 <                                        );  
89 >   my @items = map { "$path/$_" } grep ((-d "$path/$_") && ($_!~/^(CVS|\..*)$/),readdir(DIR));
90     closedir (DIR);
91     return @items;
92     }
93  
94 + =item   C<prune($path)>
95 +
96 + Recursively remove directories from the cache starting at $path.
97 +
98 + =cut
99 +
100   sub prune()
101     {
102     my $self=shift;
103 <   my ($path) = @_;
103 >   my $path = shift;
104 >   my $skipparent = shift || 0;
105 >   my $suffix = shift || "";
106 >   $self->extra_suffix($path,$suffix) if ($suffix);
107 >   if (!$skipparent)
108 >      {
109 >      my $parent = $path;
110 >      $parent =~ s|(.*)/[^/]+$|$1|;
111 >      if ($parent ne $path && exists $self->{DIRCACHE}{$parent})
112 >         {
113 >         my ($time, @subs) = @{$self->{DIRCACHE}{$parent}};
114 >         $self->{DIRCACHE}{$parent} = [ $time, grep ($_ ne $path, @subs) ];
115 >         $self->{ADDEDDIR}{$parent}=1;
116 >         $self->cachestatus(1);
117 >         }
118 >      }
119 >   if (exists $self->{ADDEDDIR}{$path}){delete $self->{ADDEDDIR}{$path};}
120 >   return if ! exists $self->{DIRCACHE}{$path};
121     $self->cachestatus(1);
122 <   return if ! exists $self->{DIRCACHE}->{$path};
123 <   my (undef, undef, @subs) = @{$self->{DIRCACHE}->{$path}};
124 <   delete $self->{DIRCACHE}->{$path};
122 >   foreach my $bf ("$ENV{SCRAM_BUILDFILE}.xml","$ENV{SCRAM_BUILDFILE}")
123 >      {
124 >      if (exists $self->{BFCACHE}{"${path}/${bf}"})
125 >         {
126 >         if (!-f "${path}/${bf}") {$self->{REMOVEDBF}{"${path}/${bf}"}=1;}
127 >         delete $self->{BFCACHE}{"${path}/${bf}"};
128 >         if (exists $self->{ADDEDBF}{"${path}/${bf}"}){delete $self->{ADDEDBF}{"${path}/${bf}"};}
129 >         last;
130 >         }
131 >      }
132 >   if (!-d $path) {$self->{REMOVEDDIR}{$path}=1;}
133 >   my (undef, @subs) = @{$self->{DIRCACHE}{$path}};
134 >   delete $self->{DIRCACHE}{$path};
135     foreach my $sub (@subs)
136        {
137 <      $self->prune($sub);
137 >      $self->prune($sub,1);
138        }
139     }
140  
141 + =item   C<checktree($path, $required, $dofiles)>
142 +
143 + A timestamp checking routine. Starting from $path, check all timestamps of
144 + directories and their files. Skip all files unless $dofiles is 1.
145 +
146 + =cut
147 +
148   sub checktree()
149     {
150 <   my ($self, $path, $required, $dofiles) = @_;
150 >   my ($self, $path, $required) = @_;
151     # Check if this path needs to be checked.  If it exists, has the same mode
152     # and the same time stamp, it's up to date and doesn't need to be checked.
153     # Otherwise if it is a directory whose time-stamp has changed, rescan it.
154     # If the path has be removed, prune it from the cache.  Note that we skip
155     # non-directories unless $dofiles is set.  Considering only directories is
156     # dramatically faster.
84   next if ($path =~ /\.admin/); # skip .admin dirs
85   next if ($path =~ /.*CVS/);
157  
158     # NB: We stat each path only once ever.  The special "_" file handle uses
159     # the results from the last stat we've made.  See man perlfunc/stat.
160     if (! stat($path))
161        {
162        die "$path: $!\n" if $required;
92      $self->logmsg("SCRAM: $path: missing: removing from cache\n");
163        $self->prune($path);
94      # Something changed so force write of cache:
95      $self->cachestatus(1);
164        return;
165        }
166  
167     # If the entry in the cache is not the same mode or time, force an update.
168     # Otherwise use the cache as the list of items we need to change.
169 <   my $cached = $self->{DIRCACHE}->{$path};  
169 >   my $cached = $self->{DIRCACHE}{$path};  
170     my @items = ();
171  
172     if (! -d _)
173        {
174 <      if ($dofiles)
175 <         {
108 <         $self->logmsg("SCRAM: $path: updating cache\n");
109 <         $self->{DIRCACHE}->{$path} = [ (stat(_))[2, 9] ];
110 <         }
111 <      else
112 <         {
113 <         $self->logmsg("SCRAM: $path: not a directory: removing from parent's list\n");
114 <         my $parent = $path;
115 <         $parent =~ s|(.*)/[^/]+$|$1|;
116 <         if ($parent ne $path && exists $self->{DIRCACHE}->{$parent})
117 <            {
118 <            my ($mode, $time, @subs) = @{$self->{DIRCACHE}->{$parent}};
119 <            $self->{DIRCACHE}->{$parent} = [ $mode, $time, grep ($_ ne $path, @subs) ];
120 <            }
121 <         $self->cachestatus(1);
122 <         }
174 >      $self->prune($path);
175 >      return;
176        }
177 <   elsif (! $cached || $cached->[0] != (stat(_))[2])
177 >   elsif (! $cached)
178        {
179        # When a directory is added, this block is activated
180 <      $self->added_dirs($path); # Store the newly-added dir
181 <      $self->logmsg("SCRAM: $path: new or changed: pruning and recreating cache\n");
129 <      $self->prune($path);
130 <      $self->{DIRCACHE}->{$path} = [ (stat(_))[2, 9], @items = $self->getdir($path) ];
180 >      $self->{ADDEDDIR}{$path}=1;
181 >      $self->{DIRCACHE}{$path} = [ (stat(_))[9], @items = $self->getdir($path) ];
182        $required = 1;
183        $self->cachestatus(1);
184        }
185 <   elsif ($cached->[1] != (stat(_))[9])
185 >   elsif ($cached->[0] != (stat(_))[9])
186        {
187 +      my $ntime = (stat(_))[9];
188        # When a subdirectory is removed, this block is activated
189        #
190        # This is a parent directory. We store this as any
191        # update can be taken recursively from this dir:
192 <      $self->modified_parentdirs($path);
141 <      
142 <      $self->logmsg("SCRAM: $path: modified: updating cache\n");
192 >      #$self->modified_parentdirs($path);
193        # Current subdirs:
194 <      @items = $self->getdir($path);
195 <      
196 <      # Start checking from element number 2:
197 <      for (my $i = 2; $i <= $#$cached; $i++)
198 <         {
199 <         if (! grep($cached->[$i] eq $_, @items))
194 >      my %curdirs = map { $_ => 1 } $self->getdir($path);
195 >      my %olddirs = ();
196 >      for (my $i = 1; $i <= $#$cached; $i++)
197 >         {
198 >         my $d = $cached->[$i];
199 >         $olddirs{$d}=1;
200 >         if (!exists $curdirs{$d})
201              {
202 <            # Add the removed path to a store for later access
152 <            # from the project cache. This info is needed to update
153 <            # the cached data:
154 <            $self->schedremoval($cached->[$i]);
155 <            # Remove all child data:
156 <            $self->clean_cache_recursive($cached->[$i]);
202 >            $self->prune($d,1);
203              }
204 <         }      
204 >         }
205        
206 <      $self->{DIRCACHE}->{$path} = [ (stat(_))[2, 9], @items ];
207 <      $required = 1;
206 >      foreach my $d (keys %curdirs)
207 >         {
208 >         if (!exists $olddirs{$d})
209 >            {
210 >            if ($self->extra_suffix($d))
211 >               {
212 >               delete $curdirs{$d};
213 >               }
214 >            }
215 >         }
216 >
217 >      $self->{ADDEDDIR}{$path}=1;
218        $self->cachestatus(1);
219 +      @items = keys %curdirs;
220 +      $required = 0;
221 +      $self->{DIRCACHE}{$path} = [ $ntime, @items ];
222        }
223     else
224        {
225 <      $self->logmsg("SCRAM: $path: valid: using cached directory list\n");
167 <      (undef, undef, @items) = @{$self->{DIRCACHE}->{$path}};
225 >      (undef, @items) = @{$self->{DIRCACHE}{$path}};
226        $required = 0;
227        }
228 +   if (($self->{cachereset}) && (!exists $self->{ADDEDDIR}{$path}))
229 +      {
230 +      $self->{ADDEDDIR}{$path}=1;
231 +      $self->cachestatus(1);
232 +      }
233    
234 +   my $bfcachedir=$ENV{LOCALTOP}."/".$ENV{SCRAM_TMP}."/".$ENV{SCRAM_ARCH}."/cache/bf/${path}";
235 +   my $cbf="${bfcachedir}/$ENV{SCRAM_BUILDFILE}";
236 +   my $bftime=0;
237 +   my $bf="${path}/$ENV{SCRAM_BUILDFILE}";
238 +   foreach my $ext (".xml","")
239 +      {
240 +      my $bfn="$bf$ext";
241 +      if (! stat ($bfn))
242 +         {
243 +         if (exists $self->{BFCACHE}{$bfn})
244 +            {
245 +            $self->{REMOVEDBF}{$bfn}=1;
246 +            delete $self->{BFCACHE}{$bfn};
247 +            Utilities::AddDir::adddir($bfcachedir);
248 +            open(BF,">${cbf}");close(BF);
249 +            $self->cachestatus(1);
250 +            }
251 +         }
252 +      else
253 +         {
254 +         $bftime = (stat(_))[9];
255 +         if ((! exists $self->{BFCACHE}{$bfn}) ||
256 +             ($bftime != $self->{BFCACHE}{$bfn}))
257 +            {
258 +            if ((!-f "${cbf}") || (exists $self->{BFCACHE}{$bfn}))
259 +               {
260 +               Utilities::AddDir::adddir($bfcachedir);
261 +               open(BF,">${cbf}");close(BF);
262 +               }
263 +            $self->{ADDEDBF}{$bfn}=1;
264 +            delete $self->{BFCACHE}{$bf};
265 +            $self->{BFCACHE}{$bfn}=$bftime;
266 +            if ($ext eq ""){$self->{nonxml}+=1;}
267 +            $self->cachestatus(1);
268 +            }
269 +         elsif($self->{cachereset})
270 +            {
271 +            $self->{ADDEDBF}{$bfn}=1;
272 +            if ($ext eq ""){$self->{nonxml}+=1;}
273 +            if (!-f "${cbf}")
274 +               {
275 +               Utilities::AddDir::adddir($bfcachedir);
276 +               open(BF,">${cbf}");close(BF);
277 +               }
278 +            $self->cachestatus(1);
279 +            }
280 +         last;
281 +         }
282 +      }
283 +   if (exists $self->{ExtraDirCache})
284 +      {
285 +      eval {$self->{ExtraDirCache}->DirCache($self,$path);};
286 +      }
287     # Process sub-directories
288     foreach my $item (@items)
289        {
290 <      $self->checktree($item, $required, $dofiles);
290 >      $self->checktree($item, $required);
291        }
292     }
293  
294 + =item   C<clean_cache_recursive($startdir)>
295 +
296 + Recursive remove cached data for directories under $startdir.
297 +
298 + =cut
299 +
300   sub clean_cache_recursive()
301     {
302     my $self=shift;
# Line 192 | Line 314 | sub clean_cache_recursive()
314     return $self;
315     }
316  
317 + =item   C<dirtree($dir,$dofiles)>
318 +
319 + Starting from $dir, scan the directory tree. Ignore files unless $dofiles is set. This
320 + function just calls checktree().
321 +
322 + =cut
323 +
324   sub dirtree()
325     {
326     my $self=shift;
327 <   my ($dir,$dofiles) = @_;
327 >   my ($dir) = @_;
328  
329     # Get the directory tree:
330 <   $self->checktree($dir, 1, $dofiles);
330 >   $self->checktree($dir, 1);
331     return $self;
332     }
333  
334 + =item   C<checkfiles()>
335 +
336 + Function to actually run the timestamp checks. This is only run from
337 + SCRAM::CMD::build().
338 +
339 + =cut
340 +
341   sub checkfiles()
342     {
343     my $self=shift;
344 +   $self->{cachereset}=shift || 0;
345     # Scan config dir for top-level data, then start from src:
346 <   my @scandirs=($ENV{LOCALTOP}."/".$ENV{SCRAM_CONFIGDIR}, $ENV{SCRAM_SOURCEDIR});
210 <   my $dofiles=1;
346 >   my @scandirs=($ENV{SCRAM_CONFIGDIR}, $ENV{SCRAM_SOURCEDIR});
347     # Loop over all directories that need scanning (normally just src and config):
348 +   $self->{nonxml}=0;
349 +   eval ("use SCRAM::Plugins::DirCache;");
350 +   if(!$@) {$self->{ExtraDirCache} = SCRAM::Plugins::DirCache->new();}
351     foreach my $scand (@scandirs)
352        {
353        $self->logmsg("SCRAM: Scanning $scand [dofiles set to ".$dofiles."]\n");
354        # Check the directory tree:
355 <      $self->dirtree($scand, $dofiles);
217 <      $dofiles=0;
355 >      $self->dirtree($scand);
356        }
357 <  
220 <   # Mark everything in the cache old:
221 <   map { $_->[0] = 0 } values %{$self->{BFCACHE}};
222 <   map { $_->[0] = 0 } values %{$self->{CONFIGCACHE}};
223 <
224 <   # Remember which directories have buildfiles in them:
225 <   my %files = map { -f $_ ? ($_ => [ (stat(_))[9] ]) : () }
226 <               map { "$_/BuildFile" }
227 <               keys %{$self->{DIRCACHE}};
228 <
229 <   # Get list of files in config dir:
230 <   my $configcache = {};
231 <   my %configfiles = map { -f $_ &&
232 <                              $_ =~ m|$ENV{LOCALTOP}/$ENV{SCRAM_CONFIGDIR}.*?$|
233 <                              ? ($_ => [ (stat(_))[9] ]) : () } keys %{$self->{DIRCACHE}};
234 <
235 <   # Also add ToolCache.db to the cache: FIXME: should probably use aglob here so
236 <   #                                     that all SCRAM_ARCHs are taken into account.
237 <   $configfiles{$ENV{LOCALTOP}."/.SCRAM/".$ENV{SCRAM_ARCH}."/ToolCache.db"} =
238 <      [ (stat($ENV{LOCALTOP}."/.SCRAM/".$ENV{SCRAM_ARCH}."/ToolCache.db"))[9] ];
239 <  
240 <   # Compare or add to config file cache. We need this to be separate so we can tell if a
241 <   # file affecting our build has been changed:
242 <   while (my ($path, $vals) = each %configfiles)
357 >   if ($self->cachestatus())
358        {
359 <      if ($self->{CONFIGCACHE}->{$path} && $self->{CONFIGCACHE}->{$path}[1] == $vals->[0])
360 <         {
361 <         $configcache->{$path} = $self->{CONFIGCACHE}->{$path};
362 <         delete $self->{CONFIGCACHE}->{$path};
363 <         }
364 <      else
365 <         {
251 <         $self->{STATUSCONFIG}=1;
252 <         $self->logmsg("SCRAM: $path: changed\n");
253 <         $configcache->{$path} = [ 1, @$vals ];
254 <         delete $self->{CONFIGCACHE}->{$path};
359 >      foreach my $bf ("$ENV{SCRAM_BUILDFILE}.xml","$ENV{SCRAM_BUILDFILE}")
360 >         {
361 >         if (exists $self->{BFCACHE}{"$ENV{SCRAM_CONFIGDIR}/${bf}"})
362 >            {
363 >            $self->{ADDEDBF}{"$ENV{SCRAM_CONFIGDIR}/${bf}"}=1;
364 >            last;
365 >            }
366           }
367        }
368 <  
369 <   # Compare with existing cache: remove from cache what no longer
259 <   # exists, then check which build files are newer than the cache.
260 <   my $newcache = {};
261 <
262 <   while (my ($path, $vals) = each %files)
368 >   delete $self->{ExtraDirCache};
369 >   if ($self->{nonxml} > 0)
370        {
371 <      if ($self->{BFCACHE}->{$path} && $self->{BFCACHE}->{$path}[1] == $vals->[0])
265 <         {
266 <         $newcache->{$path} = $self->{BFCACHE}->{$path};
267 <         delete $self->{BFCACHE}->{$path};
268 <         }
269 <      else
270 <         {
271 <         $self->{STATUSSRC}=1;
272 <         $self->logmsg("SCRAM: $path: changed\n");
273 <         $newcache->{$path} = [ 1, @$vals ];
274 <         delete $self->{BFCACHE}->{$path};
275 <         }
371 >      #print STDERR "**** WARNING: ",$self->{nonxml}," non-xml based $ENV{SCRAM_BUILDFILE} were read.\n";
372        }
277
278   # If there were BuildFiles that were removed, force update of cache
279   # and remove the BUILDFILEDATA entries:
280   foreach my $path (keys %{$self->{BFCACHE}})
281      {
282      $self->logmsg("SCRAM: $path: removed. Build data will be removed from build cache.\n");
283      $self->cachestatus(1);      
284      # Store this so that later, we can tell the BuildDataStore to remove it:
285      $self->schedremoval($path);
286      }
287  
288   # Save the BuildFile cache:
289   delete $self->{BFCACHE};
290   $self->{BFCACHE} = $newcache;
291
292   # Save the config cache:
293   delete $self->{CONFIGCACHE};
294   $self->{CONFIGCACHE} = $configcache;
373     return $self;
374     }
375  
376 + =item   C<dircache()>
377 +
378 + Return a reference to the directory cache hash.
379 +
380 + =cut
381 +
382   sub dircache()
383     {
384     my $self=shift;
# Line 302 | Line 386 | sub dircache()
386     return $self->{DIRCACHE};
387     }
388  
389 + =item   C<added_dirs($path)>
390 +
391 + Add $path to the list of directories added since last scan, or return
392 + the list of added directories if no argument given.
393 +
394 + =cut
395 +
396   sub added_dirs()
397     {
398     my $self=shift;
# Line 328 | Line 419 | sub added_dirs()
419        }
420     }
421  
422 + =item   C<modified_parentdirs($path)>
423 +
424 + Add a directory $path to the list of parent directories (directories
425 + having subdirectories), or return a reference to the list.
426 + Storing this parent allows any update to be taken recursively from this
427 + location.
428 +  
429 + =cut
430 +
431   sub modified_parentdirs()
432     {
433     my $self=shift;
# Line 356 | Line 456 | sub modified_parentdirs()
456        }
457     }
458  
459 + =item   C<schedremoval($d)>
460 +
461 + Add directory $d to list of directories that should be removed
462 + recursively from the cache.
463 + If no arguments given, return a reference to a list of
464 + directories to be removed.
465 +  
466 + =cut
467 +
468   sub schedremoval()
469     {
470     my $self=shift;
# Line 380 | Line 489 | sub schedremoval()
489        }
490     }
491  
492 + =item   C<filestatus()>
493 +
494 + Return a true or false value depending on whether
495 + a BuildFile was changed or not.
496 +
497 + =cut
498 +
499   sub filestatus()
500     {
501     my $self=shift;
# Line 388 | Line 504 | sub filestatus()
504     return $self->{STATUSSRC};
505     }
506  
507 + =item   C<configstatus()>
508 +
509 + Return a true or false value depending on whether
510 + a file in the config directory was changed or not.
511 +
512 + =cut
513 +
514   sub configstatus()
515     {
516     my $self=shift;
# Line 396 | Line 519 | sub configstatus()
519     return $self->{STATUSCONFIG};
520     }
521  
522 + =item   C<bf_for_scanning()>
523 +
524 + Return a list of BuildFiles to re-read. Note that this is only done
525 + if the status was changed (i.e. not necessary to read through the list
526 + of BuildFiles to know whether something changed as the flag B<STATUSSRC>
527 + is set as the source tree is checked).
528 + If B<STATUSCONFIG> is true, all BuildFiles are marked to be read.
529 +
530 + =cut
531 +
532   sub bf_for_scanning()
533     {
534     my $self=shift;
535     my $MODIFIED = [];
536 <  
404 <   $self->{STATUSSRC} = 0;
405 <
406 <   # Return a list of buildfiles to be reread. Note that we only do this
407 <   # if the status was changed (i.e. don't have to read through the list of BFs to know
408 <   # whether something changed as the flags STATUSSRC is set as the src tree is checked).
409 <   # Also we check to see if STATUSCONFIG is true. If so all BuildFiles are marked to be read:
410 <   if ($self->{STATUSCONFIG})
411 <      {
412 <      $self->{STATUSCONFIG} = 0;
413 <      # Return all the buildfiles since they'll all to be read:
414 <      return [ keys %{$self->{BFCACHE}} ];
415 <      }
416 <   else
417 <      {
418 <      # Only return the files that changed:
419 <      map { ( $self->{BFCACHE}{$_}->[0] == 1 ) && push(@$MODIFIED, $_) } keys %{$self->{BFCACHE}};
420 <      # Reset the flag:
421 <      $self->{STATUSCONFIG} = 0;
422 <      }
536 >   map { push(@$MODIFIED, $_) } @{$self->{ADDEDBF}};
537     return $MODIFIED;
538     }
539  
540 + =item   C<paths()>
541 +
542 + Return a reference to an array of directories for the current source tree.
543 +
544 + =cut
545 +
546   sub paths()
547     {
548     my $self=shift;
549     my $paths = {};
550    
551 <   $self->{ALLDIRS} = [];
552 <  
553 <   # Pass over each dir, skipping those that are not wanted and
434 <   # storing those that are relevant to an array:
435 <   foreach my $path (keys %{$self->{DIRCACHE}})
436 <      {
437 <      if ( ! -d $path && $path != m|$ENV{LOCALTOP}/$ENV{SCRAM_CONFIGDIR}.*?$|)
438 <         {      
439 <         $self->logmsg("SCRAM: $path no longer exists. Clearing from cache.\n");
440 <         $self->cachestatus(1);
441 <         delete $self->{DIRCACHE}->{$path};
442 <         }
443 <      else
444 <         {
445 <         next if $path =~ m|/CVS$|;     # Ignore CVS directories.
446 <         next if $path =~ m|/\.admin$|; # Ignore .admin directories.
447 <         next if $path =~ m|\Q$ENV{LOCALTOP}/$ENV{SCRAM_CONFIGDIR}\L|;
448 <         push(@{$self->{ALLDIRS}},$path);
449 <         }
450 <      }
451 <  
452 <   # Return the array:
453 <   return $self->{ALLDIRS};
551 >   my $ALLDIRS = [];
552 >   map { push(@$ALLDIRS, $_) } keys %{$self->{DIRCACHE}};
553 >   return $ALLDIRS;
554     }
555  
556 + =item   C<verbose()>
557 +
558 + Turn verbosity for the cache on or off.
559 +
560 + =cut
561 +
562   sub verbose()
563     {
564     my $self=shift;
# Line 461 | Line 567 | sub verbose()
567        : $self->{VERBOSE}
568     }
569  
570 + =item   C<cachestatus()>
571 +
572 + Set or return the cache status to indicate whether or not a file
573 + timestamp has changed since the last pass.
574 +
575 + =cut
576 +
577   sub cachestatus()
578     {
579     my $self=shift;
# Line 469 | Line 582 | sub cachestatus()
582        : $self->{STATUS}
583     }
584  
585 + =item   C<logmsg(@message)>
586 +
587 + Print a message to B<STDERR>. This is only used in
588 + checktree(), checkfiles() and paths().
589 +
590 + =cut
591 +
592   sub logmsg()
593     {
594     my $self=shift;
# Line 476 | Line 596 | sub logmsg()
596     print STDERR @_ if $self->verbose();
597     }
598  
599 + =item   C<name()>
600 +
601 + Set or return the name of the cache. Normally set
602 + to B<DirCache.db.gz> (and not architecture dependent).
603 +
604 + =cut
605 +
606   sub name()
607     {
608     my $self=shift;
# Line 484 | Line 611 | sub name()
611        : $self->{CACHENAME}
612     }
613  
614 + sub get_data()
615 +   {
616 +     my $self=shift;
617 +     my $type=shift;
618 +     @_ ? $self->{$type} = shift
619 +        : $self->{$type};
620 +   }
621 +
622 + sub extra_suffix()
623 +   {
624 +     my $self=shift;
625 +     my $path=shift;
626 +     @_ ? $self->{EXTRASUFFIX}{$path}=shift
627 +        : exists $self->{EXTRASUFFIX}{$path};
628 +   }
629 +  
630 + sub get_nonxml()
631 +   {
632 +   my $self=shift;
633 +   return $self->{nonxml};
634 +   }
635 +
636   1;
637 +
638 + =back
639 +
640 + =head1 AUTHOR
641 +
642 + Shaun Ashby (with contribution from Lassi Tuura)
643 +
644 + =head1 MAINTAINER
645 +
646 + Shaun Ashby
647 +  
648 + =cut
649 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines