FileIO (Kernel)

FileIO handles all file operations in SCI1.1. The File class wraps all these calls, and should generally be used instead.

Important

SCI1.1 only.

FileIO(fiOPEN filename mode)

Opens a file.

Parameters:
  • filename (string) – The filename.
  • mode (number) – An open mode described below.
Returns:

A handle to the file if successful. Otherwise NULL.

The modes are as follows:

Mode Description
fOPENFAIL open or fail: Try to open file, abort if not possible
fOPENCREATE open or create: Try to open file, create it if it doesn’t exist
fCREATE create: Create the file, destroying any content it might have had
FileIO(fiCLOSE handle)

Closes the specified file.

Parameters:handle (number) – A handle returned by FileIO(fiOPEN).
FileIO(fiREAD handle outBuffer byteCount)

Reads a number of bytes from a file.

Parameters:
  • handle (number) – A handle returned by FileIO(fiOPEN).
  • outBuffer (heapPtr) – A buffer into which the bytes are placed (at least byteCount big).
  • byteCount (number) – The number of bytes to read.
Returns:

The number of bytes actually read.

FileIO(fiWRITE handle inBuffer byteCount)

Writes data to a file.

Parameters:
  • handle (number) – A handle returned by FileIO(fiOPEN).
  • inBuffer (heapPtr) – A buffer containing the data to be written.
  • byteCount (number) – The number of bytes to write.
FileIO(fiUNLINK filename)

Deletes a file.

Parameters:filename (string) – The filename to delete.
FileIO(fiREAD_STRING outText byteCount handle)

Reads a string from a file.

Parameters:
  • outText (heapPtr) – A buffer into which string is placed (at least byteCount big).
  • byteCount (number) – The number of bytes to read.
  • handle (number) – A handle returned by FileIO(fiOPEN).
FileIO(fiWRITE_STRING handle inString byteCount)

Writes a string to a file.

Parameters:
  • handle (handle) – A handle returned by FileIO(fiOPEN).
  • inText (heapPtr) – The string to write.
FileIO(fiSEEK handle offset whence)

Seeks to a position in the file.

Parameters:
  • handle (number) – A handle returned by FileIO(fiOPEN).
  • offset (number) – The offset.
  • whence (number) – The point to which the offset is relative.
Whence values
Values Position
0 Beginning
1 Current position
2 End
FileIO(fiFIND_FIRST filenameMask outBuffer fileAttributes)

Begins a file enumeration in the current directory. Continue the enumeration using FileIO(fiFIND_NEXT).

Parameters:
  • filenameMask (string) – A file name filter string, like “*.txt”.
  • outBuffer (string) – The buffer that receives the first filename.
  • fileAttributes (number) – Attributes of the file. Pass 0 for regular files.
Returns:

TRUE if the first file was found, otherwise FALSE.

FileIO(fiFIND_NEXT outBuffer)

Returns the next file in an enumeration begun by fiFIND_FIRST.

Parameters:outBuffer (string) – The buffer that receives the next filename.
Returns:TRUE if there was another file, otherwise FALSE.
FileIO(fiEXISTS filename)

Checks whether a file exists.

Parameters:filename (string) – The filename.
Returns:TRUE if the file exists.
FileIO(fiRENAME oldFilename newFilename)

Renames a file.

Parameters:
  • oldFilename (string) – The current filename.
  • newFilename (string) – The new filename.