[futurebasic] Re: [FB] How to get the FSSpec of an application

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2011 : Group Archive : Group : All Groups

From: Brian S <fblistserve@...>
Date: Wed, 5 Jan 2011 21:59:30 -0700
On Jan 5, 2011, at 7:28 PM, Brian S wrote:

> ( and generally using the name field of an FSSpec is risky )


Robert gave you an FSSpec example but you would be wise to use FSRefs. Here is Robert’s example modified slightly( and quickly so go carefully through the code ) to use an FSRef and shows another UTI.

'--------------
include "Tlbx UTCoreTypes.incl"

local fn MyNavFilter( theItem as ^AEDesc, info as ^NavFileOrFolderInfo, callbackUD as pointer, filterMode as NavFilterModes ) as Boolean
'~'1
dim as Boolean   display : display = _false

if ( info.isFolder ) then display = _true : exit fn // always allow going into folders
if ( fn NavDialog_UTIConformsTo( #theItem, kUTTypePDF ) ) then display = _true
end fn = display


local fn MyGetFileHandler( reply as ^NavReplyRecord, userData as pointer )
'~'1
dim as FSRef   myRef

NavDialog_GetItemFSRef( #reply, 1, @myRef )
BlockMoveData( @myRef, userData, sizeof( FSRef ) )
end fn

dim as FSRef      ref
dim as Str255     name

window 1
NavDialog_SetFilterFn( @fn MyNavFilter )
fn NavDialog( _kNavDialogGetFile + _kNavDialogSupportPackages, "Choose an application", "", @fn MyGetFileHandler,  @ref )
GetNameAsPascalStringFromFSRef( @ref, @name )
print name

HandleEvents
'--------------



Brian S