FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DISK I/O

Use FSMakeFSSpec


These are examples of Toolbox routines that were invented after FB was released; hence, FB does not have built-in support for them.

However, we can implement them the way our poor C-programmer brothers are forced to do, which is to include the appropriate in-line assembly code.

The following is an implementation of FSMakeFSSpec (I would recommend using this rather than PBMakeFSSpec, because it is generally easier to set up the parameters).

'=================
LOCAL MODE
LOCAL FN FSMakeFSSpec(vRefNum%,dirID&,fileName$,@spec&)
'---------------------------------------
  ` CLR.W -(SP)
  ` MOVE.W ^vRefNum%,-(SP) ;INTEGER
  ` MOVE.L ^dirID&,-(SP) ;LONGINT
  ` PEA ^fileName$ ;ConstStr255Param
  ` MOVE.L ^spec&,-(SP) ;Var: FSSpec
  ` DC.W $7001,$AA52
  ` MOVE.W (SP)+,D0
  ` EXT.L D0
END FN

FSMakeFSSpec is a neat function--it does a lot more than just gluing together the three pieces of the file spec for you. For example:

* If you leave the objName$ parameter blank (a null string), then the function creates an fsSpec for the folder specified by vRefNum and dirID&;

* If you set both vRefNum% and dirID& to zero, then they specify the current default directory;

* If you set dirID& to zero and set vRefNum% to a working directory reference number, then they specify that working directory;

* If objName$ is a full path name, then vRefNum% and dirID& are ignored, and an fsSpec is created for the object indicated by the path.

In any case, regardless of what you _start_ with, the fsSpec record that's created will contain the (true) volume reference number of the object's volume, the directory ID of its parent directory, and the object's name.

Rick and David