3 # $Header: /home/ralph/netatalk/rsync/netatalk/contrib/shell_utils/Attic/apple_cp,v 1.3 2001-10-16 18:27:27 lancel Exp $
6 # Revision 1.3 2001-10-16 18:27:27 lancel
9 # Fixed a failing test where $to wasn't a directory, but
10 # didn't check that $from was only a single file, result file to file
13 # Fixed the .AppleDouble variable being sent to the split_dir_file
14 # function, it was mistakenly sending $from instead of $to, result cp
15 # $from $from, same file.
17 # Revision 1.2 2000/08/09 14:12:06 rufustfirefly
18 # /usr/local/bin/perl -> /usr/bin/perl and portability fixes
20 # Revision 1.1 2000/08/09 14:08:06 rufustfirefly
21 # Shell utils from http://www.-genome.wi.mit.edu/ftp/distribution/software/Bass/bass-1.29/apple_util/ (initial import)
23 # Revision 1.1 1996/04/03 02:13:12 lstein
24 # Added all these files because they're essential utilities.
26 # Revision 1.2 1996/02/09 18:44:44 will
29 # Revision 1.1 1996/02/09 18:21:35 will
35 Usage: $0 filename1 filename2
36 $0 filename ... directory
37 Do an apple copy, copying the resource fork as well
40 die $USAGE if @ARGV < 2;
42 @from = @ARGV; pop(@from);
45 if (-f $to && @from > 1) { die $USAGE; }
47 foreach $from (@from) {
49 print STDERR "file $from does not exist\n";
53 if (!-d $to && @from >1) {
54 print STDERR "directory $to does not exist\nCan't copy multiple files into one file.\n";
58 $cmd = "cp '$from' '$to'";
59 system $cmd || die "error executing $cmd";
61 ($from_dir, $from_file) = split_dir_file($from);
64 if (!-d "$to/.AppleDouble") {
65 mkdir("$to/.AppleDouble", 0777);
67 $cmd = "cp '$from_dir/.AppleDouble/$from_file' '$to/.AppleDouble/$from_file'";
69 ($to_dir, $to_file) = split_dir_file($to);
70 if (!-d "$to_dir/.AppleDouble") {
71 mkdir("$to_dir/.AppleDouble", 0777);
73 $cmd = "cp '$from_dir/.AppleDouble/$from_file' '$to_dir/.AppleDouble/$to_file'";
76 system $cmd || die "error executing $cmd";
79 # split a file path into a directory and file name.
83 @path_elems = split(/\//, $path);
85 my $file = pop(@path_elems);
90 $dir = join('/', @path_elems);