[futurebasic] Is a disk locked

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

From: Pete Beaumont <furbies@...>
Date: Mon, 25 Nov 2002 05:24:19 +1100
(FB^3 Release 6)

I'm trying to get get some code that David Blache posted ages 
ago to work...

His code:

'-----------------------------------------
'ShowLockedVolumes
'-----------------------------------------
CLEAR LOCAL
_hardLockFlag = &x0000000010000000
_softLockFlag = &x1000000000000000
DIM pBlock.128
DIM 63 volName$
DIM err
LOCAL FN ShowLockedVolumes
pBlock.ioNamePtr& = @volName$                     'pointer to 
volume name
DO
INC WORD (@pBlock.ioVolIndex%)                    'look for next mounted
volume
err = FN HGETVINFO (@pBlock)                      'get original volume
info
LONG IF err = _noErr                              'no error?
'show volume number and name
PRINT "Volume:";pBlock.ioVolIndex%;" '";volName$"' ";
PRINT STRING$(20-LEN(volName$),32);"  ";

'test attributes for software lock and hardware lock
IF (pBlock.ioVAtrb% AND _hardLockFlag) THEN PRINT "*hard locked* ";
IF (pBlock.ioVAtrb% AND _softLockFlag) THEN PRINT "*soft locked*";
PRINT

'show educational info :)
DEFSTR LONG
PRINT "Soft Lock Flag: "; BIN$(_softLockFlag);    " = ";_softLockFlag
PRINT "Hard Lock Flag: "; BIN$(_hardLockFlag);    " = ";_hardLockFlag
PRINT "Vol Attributes: "; BIN$(pBlock.ioVAtrb%);  " = ";pBlock.ioVAtrb%
PRINT
END IF
UNTIL err                                         'until no more volumes
END FN = err


I rewrote it as:


begin enum
_hardLockFlag = 128//&x0000000010000000
_softLockFlag = 32768//&x1000000000000000
end enum


clear local
local FN checkVolOrDiskNotLocked(vRefNum as int, showLockedMsg 
as int, dieMsg as str255)

DIM pbBlk    as HVolumeParam
DIM volName  as str255
DIM osErr    as int
dim locked   as int
DIM alertMsg as str255

pbBlk.ioCompletion = 0/* no iocompletion */
pbBlk.ioNamePtr    = @volName/* pointer to volume name */
pbBlk.ioVRefNum    = vRefNum/* vol ref num */
pbBlk.ioVolIndex   = 0/* check this vol by the ioVRefNum% */

osErr = FN pbhGETVINFOSync(@pbBlk)/* get volume info */
LONG IF osErr = _noErr/* no error? */

/* test attributes for software lock and hardware lock */
IF (pbBlk.ioVAtrb AND _hardLockFlag) THEN locked = _true
IF (pbBlk.ioVAtrb AND _softLockFlag) THEN locked = _true

LONG IF locked and showLockedMsg
alertMsg = STR#(3999, _noAccessLockedVolERR)
FN doMyAlert(_noAccessLockedVolERR, alertMsg, volName, dieMsg)
IF LEN(dieMsg) THEN END
END IF

xelse
fn showFileError(osErr, "PBHGetVInfoSync in checkVolOrDiskNotLocked")
END IF

end fn = locked

I have HVolumeParam defined as:

BEGIN RECORD HVolumeParam
DIM qLink AS QElemPtr
DIM qType AS short
DIM ioTrap AS short
DIM ioCmdAddr AS Ptr
DIM ioCompletion AS IOCompletionUPP
DIM ioResult AS OSErr
DIM ioNamePtr AS ptr//StringPtr
DIM ioVRefNum AS short
DIM filler2 AS long
DIM ioVolIndex AS short
DIM ioVCrDate AS unsigned long
DIM ioVLsMod AS unsigned long
DIM ioVAtrb AS short
DIM ioVNmFls AS unsigned short
DIM ioVBitMap AS short
DIM ioAllocPtr AS short
DIM ioVNmAlBlks AS unsigned short
DIM ioVAlBlkSiz AS long
DIM ioVClpSiz AS long
DIM ioAlBlSt AS short
DIM ioVNxtCNID AS long
DIM ioVFrBlk AS unsigned short
DIM ioVSigWord AS unsigned short
DIM ioVDrvInfo AS short
DIM ioVDRefNum AS short
DIM ioVFSID AS short
DIM ioVBkUp AS unsigned long
DIM ioVSeqNum AS unsigned short
DIM ioVWrCnt AS long
DIM ioVFilCnt AS long
DIM ioVDirCnt AS long
DIM ioVFndrInfo(8) AS long
END RECORD

When I call my FN checkVolOrDiskNotLocked I pass a vRefNum I've 
gotten via a PBGetCatInfo, but the FN checkVolOrDiskNotLocked is 
always telling me that the volume is unlocked. Even for CD-Roms.

Can someone see what I'm doing wrong ?

tia

Pete...