[futurebasic] Re: [FB] Checking for locked files

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2011 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Mon, 25 Apr 2011 11:05:07 +1200
Ken Shmidheiser wrote:

>  the following may help.

That doesn't compile.  Here's a rewrite that does.

'---------------
include "Tlbx MoreFilesX.incl"

local fn FSCheckLock( ref as ^FSRef ) as OSErr
'~'1
dim as OSErr          result
dim as FSCatalogInfo  catalogInfo
dim as FSVolumeInfo   volumeInfo

// Get nodeFlags and FSVolumeRefNum
result = fn FSGetCatalogInfo( #ref, _kFSCatInfoNodeFlags + _kFSCatInfoVolume, @catalogInfo, 0, 0, 0 )
if ( result ) then exit fn
long if ( catalogInfo.nodeFlags and _kFSNodeLockedMask )
result = _fLckdErr // File is locked
exit fn
end if
// File isn't locked, but is volume locked? Check volume flags.
result = fn FSGetVolumeInfo( catalogInfo.volume, 0, 0, _kFSVolInfoFlags, @volumeInfo, 0, 0 )
if ( result ) then exit fn
long if ( volumeInfo.flags and _kFSVolFlagHardwareLockedMask )
result = _wPrErr // Volume locked by hardware.
exit fn
end if
long if ( volumeInfo.flags and _kFSVolFlagSoftwareLockedMask )
result = _vLckdErr // Volume locked by software.
end if
end fn = result
'---------------


Robert P.