SCI Kernel Documentation/File Functions

From SCI Wiki
Revision as of 14:33, 3 December 2015 by Andrew Branscom (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Official SCI Documentation

Chapter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Index


File Functions

Author: Jeff Stephenson

Revision by: David Slayback

 


File Functions

These functions allow access to some of the MS-DOS file functions. They are best accessed through the File class.


(FileIO fileOpen filename [mode])

Opens the file whose name is filename and returns a handle to it. The optional parameter mode may be either fAppend, in which case the file pointer will be positioned at the end of the file for appending, or fTrunc, in which case the file will be truncated to zero length, or FRead in which case the file pointer will be positioned at the beginning of the file. If mode is not specified, fAppend is assumed. If there is an error in opening the file, a value of -1 is returned, else the file handle.


(FileIO fileFPuts handle string)

Write the text pointed to by string to the file whose handle is handle. Returns number of bytes successfully written.


(FileIO fileFGets string len handle)

Get some text of max length len from the file whose handle is handle and stores it in string. Returns string.


(FileIO fileWrite handle address length)

Write the length bytes from address and return the number of bytes successfully written.


(FileIO fileRead handle address length)

Read length bytes into address and return the number of bytes successfully read.


(FileIO fileSeek handle offset mode)

Changes the position in the file where the next read or write will occur. The new position is specified by means of the mode and offset. If the mode is fileSeekCur the offset is relative to the beginning of the file. If the mode is fileSeekCur the offset is relative to the current position. If the mode is fileSeekEnd the offset is relative to the end of the file. The offset can be negative (for fileSeekCur and fileSeekEnd modes). The new file position is returned.


(FileIO fileClose handle)

Close the file whose handle is handle.


(FileIO fileUnlink filename)

Delete filename, returning 0 if unsuccessful.


(FileIO fileFindFirst mask @fileName attribute)

Find the first file matching mask and put its name into fileName. See a DOS reference for attribute usage (it's somewhat warped).


(FileIO fileFindNext @fileName)

Continue the search started by fileFindFirst.


(FileIO fileExists @fileName)

Determine if fileName exists.


(GetSaveFiles gameName filenames nums)

Read the save-game directory for all files matching <gameName>*.num, putting file descriptions in the array pointed to by filenames, the file numbers in the array pointed to by nums. Returns the number of save games found.


(GetCWD pathNamePtr)

Get the current working directory and store it in pathNamePtr.


(CheckFreeSpace pathName)

See if there is enough free space on the disk in pathName to save the current heap.


(ValidPath pathNamePtr)

Return TRUE if the passed path is valid, FALSE otherwise.


(DeviceInfo GetDevice @path @device)

Puts the string describing the device component of 'path' into the string pointed to by 'device'. Thus, if path = "g:/games/kq4/sci", device = "g:". If there is no device component in 'path', puts the current device in 'device'.


(DeviceInfo CurDevice @device)

Puts the string describing the current device in 'device'.


(DeviceInfo SameDevice @dev1 @dev2)

Returns TRUE if the strings pointed to by 'dev1' and 'dev2' are the same physical device, FALSE otherwise.


(DeviceInfo DevRemovable @device)

Returns TRUE if 'device' is removable, FALSE otherwise.

 

Notes


 

Table of Contents

 

< Previous: Arithmetic Functions Next: Debugging Functions >