Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Piatok, 19. apríl 2024

Rozdiely pre scripts/perl/filesystem/hardlink-files.pl medzi verziami 1.5 a 1.6

verzia 1.5, 2005/07/10 22:17:13 verzia 1.6, 2005/07/24 21:40:48
Riadok 20 
Riadok 20 
 #  #
 #  #
   
 # $Platon: scripts/perl/filesystem/hardlink-files.pl,v 1.4 2005/05/24 15:43:00 rajo Exp $  # $Platon: scripts/perl/filesystem/hardlink-files.pl,v 1.5 2005/07/10 22:17:13 rajo Exp $
   
 use strict;  use strict;
   
Riadok 30  use Cwd qw( abs_path );
Riadok 30  use Cwd qw( abs_path );
 use File::Basename qw( basename fileparse );  use File::Basename qw( basename fileparse );
 use Digest::MD5;  use Digest::MD5;
 #use Digest::SHA1;  #use Digest::SHA1;
 use Data::Dumper;  #use Data::Dumper;
   use XML::Dumper;
 use Time::HiRes qw(gettimeofday tv_interval);  use Time::HiRes qw(gettimeofday tv_interval);
   
 $| = 1;  $| = 1;
Riadok 41  use vars qw (
Riadok 42  use vars qw (
         *file *dir *prune          *file *dir *prune
         $md5sums $cache $stat $stat_global $mountpoints          $md5sums $cache $stat $stat_global $mountpoints
         @directories          @directories
           $dump
 );  );
   
 unless (scalar(@ARGV)) {  unless (scalar(@ARGV)) {
Riadok 48  unless (scalar(@ARGV)) {
Riadok 50  unless (scalar(@ARGV)) {
         exit 1;          exit 1;
 }  }
   
 $cache_file = ".hardlink-cache";  $dump = new XML::Dumper;
   
   $cache_file = ".hardlink-cache.xml";
 $start = [gettimeofday];  $start = [gettimeofday];
   
 *file   = *File::Find::name;  *file   = *File::Find::name;
Riadok 144  foreach my $xdir (@directories) { # {{{
Riadok 148  foreach my $xdir (@directories) { # {{{
         my $file = "$xdir/$cache_file";          my $file = "$xdir/$cache_file";
         if (-f $file) {          if (-f $file) {
                 print "Trying to load cache file '$file' ... ";                  print "Trying to load cache file '$file' ... ";
                 my $code;                  my $hardlink_cache = $dump->xml2pl($file);
                 if (open(FILE, $file)) {                  if (defined $hardlink_cache and ref($hardlink_cache) eq 'HASH') {
                         while(<FILE>) {                          $cache->{$xdir} = $hardlink_cache;
                                 $code .= $_;                          print "OK\n"
                         }  
                         close(FILE);  
                         my $hardlink_cache = undef;  
                         eval $code;  
                         if ($@) {  
                                 print "failed: $@; ... removing\n";  
                                 unlink $file;  
                         }  
                         if (defined $hardlink_cache and ref($hardlink_cache) eq 'HASH') {  
                                 $cache->{$xdir} = $hardlink_cache;  
                                 print "OK\n"  
                         }  
                         else {  
                                 print "failed: bad structure; ... removing\n";  
                                 unlink $file;  
                         }  
                 }  
                 else {  
                         print STDERR "Can't open cache file '$file': $!";  
                 }                  }
         }          }
 } # }}}  } # }}}
Riadok 208  foreach my $xdir (@directories) { # {{{
Riadok 193  foreach my $xdir (@directories) { # {{{
         print "Saving cache file '$file' ... ";          print "Saving cache file '$file' ... ";
         if (open(FILE, ">$file")) {          if (open(FILE, ">$file")) {
                 #print Data::Dumper->Dump([$cache->{$xdir}], ['$hardlink_cache']);                  #print Data::Dumper->Dump([$cache->{$xdir}], ['$hardlink_cache']);
                 print FILE Data::Dumper->Dump([$cache->{$xdir}], ['$hardlink_cache']);                  # OLD INSECURE FORMAT OF CACHE
                   #print FILE Data::Dumper->Dump([$cache->{$xdir}], ['$hardlink_cache']);
                   # more safer new format:
                   print FILE $dump->pl2xml($cache->{$xdir});
                 close(FILE);                  close(FILE);
                 print "OK\n";                  print "OK\n";
         }          }

Legend:
Odstranené z verzie1.5  
zmenené riadky
  Pridané vo verzii1.6

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok