Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Filtering based on file extension using Nav Services

3 views
Skip to first unread message

John C

unread,
Oct 10, 2000, 1:02:30 AM10/10/00
to
I would like to display only files with a ".DXF" extension in my file
dialog box. I have this working with the old StandardFile dialog using a
filterProc, but I cannot for the life of me find any documentation on
how to do this in Navigation Services. The closets I've found to a Nav
Services filterProc is below, but this filter just filters on file type:

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

Richard Drysdall

unread,
Oct 10, 2000, 3:00:00 AM10/10/00
to
In article <macjohn-00664C...@news.gte.net>, John C
<mac...@mail.com> wrote:

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.

Rowan Daniell

unread,
Oct 10, 2000, 11:51:10 PM10/10/00
to
in article macjohn-00664C...@news.gte.net, John C at
mac...@mail.com wrote on 10/10/00 6:02 PM:

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

0 new messages