• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSFileManager and Resource Forks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFileManager and Resource Forks


  • Subject: Re: NSFileManager and Resource Forks
  • From: Steve Christensen <email@hidden>
  • Date: Tue, 26 Oct 2010 21:10:48 -0700

On Oct 26, 2010, at 7:26 PM, email@hidden wrote:

> Is there a way to write a resource fork for a file at a path?

I don't believe that NSFileManager knows about resource files, either in the resource or data fork.

You can use Resource Manager routines FSCreateResourceFile() or FSCreateResourceFork() to create a brand-new resource file or add a resource fork to an existing file, respectively.

FSRef fileRef;

if (CFURLGetFSRef((CFURLRef)[NSURL fileURLWithPath:resourceFilePath], &fileRef))
{
	HFSUniStr255 resourceForkName;

	FSGetResourceForkName(&resourceForkName);

	if (FSCreateResourceFork(&fileRef, resourceForkName.length, resourceForkName.unicode, 0) == noErr)
	{
		ResFileRefNum refNum;

		if (FSOpenResourceFile(fileRef, resourceForkName.length, resourceForkName.unicode, fsRdWrPerm, &refNum) == noErr)
		{
			// write resources here...

			CloseResFile(refNum);

			return YES;
		}
	}
}

return NO;


Note that the above is creating a resource file in the [classic] resource fork, but unless your files contain existing non-resource data in the data fork, it might be better to create a data fork-based resource file and write resources there.

_______________________________________________

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

References: 
 >NSFileManager and Resource Forks (From: email@hidden)

  • Prev by Date: NSFileManager and Resource Forks
  • Next by Date: Programmatically adjusting NSValueTransformer of a bound NSTextField
  • Previous by thread: NSFileManager and Resource Forks
  • Next by thread: Re: NSFileManager and Resource Forks
  • Index(es):
    • Date
    • Thread