Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Failed to copy Resource Fork??



On Jul 30, 2005, at 14:48:30, darpan kamboj wrote:
FILE *fp;
fp = fopen(Audio 1_01,"wb+");

fwrite(DataBuff,SizeToSave,1,fp);

You really should be using Cocoa methods for writing your file. In particular, use NSDocument, if it makes sense for your app. NSDocument has a method to return an attributes dictionary that lets you specify values for file type and creator. Search the list archives for lots of sample code to even do that automatically based on your Info.plist entries (I think I even posted my UKDocument class's code once). You don't need a resource fork at all. You only need to set the file's HFS attributes, which are actually separate from that.


If you badly *need* to use fwrite() (which only accesses the data fork), you'll have to use the File Manager (documented as part of Carbon) to set the additional attributes. Make sure you use FSRefs to refer to the file (you can create an FSRef from a path) and not the old FSSpecs, though.

If all you're doing is copying files, you don't need all that. Just use NSWorkspace or NSFileManager, both of which offer ways to copy a file. Though they will only correctly copy along the resource fork of a file on newer MacOS releases, IIRC. Check out the documentation at developer.apple.com to be sure they're available for the system version you're deploying to.

Cheers,
-- M. Uli Kusterer
http://www.zathras.de


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Re: Failed to copy Resource Fork?? (From: "darpan kamboj" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.