[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 01:18:32 -0400
Michael Evans asked:

>This code is from Alain...
>I need the mirror of this, GetTypeAndCreator, as so far my attempts 
>have failed


Here are a couple of Carbon functions I brewed up for you. Just pass 
them an FSSpec and you're on the way. Remember that in OS X, some 
files may be lacking this legacy info.

You can also do this with FB's Open Unix. If I remember, I'll roll 
another example with that technique.


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


Carbon functions to find file type and creator

    By Ken Shmidheiser
    Somerset, KY

    June 12, 2004


local fn GetFileType$( fs as .FSSpec )
dim as str15 type
dim as FInfo info

long if fn FSpGetFInfo( #fs, info ) == _noErr
type = mki$( info.fdType )
end if

end fn = type

local fn GetFileCreator$( fs as .FSSpec )
dim as str15 creator
dim as FInfo info

long if fn FSpGetFInfo( #fs, info ) == _noErr
creator = mki$( info.fdCreator )
end if

end fn = creator

window 1

dim as FSSpec fs
dim as str255 fileName

Print "Select file to find type and creator..."

fileName = files$( _FSSpecOpen,,,fs )
long if fileName[0] != 0
print "File name: "; fileName
print "Type: "     ; fn GetFileType$( fs )
print "Creator: "  ; fn GetFileCreator$( fs )
end if

include "Subs Quick Event Loop.Incl"