Reinstate dropbear 0.54 update
[tomato.git] / release / src / router / openssl / util / copy.pl
blobe20b45530a8f5f645ec2717cff6cf8c1e4d0187f
1 #!/usr/local/bin/perl
3 use Fcntl;
6 # copy.pl
8 # Perl script 'copy' comment. On Windows the built in "copy" command also
9 # copies timestamps: this messes up Makefile dependencies.
11 my $arg;
13 foreach $arg (@ARGV) {
14 $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob...
15 foreach (glob $arg)
17 push @filelist, $_;
21 $fnum = @filelist;
23 if ($fnum <= 1)
25 die "Need at least two filenames";
28 $dest = pop @filelist;
30 if ($fnum > 2 && ! -d $dest)
32 die "Destination must be a directory";
35 foreach (@filelist)
37 if (-d $dest)
39 $dfile = $_;
40 $dfile =~ s|^.*[/\\]([^/\\]*)$|$1|;
41 $dfile = "$dest/$dfile";
43 else
45 $dfile = $dest;
47 sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_";
48 sysopen(OUT, $dfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY)
49 || die "Can't Open $dfile";
50 while (sysread IN, $buf, 10240)
52 syswrite(OUT, $buf, length($buf));
54 close(IN);
55 close(OUT);
56 print "Copying: $_ to $dfile\n";