MacOSX-File
view release on metacpan or search on metacpan
Copy/Copy.pm view on Meta::CPAN
# before unlinking $dst, we check if $src and $dst are identical
$srcino == $dstino and $srcdev == $dstdev
and carp "$src and $dst are identical";
unlink $dst or return;
}
if (my $err = xs_copy($src, $dst, $mbs, $preserve)){
return;
}else{
if ($preserve){
# These are included in FSCatalogInfo
# chown $srcuid, $srcgid, $src;
# chmod ($srcmode & 07777), $src;
# utime $srcatime, $srcmtime, $src;
}
return 1;
}
}
sub attic($){
my $path = shift;
return dirname($path) . '/._' . basename($path);
if (my $link = $Hardlink{$srcst->ino}){
link($link, $dst) or warn "$link -> $dst:$!";
}else{
$Hardlink{$srcst->ino} = $dst;
}
}
copy($src, $dst) # simple file-to-file copy
or warn "$dst:$! ($MacOSX::File::OSErr)";
# set attributes
if ($Opt{p}){
chown $srcst->uid, $srcst->gid, $dst;
chmod $srcst->mode & 07777, $dst or warn "$dst : $!";
}else{
my $now = time();
utime $now, $now, $dst or warn "$dst: $!";
}
}elsif(-d _){ # tough part;
unless ($Opt{r}){
warn "$IAM: $src is a directory. skipped";
return;
}
# so you can casually go like 'pcpmac -R / /Volumes/backup'
lstat($srcf)->dev != $srcst->dev and next;
-e $dstf and die "$dstf: already exists!";
# else lets' do it recursively
do_copy($srcf, $dstf);
}
# copy finfo info after all traversal is done
$finfo->set($dst) or warn "$dst : $MacOSX::File::OSErr";
# set attributes
if ($Opt{p}){
chown $srcst->uid, $srcst->gid, $dst;
chmod $srcst->mode & 07777, $dst or warn "$dst : $!";
}else{
# do nothing
}
}else{
# do nothing for devices, sockets and fifos;
# devices are handled by devfs on Macs
}
}
}
untie %db;
move $Psync_DB, "$Dst/$Psync_DB" or die "Can't move $Psync_DB";
}
sub copyattrib{
my ($spath, $dpath, $mode, $uid, $gid, $atime, $mtime) = @_;
my $finfo = getfinfo($spath);
unless ($opt_r > 1){
chmod $mode & 07777, $dpath;
chown $uid, $gid, $dpath;
}
$finfo and $finfo->set($dpath);
utime $atime, $mtime, $dpath;
}
exit;
sub do_log{
print shift, "\n";
}
( run in 0.972 second using v1.01-cache-2.11-cpan-71847e10f99 )