Re: creating a resource fork and writing raw bytes to it
Re: creating a resource fork and writing raw bytes to it
- Subject: Re: creating a resource fork and writing raw bytes to it
- From: Jens Alfke <email@hidden>
- Date: Wed, 21 May 2008 07:51:37 -0700
On 21 May '08, at 6:14 AM, Nick Rogers wrote:
My app has to create the resource fork of a file and then write raw
bytes picked up from the disk to it.
Hopefully you're copying the contents of another file's resource fork,
i.e. you're copying or unarchiving a file. A file's resource fork
shouldn't contain anything but bona fide Resource Manager data.
If you're copying a file, there are functions that will copy it for
you and transfer all the metadata, including resources and extended
attributes. (I don't remember their names, but they wouldn't be hard
to find by searching the docs.)
If you're expanding an archive, or transferring a file over the
network, then you do have a valid case for writing to the resource
fork and I'll stop lecturing you :)
Is there any support in cocoa for this.
No. In general Cocoa does not provide its own APIs for every function
available in the system. And resource forks are a legacy feature
nowadays.
For writing to the data fork I'm creating the file with
NSFileManager and then writing using write().
Look at <Files.h> in CarbonCore — it has a function for opening the
resource fork (it used to be FSOpenFork, but there may be a newer
equivalent). Then you use FSWrite to write to it.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden