Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Files /
Chapter 2 - File Manager / File Manager Reference
Low-Level HFS Routines / Accessing Information About Files and Directories


PBGetCatInfo

You can use the PBGetCatInfo function to get information about the files and directories in a file catalog.

FUNCTION PBGetCatInfo (paramBlock: CInfoPBPtr; async: Boolean): 
                        OSErr;
paramBlock
A pointer to a catalog information parameter block.
async
A Boolean value that specifies asynchronous (TRUE) or synchronous (FALSE) execution.
for files
-->ioCompletionProcPtrA pointer to a completion routine.
<--ioResultOSErrThe result code of the function.
<->ioNamePtr StringPtrA pointer to a pathname.
-->ioVRefNumIntegerA volume specification.
<--ioFRefNumIntegerA file reference number.
-->ioFDirIndexIntegerAn index.
<--ioFlAttribSignedByteThe file attributes.
<--ioFlFndrInfoFInfoInformation used by the Finder.
<->ioDirIDLongIntOn input, a directory ID. On output, a file ID.
<--ioFlStBlk IntegerThe first allocation block of the
data fork.
<--ioFlLgLenLongIntThe logical end-of-file of the data fork.
<--ioFlPyLenLongIntThe physical end-of-file of the
data fork.
<--ioFlRStBlkIntegerThe first allocation block of the resource fork.
<--ioFlRLgLenLongIntThe logical end-of-file of the
resource fork.
<--ioFlRPyLenLongIntThe physical end-of-file of the
resource fork.
<--ioFlCrDatLongIntThe date and time of creation.
<--ioFlMdDatLongIntThe date and time of the last modification.
<--ioFlBkDatLongIntThe date and time of the last backup.
<--ioFlXFndrInfoFXInfoAdditional information used by
the Finder.
<--ioFlParIDLongIntThe directory ID of the parent directory.
<--ioFlClpSizLongIntThe file's clump size.

for directories
-->ioCompletionProcPtrA pointer to a completion routine.
<--ioResultOSErrThe result code of the function.
<->ioNamePtr StringPtrA pointer to a pathname.
-->ioVRefNumIntegerA volume specification.
-->ioFDirIndexIntegerAn index.
<--ioFlAttribSignedByteThe directory attributes.
<--ioACUserSignedByteThe directory access rights.
<--ioDrUsrWdsDInfoInformation used by the Finder.
<->ioDrDirIDLongIntThe directory ID.
<--ioDrNmFlsIntegerThe number of files in the directory.
<--ioDrCrDatLongIntThe date and time of creation.
<--ioDrMdDatLongIntThe date and time of the last modification.
<--ioDrBkDatLongIntThe date and time of the last backup.
<--ioDrFndrInfoDXInfoAdditional information used by
the Finder.
<--ioDrParIDLongIntThe directory ID of the parent directory.

DESCRIPTION
The PBGetCatInfo function returns information about a file or directory, depending on the values you specify in the ioFDirIndex, ioNamePtr, ioVRefNum, and ioDirID or ioDrDirID fields. If you need to determine whether the information returned is for a file or a directory, you can test bit 4 of the ioFlAttrib field; if that bit is set, the information returned describes a directory.

The PBGetCatInfo function selects a file or directory according to these rules:

With files, PBGetCatInfo is similar to PBHGetFInfo but returns some additional information. If the file is open, the reference number of the first access path found is returned in ioFRefNum, and the name of the file is returned in ioNamePtr (unless ioNamePtr is NIL). The file's attributes are returned in the ioFlAttrib field. See
the description of the fields of the CInfoPBRec data type (beginning on page 2-100)
for the meaning of the bits in this field.

Note
When you get information about a file, the ioDirID field contains the file ID on exit from PBGetCatInfo. You might need to save the value of ioDirID before calling PBGetCatInfo if you make subsequent calls with the same parameter block.
With directories, PBGetCatInfo returns information such as the directory attributes and, for server volumes, the directory access privileges of the user. The directory attributes are encoded by bits in the ioFlAttrib field and have these meanings:
BitMeaning
0Set if the directory is locked
1Reserved
2Set if the directory is within a shared area of the directory hierarchy
3Set if the directory is a share point that is mounted by some user
4Set if the item is a directory
5Set if the directory is a share point
6-7Reserved

Note
These bits in the ioFlAttrib field for directories are read-only.
You cannot alter directory attributes by setting these bits using PBSetCatInfo. Instead, you can call PBHSetFLock and PBHRstFLock to lock and unlock a directory, and PBShare
and PBUnshare to enable and disable file sharing on local
directories.
The PBGetCatInfo function returns the directory access rights in the ioACUser
field only for shared volumes. As a result, you should set this field to 0 before
calling PBGetCatInfo.

You can also use PBGetCatInfo to determine whether a file has a file ID reference.
The value of the file ID is returned in the ioDirID field. Because that parameter could also represent a directory ID, call PBResolveFileIDRef to see if the value is a real
file ID. If you want to determine whether a file ID reference exists for a file and create one if it doesn't, use PBCreateFileIDRef, which will either create a file ID or
return fidExists.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for PBGetCatInfo are
Trap macroSelector
_HFSDispatch$0009

RESULT CODES
noErr0No error
nsvErr-35No such volume
ioErr-36I/O error
bdNamErr-37Bad filename
fnfErr-43File not found
paramErr-50No default volume
dirNFErr-120Directory not found or incomplete pathname
afpAccessDenied-5000User does not have the correct access
afpObjectTypeErr-5025Directory not found or incomplete pathname

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996