9 # Copy to the destination if the source is not the same as it.
13 foreach my $arg (@ARGV) {
14 $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob...
25 die "Need at least two filenames";
28 my $dest = pop @filelist;
30 if ($fnum > 2 && ! -d $dest)
32 die "Destination must be a directory";
41 $dfile =~ s|^.*[/\\]([^/\\]*)$|$1|;
42 $dfile = "$dest/$dfile";
52 sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_";
53 sysopen(OUT, $dfile, O_RDONLY|O_BINARY)
54 || die "Can't Open $dfile";
55 while (sysread IN, $buf, 10240)
58 goto copy if !sysread(OUT, $b2, 10240) || $buf ne $b2;
60 goto copy if sysread(OUT, $buf, 1);
63 print "NOT copying: $_ to $dfile\n";
67 sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_";
68 sysopen(OUT, $dfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY)
69 || die "Can't Open $dfile";
70 while (sysread IN, $buf, 10240)
72 syswrite(OUT, $buf, length($buf));
76 print "Copying: $_ to $dfile\n";