Difference between revisions of "SCI Kernel Documentation/File Functions"

From SCI Wiki
Jump to navigationJump to search
 
(One intermediate revision by the same user not shown)
Line 23: Line 23:
 
</div><br />
 
</div><br />
  
<div align="center"><span style="font-size: 22pt"></span><br />
+
<div align="center"><span style="font-size: 22pt">File Functions</span><br />
 
''Author: [[Jeff Stephenson]]''<br />
 
''Author: [[Jeff Stephenson]]''<br />
 
''Revision by: David Slayback''</div>
 
''Revision by: David Slayback''</div>
Line 29: Line 29:
 
&nbsp;
 
&nbsp;
  
xxxxxxx body xxxxxxxx
+
==<br /> File Functions ==
 +
 
 +
These functions allow access to some of the MS-DOS file functions. They are best accessed through the File class.
 +
 
 +
===<br /> (FileIO fileOpen filename [mode]) ===
 +
 
 +
<blockquote>
 +
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.
 +
</blockquote>
 +
 
 +
===<br /> (FileIO fileFPuts handle string) ===
 +
 
 +
<blockquote>
 +
Write the text pointed to by string to the file whose handle is handle. Returns number of bytes successfully written.
 +
</blockquote>
 +
 
 +
===<br /> (FileIO fileFGets string len handle) ===
 +
 
 +
<blockquote>
 +
Get some text of max length len from the file whose handle is handle and stores it in string. Returns string.
 +
</blockquote>
 +
 
 +
===<br /> (FileIO fileWrite handle address length) ===
 +
 
 +
<blockquote>
 +
Write the length bytes from address and return the number of bytes successfully written.
 +
</blockquote>
 +
 
 +
===<br /> (FileIO fileRead handle address length) ===
 +
 
 +
<blockquote>
 +
Read length bytes into address and return the number of bytes successfully read.
 +
</blockquote>
 +
 
 +
===<br /> (FileIO fileSeek handle offset mode) ===
 +
 
 +
<blockquote>
 +
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.
 +
</blockquote>
 +
 
 +
===<br /> (FileIO fileClose handle) ===
 +
 
 +
<blockquote>
 +
Close the file whose handle is handle.
 +
</blockquote>
 +
 
 +
===<br /> (FileIO fileUnlink filename) ===
 +
 
 +
<blockquote>
 +
Delete filename, returning 0 if unsuccessful.
 +
</blockquote>
 +
 
 +
===<br /> (FileIO fileFindFirst mask @fileName attribute) ===
 +
 
 +
<blockquote>
 +
Find the first file matching mask and put its name into fileName. See a DOS reference for attribute usage (it's somewhat warped).
 +
</blockquote>
 +
 
 +
===<br /> (FileIO fileFindNext @fileName) ===
 +
 
 +
<blockquote>
 +
Continue the search started by fileFindFirst.
 +
</blockquote>
 +
 
 +
===<br /> (FileIO fileExists @fileName) ===
 +
 
 +
<blockquote>
 +
Determine if fileName exists.
 +
</blockquote>
 +
 
 +
===<br /> (GetSaveFiles gameName filenames nums) ===
 +
 
 +
<blockquote>
 +
Read the save-game directory for all files matching &lt;gameName&gt;*.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.
 +
</blockquote>
 +
 
 +
===<br /> (GetCWD pathNamePtr) ===
 +
 
 +
<blockquote>
 +
Get the current working directory and store it in pathNamePtr.
 +
</blockquote>
 +
 
 +
===<br /> (CheckFreeSpace pathName) ===
 +
 
 +
<blockquote>
 +
See if there is enough free space on the disk in pathName to save  the current heap.
 +
</blockquote>
 +
 
 +
===<br /> (ValidPath pathNamePtr) ===
 +
 
 +
<blockquote>
 +
Return TRUE if the passed path is valid, FALSE otherwise.
 +
</blockquote>
 +
 
 +
===<br /> (DeviceInfo GetDevice @path @device) ===
 +
 
 +
<blockquote>
 +
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'.
 +
</blockquote>
 +
 
 +
===<br /> (DeviceInfo CurDevice @device) ===
 +
 
 +
<blockquote>
 +
Puts the string describing the current device in 'device'.
 +
</blockquote>
 +
 
 +
===<br /> (DeviceInfo SameDevice @dev1 @dev2) ===
 +
 
 +
<blockquote>
 +
Returns TRUE if the strings pointed to by 'dev1' and 'dev2' are the same physical device, FALSE otherwise.
 +
</blockquote>
 +
 
 +
===<br /> (DeviceInfo DevRemovable @device) ===
 +
 
 +
<blockquote>
 +
Returns TRUE if 'device' is removable, FALSE otherwise.
 +
</blockquote>
  
 
&nbsp;
 
&nbsp;
Line 42: Line 158:
 
&nbsp;
 
&nbsp;
  
<span style="float: left">[[SCI Kernel Documentation/|&lt; Previous: ]]</span><span style="float: right">[[SCI Kernel Documentation/|Next: &gt;]]</span>
+
<span style="float: left">[[SCI Kernel Documentation/Arithmetic Functions|&lt; Previous: Arithmetic Functions]]</span>
 +
<span style="float: right">[[SCI Kernel Documentation/Debugging Functions|Next: Debugging Functions &gt;]]</span>
  
 
&nbsp;
 
&nbsp;
  
 
[[Category:SCI Documentation]]
 
[[Category:SCI Documentation]]
[[Category:Scripting]]
 
 
[[Category:Kernel Functions]]
 
[[Category:Kernel Functions]]
 +
[[Category:File Functions]]

Latest revision as of 14:33, 3 December 2015

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 >