Category : Modula II Source Code
Archive   : FIOASM.ZIP
Filename : FIOASM.DEF

 
Output of file : FIOASM.DEF contained in archive : FIOASM.ZIP
(*$M CODE*)(*$D DATA*)
DEFINITION MODULE FioAsm;

(*
File input-output routines for JPI Modula-2
by Carl Neiburger
169 N. 25th St.
San Jose, Calif. 95116

CompuServe No. 72336,2257


These routines are intended to replace low-level routines in JPI's FIO.MOD.
FioAsm's routines are optimized through assembly language. The source code
is in FioAsm.A. These routines may be used directly in Modula-2 programs,
although they are intended to be used with an intermediary Modula-2 module
such as a modified version of FIO.MOD to provide higher-level functions.
The outlines of such a module, NFIO.DEF and NFIO.MOD, are included in this
package.

The definitions in FioAsm are NOT THE SAME as those in FIO.MOD, although
many are similar. There is no IOcheck variable; unless you design your
code to do otherwise, input-output errors will not cause your program
to halt.

However, every procedure that can report a meaningful input-output error
does so in two ways:

-- The procedure returns either a function result or a variable that
indicates whether an error has occurred. The indicators were selected to
fit in with the procedures as naturally as possible. Thus Read and
Write report zero in case of an error, though Read may also report zero
at the end of a file. Procedures that ordinarily return file handles
return MAX(CARDINAL) if an error occurs.

-- The procedure also sets a hidden variable that is read, reported
and reset by IOresult(). If no error occurs, IOresult returns zero;
If an MS-DOS errror occurs, it returns the MS-DOS error code. Thus
IOresult will always return zero unless the LAST input-output procedure
invoked resulted in an error.

If you find any errors in these procedures, please write to me
at the above address so that I may correct them. Thank you.

Revised May 17, 1989, to add SeekRel

*)

TYPE
Handle = CARDINAL;
AccessType = (Input, Output, InputOutput);

PathStr = ARRAY[0..64] OF CHAR;
PathTail = ARRAY[0..12] OF CHAR;

FileAttributes = (readonly,hidden,system,volume,directory,archive,ioerror);
FileAttr = SET OF FileAttributes;
DirEntry = RECORD
rsvd : ARRAY[0..20] OF SHORTCARD;
attr : FileAttr;
time : CARDINAL;
date : CARDINAL;
size : LONGCARD;
Name : PathTail;
END;

TimeType = RECORD
Year, Month, Day, Hours, Mins, Secs: CARDINAL
END;

PROCEDURE IOresult() : CARDINAL;
(* Returns value saved in hidden IOR variable.
Possible values are:
2: file not found.
3: path not found.
4: too many open files.
5: access denied (as in writing to a read-only file).
6: invalid handle.
12: invalid access.
15: invalid drive.
16: trying to remove current directory.
17: trying to move a file to a different drive or device.
*)

(* These procedures set IOresult if they fail: *)
PROCEDURE Create(Name: ARRAY OF CHAR) : Handle;
(* Creates file with specified name *)
(* If unsuccessful, returns MAX(CARDINAL) *)
(* Possible errors: 3, 4, 5 *)

PROCEDURE Open (Name: ARRAY OF CHAR; Typ: AccessType ) : Handle;
(* Opens existing file with specified name and access type *)
(* If unsuccessful, returns MAX(CARDINAL) *)
(* Possible errors: 2, 4, 5, 12 *)

PROCEDURE Close (F: Handle): BOOLEAN;
(* Closes file with specified handle *)
(* If unsuccessful, returns FALSE *)
(* Possible error: 6 *)

PROCEDURE Read (F: Handle; VAR Buf: ARRAY OF BYTE; Count: CARDINAL) : CARDINAL;
(* Returns the number of bytes read from file into Buf, up to a maximum *)
(* of Count. Example: Result = Read( fi, readbuf, SIZE (readbuf) ); *)
(* If unsuccessful, returns 0 *)
(* Possible errors: 5, 6 *)

PROCEDURE Write (F: Handle; Buf: ARRAY OF BYTE; Count: CARDINAL): CARDINAL;
(* Returns the number of bytes written to file from Buf, up to a maximum *)
(* of Count. Example: Result = Write( fi, writebuf, SIZE (writebuf) ); *)
(* If unsuccessful, returns 0 *)
(* Possible errors: 5, 6 *)

PROCEDURE Rename(Name,NewName : ARRAY OF CHAR): BOOLEAN;
(* Renames file Name to NewName *)
(* Can also be used to move a file betwen directories *)
(* If unsuccessful, returns FALSE *)
(* Possible errors: 2, 5, 17 *)

PROCEDURE SetFileAttribute(atr: FileAttr; Name: ARRAY OF CHAR): BOOLEAN;
(* Gives named file a new attribute *)
(* If unsuccessful, returns FALSE *)
(* Possible errors: 3, 5 *)

PROCEDURE GetFileAttribute(Name: ARRAY OF CHAR): FileAttr;
(* Returns the attribute of named file *)
(* If unsuccessful, returns FileAttr{ioerror} *)
(* Possible errors: 3, 5 *)

PROCEDURE Erase (Name: ARRAY OF CHAR): BOOLEAN;
(* Erases named file *)
(* If unsuccessful, returns FALSE *)
(* Possible errors: 2, 5 *)

PROCEDURE RmDir (Name: ARRAY OF CHAR): BOOLEAN;
(* Removes named directory *)
(* If unsuccessful, returns FALSE *)
(* Possible errors: 3, 5, 16 *)

PROCEDURE MkDir (Name: ARRAY OF CHAR): BOOLEAN;
(* Creates named directory *)
(* If unsuccessful, returns FALSE *)
(* Possible errors: 3, 5 *)

PROCEDURE ChDir (Name: ARRAY OF CHAR): BOOLEAN;
(* Changes from current directory to named directory *)
(* If unsuccessful, returns FALSE *)
(* Possible errors: 3 *)

PROCEDURE Seek (F: Handle; Pos: LONGCARD; VAR OK: BOOLEAN);
(* Points MS-DOS read-write pointer to Pos *)
PROCEDURE SeekRel (F: Handle; Pos: LONGINT; VAR OK: BOOLEAN);
(* Mpves MS-DOS read-write pointer Pos bytes toward end of file *)
PROCEDURE GetPos(F: Handle; VAR OK: BOOLEAN) : LONGCARD;
(* Returns position of MS-DOS read-write pointer *)
PROCEDURE SeekEOF (F: Handle; VAR OK: BOOLEAN);
(* Moves MS-DOS read-write pointer to end of file *)
(* For above 3 procedures, possible error: 6 *)
PROCEDURE EOF(F:Handle; VAR OK: BOOLEAN): BOOLEAN;
(* TRUE if MS-DOS read-write pointer is at end of file *)
(* Possible errors: 5, 6, 13 *)
(* Above four procedures return OK if successful *)

PROCEDURE Truncate(F: Handle): BOOLEAN;
(* Truncates file at current MS-DOS read-write pointer position *)
(* If unsuccessful, returns FALSE *)
(* Possible errors: 5, 6 *)

PROCEDURE SetFileTime(fi: Handle; filetime: LONGCARD): BOOLEAN;
(* Sets the file time to MS-DOS format value in filetime. *)
(* See EncodeFileTime below *)
(* Returns false if unsucessful *)
(* Possible error: 6 *)

PROCEDURE FileTime(fi: Handle) : LONGCARD;
(* Returns the file time in MS-DOS format *)
(* See DecodeFileTime below *)
(* Returns 0 if unsucessful *)
(* Possible error: 6 *)

PROCEDURE SetDrive(Dr :SHORTCARD): BOOLEAN;
(* Selects a new default drive *)
(* A: = 1, etc. *)
(* Possible error: 15 *)

(* These procedures do not set IOresult *)
PROCEDURE GetDrive():SHORTCARD;
(* Returns the current default drive *)
(* A: = 1, etc. *)

PROCEDURE Drives(): SHORTCARD;
(* tells how many *)

PROCEDURE GetDir(Drive: SHORTCARD; VAR Name: ARRAY OF CHAR);
(* Returns the current directory path *)
(* If invalid drive or if root directory Name = '' *)

PROCEDURE VerifyIsOn(): BOOLEAN;
(* Reports if the MS-DOS write-verify switch is on *)

PROCEDURE SetVerify(On: BOOLEAN);
(* Turns the MS-DOS write-verify switch on (TRUE) or off (FALSE) *)

PROCEDURE DecodeFileTime ( filetime: LONGCARD; VAR T: TimeType );
(* Translates MS-DOS format filetime into TimeType, *)
(* so you and your program can read it *)
(* See FileTime above *)

PROCEDURE EncodeFileTime ( T: TimeType ) : LONGCARD;
(* Translates TimeType into MS-DOS file time format *)
(* See SetFileTime above *)

PROCEDURE ReadFirstEntry(DirName : ARRAY OF CHAR;
Attr : FileAttr;
VAR D : DirEntry) : BOOLEAN;
(* Returns information on first file found matching *)
(* DirName (which may include wildcards) in D. *)
(* Will return hidden and system files and directories *)
(* if they are included in Attr. Returns FALSE if no *)
(* matching file is found. See ReadNextEntry. *)

PROCEDURE ReadNextEntry (VAR D : DirEntry) : BOOLEAN;
(* Returns subsequent matching files after first is *)
(* found by ReadFirstEntry, above. Returns FALSE if no *)
(* matching file is found. *)

PROCEDURE SetDTA( D : ADDRESS );
(* Assigns the MS-DOS disk transfer area to ADDRESS *)

PROCEDURE GetDTA(): ADDRESS;
(* Returns address of MS-DOS disk transfer area *)

PROCEDURE DiskFree(dr: SHORTCARD; VAR BytesPerClust : CARDINAL ): LONGCARD;
(* Returns disk free space in bytes. BytesPerCluster returns *)
(* the smallest increment of disk space that can be allocated. *)
(* Thus a one-bit file will require BytesPerCluster bytes. *)

END FioAsm.


  3 Responses to “Category : Modula II Source Code
Archive   : FIOASM.ZIP
Filename : FIOASM.DEF

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/