pascal Boolean myFilterProc(AEDesc* theItem, void* info,
NavCallBackUserData callBackUD,
NavFilterModes filterMode)
{
OSErr theErr = noErr;
Boolean display = true;
NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*)info;
if (theItem->descriptorType == typeFSS)
if (!theInfo->isFolder)
if (theInfo->fileAndFolder.fileInfo.finderInfo.fdType
!= 'TEXT')
display = false;
return display;
}
Anyone have any ideas on how to filter based on file extension (or, for
that matter, on filename)?
Thanks,
John C
I haven't compiled this example, but I've modified your code based on an
application of mine which does filtering based on extensions. Basically,
the only trick is knowing how to get the FSSpec for the file:
> pascal Boolean myFilterProc(AEDesc* theItem, void* info,
> NavCallBackUserData callBackUD,
> NavFilterModes filterMode)
> {
> OSErr theErr = noErr;
Boolean display = false;
> NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*)info;
FSSpec theFSSpec;
>
> if (theItem->descriptorType == typeFSS)
> if (!theInfo->isFolder)
if (theInfo->fileAndFolder.fileInfo.finderInfo.fdType ==
'TEXT')
{
BlockMoveData (*theItem -> dataHandle, &theFSSpec,
sizeof (theFSSpec));
// if theFSSpec.name ok, set display = true
}
> return display;
> }
--
Richard Drysdall, Auckland, New Zealand.
You are almost there: Use
FSSpec finalFSSpec;
#if OPAQUE_TOOLBOX_STRUCTS // carbon
AEGetDescData(theItem, &finalFSSpec, sizeof(FSSpec));
#else // pre carbon
BlockMoveData(*theItem->dataHandle, &finalFSSpec, sizeof(FSSpec));
#endif
to get the actual FSSpec record for the file. Then you have the filename in
finalFSSpec.name. Parse the file name to see if it ends in .DXF.
Remember to return false for the files you *do* want to show. True filters
them out. (opposite of Standard File)
--
Rowan Daniell tel:+64-9-486-0282
Cognito Software Ltd fax:+64-9-489-6010
http://www.cognito.co.nz