3
# $Id: apple_cp.in,v 1.1 2002/01/17 05:59:25 srittau Exp $
6
Usage: $0 filename1 filename2
7
$0 filename ... directory
8
Do an apple copy, copying the resource fork as well
11
die $USAGE if @ARGV < 2;
13
@from = @ARGV; pop(@from);
16
if (-f $to && @from > 1) { die $USAGE; }
18
foreach $from (@from) {
20
print STDERR "file $from does not exist\n";
24
if (!-d $to && @from >1) {
25
print STDERR "directory $to does not exist\nCan't copy multiple files into one file.\n";
29
$cmd = "cp '$from' '$to'";
30
system $cmd || die "error executing $cmd";
32
($from_dir, $from_file) = split_dir_file($from);
35
if (!-d "$to/.AppleDouble") {
36
mkdir("$to/.AppleDouble", 0777);
38
$cmd = "cp '$from_dir/.AppleDouble/$from_file' '$to/.AppleDouble/$from_file'";
40
($to_dir, $to_file) = split_dir_file($to);
41
if (!-d "$to_dir/.AppleDouble") {
42
mkdir("$to_dir/.AppleDouble", 0777);
44
$cmd = "cp '$from_dir/.AppleDouble/$from_file' '$to_dir/.AppleDouble/$to_file'";
47
system $cmd || die "error executing $cmd";
50
# split a file path into a directory and file name.
54
@path_elems = split(/\//, $path);
56
my $file = pop(@path_elems);
61
$dir = join('/', @path_elems);