SETCATINFO
PBSetCatInfo Change file or directory de scriptive information #include <Files.h> File Manager (PBxxx)
Boolean async ; 0=await completion; 1=immediate return PBSetCatInfo lets you change such file and directory data as its creation, modification, and backup time, its locked/unlocked status, and Finder- specific
information such as its icon ID and display position.
pb is the address of a 108-byte CInfoPBRec union. The information must be formatted as either a 108-byte HFileInfo or a 104-byte DirInfo structure, depending upon whether the entry is a file or directory.
To change a file's information, use an HFileInfo structure: Out-In Name Type Size Offset Description
-> ioCompletion ProcPtr 4 12 Completion routine address (if async =TRUE) -> ioVRefNum short 2 22 Volume, drive, or working directory reference
-> ioFlAttrib SignedByte 1 30 File Attribute bits ( changes have no effect) -> ioFlFndrInfo FInfo 16 32 (File type, creator, flags, icon point, etc.) -> ioDirID long 4 48 "hard" ID of dir containing target file (or 0)
-> ioFlCrDat long 4 72 Date/time of creation
-> ioFlMdDat long 4 76 Date/time of last modification
-> ioDrBkDat long 4 80 Date/time last backed up
-> ioFlClpSiz long 4 104 Clump size for optimal writing (0=vol default)
<-> ioNamePtr StringPtr 4 18 Address of full or partial name of file <- ioResult OSErr 2 16 Error Code (0=no error, 1=not done yet) To change a directory's information, use a DirInfo structure: Out-In Name Type Size Offset Description
-> ioCompletion ProcPtr 4 12 Completion routine address (if async =TRUE) -> ioVRefNum short 2 22 Volume, drive, or working directory reference
-> ioFlAttrib SignedByte 1 30 File Attribute (only the lock bit can be changed) -> ioDrDirID long 4 48 "hard" ID of dir containing target file (or 0)
-> ioDrCrDat long 4 72 Date/time of creation
-> ioDrMdDat long 2 76 Date/time of last modification
-> ioDrBkDat long 4 80 Date/time last backed up
-> ioDrFndrInfo DXInfo 16 84 (Scroll point, home dir, comment, etc.) <-> ioNamePtr StringPtr 4 18 Address of full or partial name of directory <- 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.
noErr (0) No error
bdNamErr (-37) Bad name
dirNFErr (-120) Directory not found
extFSErr (-58) External file system
fnfErr (-43) File not found
ioErr (-36) I/O error
nsvErr (-35) No such volume
paramErr (-50) No default volume
Notes: This works somewhat like PBHSetFInfo except that it can change
information about directories and it gives you access to additional fields in a
larger parameter block.
fields you don't wish to change. In particular, be sure that ioFlClpSiz is
correct (or 0 for volume default clump size).
Some changes may not be noticed immediately. For instance, if you set the
lock bit of ioFlAttrib, the system may not hear about it for some time (in
addition to the normal volume caching, the Finder appears to have an
internal cache - it's best to call PBSetFLock to lock a file). Other bits of
the attribute byte cannot be changed; e.g., you can't force a directory to
become a regular file.
The following example changes a file's backup date.
Example
#include <Files.h>
short rc;
fpb->ioNamePtr = (StringPtr)"\pHD 20:Ltrs:Smith"; fpb-> ioVRefNum=0; [TOKEN:12074] volume supplied in filename */
fpb->ioFDirIndex=0; /* we're not indexing here */
fpb->ioDirID=0; [TOKEN:12074] 0 says "ignore me" */
if ( rc ) { /* . . . handle the error . . . */ }
GetDateTime( &fpb->ioFlBkDat ); /* set backup date to now */ fpb->ioFlFndrInfo.fdType = 'TEXT'; /* set file type */
if ( rc ) { /* . . . handle the error . . . */ }