[futurebasic] Re: [FB] Locate Files under OSX

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2002 : Group Archive : Group : All Groups

From: Alain Pastor <pixmix@...>
Date: Sat, 05 Oct 2002 01:05:34 +0200

Edwards, Waverly wrote:
> I tried a few pieces of code that were supposed
> to get the ioVRefNum% of all the mounted volumes
> so that I could search across all volumes but
> the file/app was never found.
> 
> The code that I posted was a simplified fragment 
> I extracted from one of my programs which does 
> not work on OSX but does work in classic.
> 
> No error generated but the file is not located.
> 
> 

I must be tired but I'm still confused about the issue.
Below is the code you've posted slightly modified to search all the 
mounted volumes until a match is found.
At my side, it works in plain vanilla Mac OS 9.2.2 under Carbon.
I'm not running OS X, so perhaps you could test and report back.

_FactSrvrType    = _"APPL" // File type code
_FactSrvrCreator = _"CCPr" //Creator code

'~'2
// buffer for CatSearch code in fn CCLocateFile.
_FactBuffSz     = 2048 // seems plenty (was 32768)
dim gFactCatSrchBuffer.FactBuffSz// see IM File Manager PBCatsearchSync

end globals



clear local
local fn CCLocateFile( type as OSType, creator as OSType, theFSSpec as 
ptr )
// Find 1 occurrence of file of specified type & creator.
// If found, return _noErr, with the file's FSSpec filled in; else 
return error code
// Modified version of Ross W. Lambert's "PBCatSearch Demo"
// Copyright © 1995 Ariel Publishing, Inc.  All Right Reserved
dim catSrchPB.76// see IM File Manager PBCatsearchSync
dim spec1.108// see IM File Manager PBCatsearchSync
dim spec2.108// see IM File Manager PBCatsearchSync
dim err as OSErr
Dim cInfoPBRec.128
dim volName as str63

cInfoPBRec.ioNamePtr&  = @volName

do


err = Fn PBHGetVInfoSync ( cInfoPBRec )

long if ( err == _noErr )
catSrchPB.ioVRefNum%       = cInfoPBRec.ioVRefNum%
catSrchPB.ioMatchPtr&      = theFSSpec // put result here
catSrchPB.ioSearchTime&    = 0 // no time limit
catSrchPB.ioReqMatchCount& = 1 // find 1 instance of the file
catSrchPB.ioSearchBits&    = _fsSBFlFndrInfo%
catSrchPB.ioSearchInfo1&   = @spec1
catSrchPB.ioSearchInfo2&   = @spec2
spec1.ioBuffer.fdType&     = type
spec1.ioBuffer.fdCreator&  = creator
spec2.ioBuffer.fdType&     = -1 // all bits significant
spec2.ioBuffer.fdCreator&  = -1 // all bits significant
catSrchPB.ioOptBuffer&     = @gFactCatSrchBuffer
catSrchPB.ioOptBufSize&    = _FactBuffSz
err = fn PBCatSearchSync( catSrchPB )
if err != _noErr or catSrchPB.ioActMatchCount& != 0 then exit fn
inc( cInfoPBRec.ioVolIndex% )
end if
until _nil
end fn = err


local fn CClaunchServer
dim srvrPSN    as ProcessSerialNumber
dim srvrFSSpec as FSSpec

long if fn CCLocateFile( _FactSrvrType, _FactSrvrCreator, srvrFSSpec )
shutdown "Could not locate server application"
xelse
print srvrFSSpec.name
run srvrFSSpec.name,srvrFSSpec.vRefnum,srvrFSSpec.parID
end if

end fn

window 1

fn CClaunchServer

Do
handleevents
until 0


-- 
Cheers,

A. Pastor