• 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: Type/Creator codes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Type/Creator codes


  • Subject: Re: Type/Creator codes
  • From: Arno <email@hidden>
  • Date: Sat, 12 May 2001 17:09:52 -0700

> I can't seem to find any cocoa API for setting Type/Creator codes on
> files you create. Does anyone know of any?

Here it is. Enjoy.

OSStatus setTypeAndCreatorFromPath(FourCharCode, inType, FourCharCode,
inCreator, NSString* inPath)
{
OSStatus status = noErr;
FSRef fsRef;
if ((status = PosixPathToFSRef(inPath, &fsRef, YES)) == noErr) status = [[[HFSObject
alloc] initWithFSRef:&fsRef] autorelease];

if (status == noErr)
{
FSCatalogInfo catalogInfo;
status = FSGetCatalogInfo(& fsRef, kFSCatInfoFinderInfo,
&catalogInfo, NULL, NULL, NULL);

if (status == noErr)
{
FileInfo* info = (FileInfo*)&catalogInfo.finderInfo;
info->fileType = inType;
info->fileCreator = inCreator;

status = FSSetCatalogInfo(& fsRef, kFSCatInfoFinderInfo,
&catalogInfo);
}
return status;
}

Arno.


References: 
 >Type/Creator codes (From: Jamie Curmi <email@hidden>)

  • Prev by Date: Type/Creator codes
  • Next by Date: Re: Cocoa docs
  • Previous by thread: Type/Creator codes
  • Next by thread: Re: Type/Creator codes
  • Index(es):
    • Date
    • Thread