Re: Type/Creator codes
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.