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

Comparing COMP/SCRAM/src/Utilities/AddDir.pm (file contents):
Revision 1.1 by williamc, Mon Mar 1 10:35:01 1999 UTC vs.
Revision 1.7 by sashby, Fri Dec 10 13:41:43 2004 UTC

# Line 1 | Line 1
1 #!/usr/local/bin/perl5
2 #
3
1   package AddDir;
2 + require 5.001;
3   require Exporter;
4   use Cwd;
5   @ISA    = qw(Exporter);
6 < @EXPORT = qw(adddir);
6 > @EXPORT = qw(adddir copydir);
7 >
8  
9 < sub adddir ($directory) {
9 > sub adddir {
10   my $indir=shift;
11   my $startdir=cwd;
12   my @dir=split /\//,  $indir;
# Line 28 | Line 27 | sub adddir ($directory) {
27   }
28   chdir $startdir;
29   }
30 +
31 + sub copydir
32 +   {
33 +   my $src=shift;
34 +   my $dest=shift;
35 +  
36 +   use DirHandle;
37 +   use File::Copy;
38 +  
39 +   adddir($dest);
40 +   my $dh=DirHandle->new($src);
41 +  
42 +   if (defined $dh)
43 +      {
44 +      my @allfiles=$dh->read();
45 +  
46 +      my $file;
47 +      foreach $file ( @allfiles )
48 +         {
49 +         next if $file=~/^\.\.?/;
50 +         if ( -d $src."/".$file )
51 +            {
52 +            copydir($src."/".$file,$dest."/".$file);
53 +            }
54 +         else
55 +            {
56 +            copy($src."/".$file,$dest."/".$file);
57 +            if ( -x $src."/".$file || -X $src."/".$file ) {chmod(0775,$dest."/".$file);}
58 +            }
59 +         }
60 +      undef $dh;
61 +      }
62 +   else
63 +      {
64 +      die "Attempt to open a non-existent directory ($src). Exitting\n";
65 +      }
66 +   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines