Macintosh Parameter-Block Record Format (Used by HFSDispatch) (69177)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0b

This article was previously published under Q69177

SUMMARY

The HFSDispatch library routine (an MBLC resource) for QuickBasic for the Macintosh allows access to HFS (hierarchical file system) routines that do not have individual trap addresses. You must pass these HFS routines an input/output parameter block, which contains information used by the File Manager to perform the details of the routine. However, the data structure of the parameter block is not fully compatible with the data structures available with QuickBasic. This article shows how to set up an array of integers that can be used as the parameter block.

The following information applies to Microsoft QuickBasic versions 1.0, 1.0a, and 1.0b for Apple Macintosh.

MORE INFORMATION

A Macintosh parameter-block record is a variable record that can take six basic forms:

  1. ParamBlockRec -- Used by all routines in the 64K ROM version of the Macintosh File Manager.
  2. HParamBlockRec -- Used by the RAM-based version of the File Manager, which can use the hierarchical file system.
  3. CInfoPBRec
  4. CMovePBRec
  5. WDPBRec -- Used by routines that exclusively use the hierarchical file directory (128K ROM only).
  6. FCBPBRec -- Used to gain access to the contents of a file's file control block (128K ROM only).
HFSDispatch uses all six parameter-block record formats, depending on the routine that it calls.

The format for QuickBasic's HFSDispatch library call is
   HFSDispatch selector%, IOPB%(0)
				
where selector% is the routine number to call, as follows:
  Selector% Routine Name  Parameter-Block Record Type
  --------- ------------  ---------------------------

     1      OpenWD        WDPBRec
     2      CloseWD       WDPBRec
     5      CatMove       CMovePBRec
     6      DirCreate     HParamBlockRec
     7      GetWDInfo     WDPBRec
     8      GetFCBInfo    FCBPBRec
     9      GetCatInfo    CInfoPBRec
    10      SetCatInfo    CInfoPBRec
    11      SetVolInfo    HParamBlockRec
    16      LockRng       ParamBlockRec
    17      UnlockRng     ParamBlockRec
				
The IOPB% array is used to set up a memory region to be used as the parameter block. For most uses of HFSDispatch, this array should be dimensioned to around 60 integer elements.

The first 11 array elements and corresponding parameter-block record entries are as follows:
   Array
   Element Element Name  Pascal Type  Description
   ------- ------------  -----------  -----------

   0-1     qLink         QElemPtr     Used by File Manager
    2      qType         Integer      Used by File Manager
    3      ioTrap        Integer      Used by File Manager
   4-5     ioCmdAddr     Ptr          Used by File Manager
   6-7     ioCompletion  ProcPtr      Pointer to completion routine
    8      ioResult      OsErr        Returns the result code
   9-10    ioNamePtr     StringPtr    Points to string containing
                                      path/filename
    11     ioVRefNum     Integer      Volume, drive, or working directory
                                      reference number
				
Note that the above eight fields are identical for all six parameter-block record types.

The remaining elements of the record vary according to the parameter-block record type, as well as the type of file access being done, whether for a file, a volume, a catalog information query, or other low-level access.

An example of the data structure for the CInfoPBRec, used in the GetCatInfo and SetCatInfo routines, follows. A similar technique can be used for breaking down the other parameter-block records.

For Files

   Array
   Element Element Name  Pascal  Type   Description
   ------- ------------  -----------   -----------

    12     ioFRefNum     Integer       Path reference number
   13(h)   ioFVersNum    Signed Byte   Version number
   13(l)   filler1       Signed Byte   Not used
    14     ioFDirIndex   Integer       Index (see "Inside Macintosh,"
                                       volume 4, pages 155-156 for usage)
   15(h)   ioFlAttrib    Signed Byte   File attributes (see below)
   15(l)   filler2       Signed Byte   Not used
   16-23   ioFlFndrInfo  FInfo
                         (16 Bytes)    Information used by the Finder
                                       (see below)
   24-25   ioDirID       Long Integer  Directory ID or file number
    26     ioFlStBlk     Integer       First allocation block of data fork
   27-28   ioFlLgLen     Long Integer  Logical end-of-file of data fork
   29-30   ioFlPyLen     Long Integer  Physical end-of-file of data fork
    31     ioFlRStBlk    Integer       First allocation block resource fork
   32-33   ioFlRLgLen    Long Integer  Logical end-of-file of resource fork
   34-35   ioFlRPyLen    Long Integer  Physical end-of-file resource fork
   36-37   ioFlCrDat     Long Integer  Date and time of creation
   38-39   ioFlMdDat     Long Integer  Date and time of last modification
   40-41   ioFlBkDat     Long Integer  Date and time of last backup
   42-49   ioFlXFndrInfo FXInfo
                         (16 bytes)    Additional information used by the
                                       Finder (see below)
   50-51   ioFlParID     Long Integer  File's parent directory ID
   52-53   ioFlClpSiz    Long Integer  File's clump size
				

For Directories

   Array
   Element Element Name  Pascal Type   Description
   ------- ------------  -----------   -----------

    12     ioFRefNum     Integer       Path reference number
   13(h)   ioFVersNum    Signed Byte   Version number
   13(l)   filler1       Signed Byte   Not used
    14     ioFDirIndex   Integer       Index (see "Inside Macintosh,"
                                       volume 4, pages 155-156 for usage)
   15(h)   ioFlAttrib    Signed Byte   File attributes (see below)
   15(l)   filler2       Signed Byte   Not used
   16-23   ioDrUsrWds    DInfo
                         (16 Bytes)    Information used by the Finder
                                       (see below)
   24-25   ioDrDirID     Long Integer  Directory ID
    26     ioDrNmFls     Integer       Number of files in directory
   27-35   filler3       Array [1..9]
                         of Integer    Not used
   36-37   ioDrCrDat     Long Integer  Date and time of creation
   38-39   ioDrMdDat     Long Integer  Date and time of last
                                       modification
   40-41   ioDrBkDat     Long Integer  Date and time of last backup
   42-49   ioDrFndrInfo  DXInfo
                         (16 bytes)    Additional information used by the
                                       Finder (see below)
   50-51   ioFlParID     Long Integer  Directory's parent directory ID
				
Note that some of the element names are common to some or all of the other data structures.

The ioFlAttrib byte contains the following file attributes:
   Bit   Meaning
   ---   -------

   0     Set if file is locked
   2     Set if resource fork is open
   3     Set if data fork is open
   4     Set if a directory
   7     Set if file (either fork) is open
				
Following are some of the additional data types used by the Finder, broken down by element:

Type FInfo

    Array   Element Name  Pascal Type      Description
   -----   ------------  -----------      -----------

   16-17   fdType        OSType (4 Char)  File type
   18-19   fdCreator     OSType (4 Char)  File's creator code
    20     fdFlags       Integer          File flags as follows:

                                             Bit 0  - Set if file
                                                      is on desktop
                                             Bit 13 - Set if file
                                                      has a bundle
                                             Bit 15 - Set if file's
                                                      icon is invisible

   21-22   fdLocation    Point (4 bytes)  File's icon location
    23     fdFldr        Integer          File's window as follows:

                                             -3  - File in Trash window
                                             -2  - File is on desktop
                                              0  - File is in disk window
				

Type FXInfo

   Array   Element Name  Pascal Type    Description
   -----   ------------  -----------    -----------

    42     fdIconID      Integer        Icon ID
   43-46   fdUnused      Array [1..4]
                         of Integer     Reserved
    47     fdComment     Integer        Comment ID
   48-49   fdPutAway     Long Integer   Home directory ID
				

Type DInfo

   Array   Element Name  Pascal Type    Description
   -----   ------------  -----------    -----------

   16-19   frRect        Rect
                         (8 bytes)      Folder's rectangle coordinates
    20     frFlags       Integer        Directory flags (see fdFlags above)
   21-22   frLocation    Point
                         (4 bytes)      Folder's location
    23     frView        Integer        Folder's view
				

Type DXInfo

   Array   Element Name  Pascal Type    Description
   -----   ------------  -----------    -----------

   42-43   frScroll      Point
                         (4 bytes)      Scroll position
   44-45   frOpenChain   Long Integer   Directory ID chain of open folders
    46     frUnused      Integer        Reserved
    47     frComment     Integer        Comment ID
   48-49   frPutAway     Long Integer   Directory ID
				
One problem with using an integer array for the IOPB structure is that the element sizes of the parameter block are not all 2 bytes long. For example, to convert the ioFlPyLen (a long integer value containing the physical length of the data fork) from two integer values (IOPB%(29) and IOPB%(30)) to a single, long-integer value, the following formula must be used:
   PhysicalLength& = PEEKL(VARPTR(IOPB%(29)))
				
To convert a long integer to two integers:
   IOPB%(29) = PEEKW(VARPTR(PhysicalLength&))     ' High 2 bytes
   IOPB%(30) = PEEKW(2+VARPTR(PhysicalLength&))   ' Low 2 bytes
				
To extract a single byte from an integer, as is required to get the ioFVersNum, the following will work:
high% = PEEK(VARPTR(IOPB%(13)))    ' Extracts high byte from integer
low% = PEEK(1+VARPTR(IOPB%(13)))   ' Extracts low byte from integer
VersNumber% = high%
ioPermission% = low%   '(ioPermission is a signed byte in HParamBlockRec)
				
To combine two bytes into an integer:
POKE VARPTR(IOPB%(13)), high%
POKE VARPTR(IOPB%(13))+1, low%
				
The preceding information can be applied to all formats of the parameter block. For more information on the structure and data elements of the other formats, consult

REFERENCES

"Inside Macintosh," volume 4, Apple Computer Inc., Addison-Wesley

Modification Type:MajorLast Reviewed:10/20/2003
Keywords:KB69177