Subject: | bug: MacOSX::File::Copy->copy() fails from a mounted disk image |
Date: | Mon, 3 May 2010 14:54:09 +0100 |
To: | bug-MacOSX-File [...] rt.cpan.org |
From: | Mike Elston <mike [...] caisys.co.uk> |
I wanted to use MacOSX::File to copy files from a backup produced by
Apple's Backup application (on Mac OS X 10.4 Tiger). This application
creates sparse disk images which may be mounted by 'hdiutil attach',
and the mounted volume contains the files backed up.
However, trying to copy a file using MacOSX::File::Copy from this
mounted image to a hard disk fails, reporting 'No such file or
directory'. Essentially, my Perl program is as follows:
use MacOSX::File::Copy;
@attach = ('hdiutil', 'attach', '-quiet', '-readonly', '-private');
...
$imagefile = $backup . "/Contents/Contents/Backup.sparseimage";
system(@attach, $imagefile) == 0 or
die "failed to mount backup image\n";
...
# (in a loop)
copy($pathfrom, $pathto) or warn "$pathfrom: restore failed: $!\n";
This fails on every file in the backup disk image. However, simply
replacing "MacOSX::File::Copy" with "File::Copy" works successfully
(except of course where the MacOSX features are concerned, eg
resource fork etc).
Assuming this was caused by the fact that MacOSX::File uses the
Carbon File Manager, while hdiutil attaches the disk image with a BSD
backing store, I removed the '-private' option from the 'hdiutil
attach' command. This had the effect that most files (but not all)
were now copied successfully, although on most files (but not all)
the copy() command still reported the same error, 'No such file or
directory'.
I assume this indicates a problem using the Carbon File Manager on
disk images mounted by hdiutil. Is there another solution?
Regards
/mike
--
Mike Elston | CaiSys _|>
consultant | MacOS, NeXT, Unix, CAI
Email: mike@caisys.co.uk