summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/util/copy.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/util/copy.pl')
-rw-r--r--src/lib/libcrypto/util/copy.pl70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/lib/libcrypto/util/copy.pl b/src/lib/libcrypto/util/copy.pl
new file mode 100644
index 0000000000..eba6d5815e
--- /dev/null
+++ b/src/lib/libcrypto/util/copy.pl
@@ -0,0 +1,70 @@
1#!/usr/local/bin/perl
2
3use Fcntl;
4
5
6# copy.pl
7
8# Perl script 'copy' comment. On Windows the built in "copy" command also
9# copies timestamps: this messes up Makefile dependencies.
10
11my $stripcr = 0;
12
13my $arg;
14
15foreach $arg (@ARGV) {
16 if ($arg eq "-stripcr")
17 {
18 $stripcr = 1;
19 next;
20 }
21 $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob...
22 foreach (glob $arg)
23 {
24 push @filelist, $_;
25 }
26}
27
28$fnum = @filelist;
29
30if ($fnum <= 1)
31 {
32 die "Need at least two filenames";
33 }
34
35$dest = pop @filelist;
36
37if ($fnum > 2 && ! -d $dest)
38 {
39 die "Destination must be a directory";
40 }
41
42foreach (@filelist)
43 {
44 if (-d $dest)
45 {
46 $dfile = $_;
47 $dfile =~ s|^.*[/\\]([^/\\]*)$|$1|;
48 $dfile = "$dest/$dfile";
49 }
50 else
51 {
52 $dfile = $dest;
53 }
54 sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_";
55 sysopen(OUT, $dfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY)
56 || die "Can't Open $dfile";
57 while (sysread IN, $buf, 10240)
58 {
59 if ($stripcr)
60 {
61 $buf =~ tr/\015//d;
62 }
63 syswrite(OUT, $buf, length($buf));
64 }
65 close(IN);
66 close(OUT);
67 print "Copying: $_ to $dfile\n";
68 }
69
70