[futurebasic] Re: GetTypeAndCreator

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2004 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sat, 12 Jun 2004 02:07:34 -0400
After posting the earlier code, I noticed Brian's 
post and revisited his code. In it, he wisely 
used FSpGetFInfo to update the file info record 
prior to making the modifications. I have 
included that step in this revision. Thanks, 
Brian!

Ken

p.s. Watch for e-mail line breaks and lost constant underscores

/*

Carbon function to set file type and creator

    By Ken Shmidheiser
    Somerset, KY

    June 12, 2004

     Revised courtesy Brian Stevens

*/

local fn SetTypeAndCreator( fs as .FSSpec,¬
                         type as OSType,¬
                      creator as OSType )
'~'1
dim as OSErr   err
dim as FInfo @ info

err = fn FSpGetFInfo (#fs, info )
long if( err == _noErr )
info.fdType    = type
info.fdCreator = creator
err = fn FSpSetFInfo ( #fs, info )
end if

end fn = err

dim as FSSpec fs
dim as OSErr  err

// Set a text file to BBEdit
long if len( files$( _FSSpecOpen, "", "", fs ) )
err = fn SetTypeAndCreator( fs, _"TEXT", _"R*ch" )
long if( err == _noErr )
PRINT "File type and creator set"
xelse
print "Error No. "; err; " occurred"
end if
xelse
print "User canceled"
end if

include "Subs Quick Event Loop.Incl"