[net.micro.mac] How to detect if a disk is locked??

rick@sara70.UUCP (Rick Jansen) (08/06/85)

 
[Share and enjoy]
 
Does anyone know the right way to check wether a disk, given its
VolumeReferenceNumber, is write protected?
 
I need to know this for an application which performs spooling and
spool printing. Then a spool file is created on the disk, which
of course does not work with locked disks.
The Printing Manager function PrError returns the value -51 (rfNumErr,
reference number wrong) with a locked disk after PrOpenDoc. It is NOT
documented that this is the error code for a locked disk, so it is
not a reliable means of checking wether printing is possible.
 
So, I decided to check wether the disk is locked myself. There is NO
high-level File Manager routine which you can ask wether a given disk
is locked. The routines returning the error code wrPrError (-44) all
try to CHANGE something on the disk, like Creating, Deleting files etc.
GetVInfo just returns FreeBytes (the number of free bytes on the disk)
wether or not the disk is locked.
Also, GetVInfo has BOTH parameters drvNum and vRefNum. It is not explicitly
documented what to pass for drvNum when you want to access the volume
by its reference number (0 will do).
 
Well, try the low-level routines then: PBGetVInfo (NOT PBGetVolInfo
as the File Manager erroneously tries to let us believe!!).
Page 30 of the File Manager manual states for the field ioVAtrb that
if the volume is locked bit 15 is 1. My observations are that it
is bit 7 which is 1 with locked disks! Can anyone confirm this
(Apple please)? What is the function the other bits?
 
Something else: the Segment Loader routine GetAppParms' first parameter
is documented to be of type STRING[31]. This should be STR255, as the
Pascal interface states. (GetAppParms was called to get the Volume
Reference number of the application disk.)
 
Thank you in advance for making a programmer very happy,
Rick Jansen
{seismo,decvax,philabs}!mcvax!sara70!rick