[comp.sys.apple] DOS 3.3 File Manager

romero@mind.UUCP (Antonio Romero) (01/09/88)

I'm developing some software for the Apple IIe/c using Manx's C compiler
v1.05.  I'm in a bit of a bind at the moment, because Manx's creat() 
function from their library is rather buggy.  I can't seem to get it to
work for creating text files-- the machine almost invariably crashes.
Since the creat() function is evidently nothing but an interface to the file
manager of DOS 3.3, I'd like to try bypassing the library altogether 
and calling the file manager directly, but I can't find a description of
the file manager anywhere in the technical reference manual for DOS 3.3 or
in the Dos Programmer's Toolkit.   Does anyone out there know a readily
available reference which describes the use of the file manager? Can 
anyone out there provide me with examples of their own code for using it?

My only other alternative would be to create the file as an empty binary
file, then grub through the catalog track and change the byte which
holds the file type from binary to text.  From what I remember of DOS
3.3, this should work.  Does anyone out there know of a reason why
it might fail?

Thanks for any information you can provide.

-Antonio Romero       romero@mind.Princeton.EDU

spike@bu-cs.BU.EDU (Spike) (01/10/88)

In article <1568@mind.UUCP> romero@mind.UUCP (Antonio Romero) writes:
>I'm developing some software for the Apple IIe/c using Manx's C compiler
>v1.05.  I'm in a bit of a bind at the moment, because Manx's creat() 
>function from their library is rather buggy.  I can't seem to get it to
>work for creating text files-- the machine almost invariably crashes.
>Since the creat() function is evidently nothing but an interface to the file
>manager of DOS 3.3, I'd like to try bypassing the library altogether 
>and calling the file manager directly, but I can't find a description of
>the file manager anywhere in the technical reference manual for DOS 3.3 or
>in the Dos Programmer's Toolkit.   Does anyone out there know a readily
>available reference which describes the use of the file manager? 

	This is cribbed from _Beneath_Apple_Dos_ [Worth, Lechner] get
it if you can!!

	O.K. to use the File Manager you do to things

First:
	You tell the File Manager the location of your parameter list.
This is done with a  'JSR $3DC'  where the high part of the address is
in Y and the low in A.

Second:

	The file manager is call with a  'JSR $3D6'.  If a file is not
found and the X refister contains 0 then the file is created; if X
does not contain 0 an error is returned.

For the Open call the parameter list should look like:

Byte
00      ->  01 (OPEN)
02/03   ->  Fix record length or 0000 if variable
04	->  Volume number or 00 for any
05	->  Drive [01 or 02]
06	->  Slot  [01 thur 07]
07	->  File type
	$00 = TEXT  $01 = INTEGER BASIC  $02 = APPLESOFT BASIC $04 = BINARY 
	$08 = RELOCATABLE  $10 = S TYPE  $20 = A TYPE  $40 = B TYPE
08/09	->  Low/High address of filename  (30 chars)
0C/0D	->  Low/High address of workarea buffer  (45 bytes)
0E/0F	->  Low/High address of Track/Sector list buffer (256 bytes)
10/11	->  Low/High address of data buffer  (256 bytes)


	The three buffers are initialized by the file manager not by
the caller


The call returns

Byte

07	->  File type opened  (useful if the file was not just created)
0A	->  Return Code
	    $00 = No Error  $02 = Bad Call  $03 = Bad Sub Call 
	    $04 = Write Protected  $05 = End Of Data  $06 = File Not Found
	    $07 = Volume Mismatch  $08 = Disk I/O Error   $09 = Disk Full
	    $0A = File Locked

OPEN should alway be follow by a POSITION call.  For creat you would want to
set the position to the start of the file i.e. 02-05 = 00 00 00 00.

BYTE
00	->  0A (Position)
02/03	->  Relative record number (0000 is the first) if fixed record length
	    0000 if not fix record.
04/05   ->  Offset in to record or if not fix record offset in to file
0C/OD   ->  Low/High address of data buffer (256 bytes)

0A	->  Return code

CLOSE Cleans up and updates the catalog.  It looks like:

BYTE
00	-> 02 (Close)
0C/0D	->  Low/High address of workarea buffer  (45 bytes)
0E/0F	->  Low/High address of Track/Sector list buffer (256 bytes)
10/11	->  Low/High address of data buffer (256 bytes)

0A	->  Return code

	"Last night I had that dream again. I dreamt I had to take a
		test, in a Dairy Queen, on another planet."
 UUCP:	...!harvard!bu-cs!bu-it!spike  ARPANET: spike@bu-it.bu.edu
   CSNET: spike%bu-it@bu-cs   BITNET: engemnc@bostonu "VPS sucks"

-- 
->Spike

mturner@convexe.UUCP (01/12/88)

If you really want to learn about dos 3.3 and the file manager then you
should invest in a copy of beneath apple dos 3.3.  You should be able to find
it in a bookstop.  
---Mike Turner

mdelama1@ORION.CF.UCI.EDU (Michael De La Maza) (02/20/88)

Worth's Beneath Apple DOS has a good description of the File Manager.
If that is not enough try Sandy Mossberg's column in Nibble.  He
disassembled all of Dos a while back.
In any case, your second alternate method should work.