2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 print STDERR
"recursive copy called with $fromdir, $todir\n";
14 #remove any trailing slashes.
18 opendir(DIR
, $fromdir);
19 @dirlist = readdir DIR
;
23 foreach $file (@dirlist) {
24 if (! (($file eq "." ) || ($file eq "..") )) {
26 if (-d
"$fromdir/$file") {
27 print STDERR
"handling directory $todir/$file\n";
28 &rec_mkdir
("$todir/$file");
29 &recursive_copy
("$fromdir/$file","$todir/$file");
32 print STDERR
"handling file $fromdir/$file\n";
33 &my_copy
("$fromdir/$file","$todir/$file");
41 # print STDERR "Parsing Variables\n";
43 foreach $q ( @ARGV ) {
45 $var{$lastassigned} .= " $q";
48 $q =~ /^([^=]*)=(.*)/;
55 $lastassigned = $left;
58 print STDERR
"Assigned $lastassigned = $var{$lastassigned}\n";
63 # usage: &my_copy("dir/fromfile","dir2/tofile");
64 # do a 'copy' - files only, 'to' MUST be a filename, not a directory.
66 # fix this to be able to use copy on win nt.
76 if ( ! defined $var{OS_ARCH
}) {
77 die "OS_ARCH not defined!";
80 if ($var{OS_ARCH
} eq 'WINNT') {
86 print STDERR
"COPYING: $cpcmd $from $to\n";
87 system("$cpcmd $from $to");
98 open(FIN
, "<$from") || die("Can't read from file $from\n");
99 if ( ! open(FOUT
,">$to")) {
101 die "Can't write to file $to\n";
103 while (read(FIN
, $buf, 100000)) {
117 foreach $q (split(/\//,$arg)) {
119 if (! ($t =~ /\.\.$/)) {