[futurebasic] Re: [FB] [FB^3] Full Path Names Code

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2001 : Group Archive : Group : All Groups

From: Ken Shmidheiser <k.shmidheiser@...>
Date: Mon, 5 Feb 2001 10:19:54 -0500
Alain recommeded the following patch to fix Heather's Full Path Names Code:

>I think I've found the problem.
>In the Header file Tlbx Navigation.Incl the FXInfo record is not correctly
>defined.
>The field:
>dim fdReserved(3) as SInt16 /* Reserved (set to 0) */
>should have been
>dim fdReserved[2] as SInt16 /* Reserved (set to 0) */


In addition to Alain's necessary patch to:

MacintoshHD:FB^3:FB Extensions:Compiler:Headers:Tlbx Navigation.Incl

as referenced above, I've shuffled around some dimensioned variables 
in Heather's code to get rid of an uneven rounding problem, and added 
a few functions to make it a stand-alone app to fetch multiple paths. 
My first use was to copy the above-referenced file path to the 
clipboard and then paste it into this message!

Ken

p.s. Joe, this might be one for "The Book"

Please watch for e-mail line breaks:

'------- begin code

'~Record Statements

Begin Record CInfoPBRec
DIM qLink AS PTR//queue link in header
DIM qType AS short//type byte for safety check
DIM ioTrap AS short//FS: the Trap
DIM ioCmdAddr AS Ptr//FS: address to dispatch to
DIM ioCompletion AS PROC//completion routine addr (0 for synch calls)
DIM ioResult AS WORD//result code
DIM ioNamePtr AS PTR//ptr to Vol:FileName string
DIM ioVRefNum AS short//volume refnum (DrvNum for Eject and MountVol)
DIM ioFRefNum AS short
DIM ioFVersNum AS SInt8
DIM filler1 AS SInt8
DIM ioFDirIndex AS short
DIM ioFlAttrib AS SInt8
DIM ioACUser AS SInt8
Begin Union
DIM ioFlFndrInfo AS FInfo
DIM ioDrUsrWds AS DInfo
End Union
Begin Union
DIM ioDirID AS long
DIM ioDrDirID AS long
End Union
Begin Union
DIM ioFlStBlk AS unsigned short
DIM ioDrNmFls AS unsigned short
End Union
DIM ioFlLgLen AS long
DIM ioFlPyLen AS long
DIM ioFlRStBlk AS unsigned short
DIM ioFlRLgLen AS long
DIM ioFlRPyLen AS long
Begin Union
DIM ioFlCrDat AS unsigned long
DIM ioDrCrDat AS unsigned long
End Union
Begin Union
DIM ioFlMdDat AS unsigned long
DIM ioDrMdDat AS unsigned long
End Union
Begin Union
DIM ioFlBkDat AS unsigned long
DIM ioDrBkDat AS unsigned long
End Union
Begin Union
DIM ioFlXFndrInfo AS FXInfo
DIM ioDrFndrInfo AS DXInfo
End Union
Begin Union
DIM ioFlParID AS long
DIM ioDrParID AS long
End Union
DIM ioFlClpSiz AS long
End Record
#DEFINE CInfoPBPtr AS POINTER TO CInfoPBRec

'~Constructing the full pathname of a file

DIM AS STR255 fileName, filePath
DIM refNumVar AS SHORT
DIM gUNIXStyle AS BOOLEAN: gUNIXStyle = _false

gFBUseNavServices = fn FBTestForLibrary( "NavigationLib" )

CLEAR LOCAL
DIM myPB AS CInfoPBRec// {parameter block for PBGetCatInfo}
DIM dirName AS STR255// {a directory name}
DIM fullPath AS STR255// {full pathname being constructed}
DIM myErr AS OSErr
LOCAL FN GetFullPath$ ( DirID AS LONG, vRefnum AS SHORT )

// {initialize myPB}
myPB.ioNamePtr = @dirName
myPB.ioVRefNum = vRefNum// {indicate target volume}
myPB.ioDrParID = DirID// {initialize parent directory ID}
myPB.ioFDirIndex = -1// {get info about a directory}

//{Get name of each parent directory, up to root directory.}
DO
myPB.ioDrDirID = myPB.ioDrParID
myErr = FN PBGetCatInfosync( @myPB )

LONG IF gUNIXStyle = _true
dirName = dirName + "/"
XELSE
dirName = dirName + ":"
END IF

fullPath = dirName + fullPath
UNTIL myPB.ioDrDirID = _fsRtDirID

END FN = fullPath

LOCAL FN buildMenus
MENU 1,0,_enable,"File"
MENU 1,1,_disable,"-"
MENU 1,2,_enable,"Quit/Q"
EDIT MENU 2
END FN

LOCAL FN buildWindow
fileName = FILES$( _fOpen,"",,refNumVar )
filePath = FN GetFullPath$ ( 0, refNumVar )
WINDOW -1,"File Path Demo",(0,0)-(300,190),_docNoGrow
EDIT = 4
EDIT FIELD 1,"",(20,20)-(280,140),_framed,_centerJust
EDIT$(1) = CHR$(13)+" The path for "+fileName+" 
is:"+CHR$(13)+CHR$(13)+filePath+fileName
LONG COLOR 56797,56797,56797,_false
BUTTON 1,_activeBtn,"Quit",(230,159)-(280,180),_shadow
BUTTON 2,_activeBtn,"Find another",(110,159)-(220,180),_push
EDIT FIELD 0
WINDOW 1
END FN

LOCAL
DIM AS INTEGER evnt,id
LOCAL FN doDialog
evnt = DIALOG(0)
id = DIALOG(evnt)
SELECT CASE evnt
CASE _wndClose
SELECT id
CASE 1
END
END SELECT
CASE _btnClick
SELECT id
CASE 1
END
CASE 2
WINDOW CLOSE 1
FN buildWindow
END SELECT
END SELECt
END FN

LOCAL
DIM AS INTEGER menuID,itemID
LOCAL FN doMenu
menuID = MENU(_menuID)
itemID = MENU(_itemID)
SELECT CASE menuID
CASE 1
SELECT itemID
CASE 1
END
END SELECT
END SELECT
MENU
END FN

ON DIALOG FN doDialog
ON MENU FN doMenu

FN buildMenus
FN buildWindow

DO
HANDLEEVENTS
UNTIL 0
END

'------- end code