PBSetVInfoSync
PBSetVInfo Change volume name, backup date; lock/unlock it
#include <Files.h> File Manager (PBxxx)
OSErr PBSetVInfo(pb, async );
HParmBlkPtr pb ; address of a 122-byte HVolumeParam structure
Boolean async ; 0=await completion; 1=immediate return
returns Error Code; 0=no error
PBSetVInfo lets you change a volume's name, its creation, modification, and
backup date/time, its Finder information, and the locked/unlocked volume
attribute.
pb is the address of a 122-byte HVolumeParam structure. The
following fields are relevant:
Out-In Name Type Size Offset Description
-> ioCompletion ProcPtr 4 12 Completion routine address (if async =TRUE)
-> ioNamePtr StringPtr 4 18 Address of volume name (NIL=don't change)
-> ioVRefNum short 2 22 Volume or drive number
-> ioVCrDate long 4 30 Date/time volume created
-> ioVLsMod long 4 34 Date/time volume information was modified
-> ioVAtrb short 2 38 Volume attributes (bit 15=locked, etc.)
-> ioVClpSiz long 4 52 Default clump size (bytes to allocate)
-> ioVBkUp long 4 72 Date/time of most-recent backup
-> ioVSeqNum short 2 76 (used internally)
-> ioVFndrInfo[8] long 32 90 Information used by the Finder
<- ioResult OSErr 2 16 Error Code (0=no error, 1=not done yet)
async is a Boolean value. Use FALSE for normal (synchronous) operation
or TRUE to enqueue the request and resume control immediately. See
Async I/O.
Returns: an operating system Error Code. It will be one of:
noErr (0) No error
nsvErr (-35) No such volume
paramErr (-50) No default volume

Notes: The normal way to use this function is to call PBHGetVInfo, change one or
two fields in the HVolumeParam structure, then call PBSetVInfo. Use
FlushVol to ensure that the changes get written to the media.
If you are using a string in the ioNamePtr field to specify a volume name,
the string must be in the following form
myVolParam.ioNamePtr = "\pMy HardDisk:
The trailing colon on the string indicates that we are referring to a
directory, not a file.
Of the volume attributes in ioVAtrb, only bit 15 (the lock bit) can be
modified. Set it or reset it as follows:
pb.ioVAtrb |= 0x8000; [TOKEN:12074] lock the volume */
pb.ioVAtrb &= 0x7FFFF; [TOKEN:12074] unlock the volume */
Note that a file on a locked volume may be opened for writing, but all
attempts to write to the file will fail.
Use PBSetCatInfo to modify information on files and directories,
including the information used by the Finder.
Note: If you change the volume name via this command, the Finder and
Standard File Package may not recognize the change immediately. Use
Rename or PBRename instead.
The following example illustrates how to use PBSetVInfo to set the
backup date/time to the current system date/time.
Example
#include <Files.h>
HVolumeParam pb; È/* create the 122-byte structure */
short err;
pb.ioVolIndex = 1; /* get info on first disk */
err = PBHGetVInfo( &pb, FALSE ); /* synchronous request */
if (err) { /*. . . handle the error . . . */ }
GetDateTime( &pb.ioVBkUp ); /* set the backup date */
err = PBSetVInfo( &pb, FALSE ); /* install the change */
if (err) { /*. . . handle the error . . . */ }
FlushVol( 0, pb.ioVRefNum ); /* flush to the media */