10 # Copy to the destination if the source is not the same as it.
16 foreach my $arg (@ARGV) {
17 $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob...
28 die "Need at least two filenames";
31 my $dest = pop @filelist;
33 if ($fnum > 2 && ! -d $dest)
35 die "Destination must be a directory";
44 $dfile =~ s|^.*[/\\]([^/\\]*)$|$1|;
45 $dfile = "$dest/$dfile";
55 sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_";
56 sysopen(OUT, $dfile, O_RDONLY|O_BINARY)
57 || die "Can't Open $dfile";
58 while (sysread IN, $buf, 10240)
61 goto copy if !sysread(OUT, $b2, 10240) || $buf ne $b2;
63 goto copy if sysread(OUT, $buf, 1);
66 print "NOT copying: $_ to $dfile\n";
70 sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_";
71 sysopen(OUT, $dfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY)
72 || die "Can't Open $dfile";
73 while (sysread IN, $buf, 10240)
75 syswrite(OUT, $buf, length($buf));
79 print "Copying: $_ to $dfile\n";