Difference between revisions of "83Plus:Software:usb8x/Asm Interface/MSD/DOS openFile"

From WikiTI
Jump to: navigation, search
 
m
 
Line 11: Line 11:
  
 
=== Outputs ===
 
=== Outputs ===
 +
* File handle is populated and seek pointer is set to offset 0
 
* HL points to the file handle
 
* HL points to the file handle
 
* C set if problems
 
* C set if problems

Latest revision as of 01:26, 17 August 2006

Synopsis

Name: DOS_openFile

Minimum usb8x version: 0.10

Opens a file for reading or writing by populating a file handle containing important information.

Inputs

  • HL points to ASCIIZ filename including path (ex. "/TESTDIR/TEST.TXT",0)
  • DE points to a location to store the file handle (typically 27 bytes, size obtained by [[../MSDVersion|MSDVersion]])

Outputs

  • File handle is populated and seek pointer is set to offset 0
  • HL points to the file handle
  • C set if problems

Destroys

  • AF, BC, DE, HL

Notes

The filename is case-insensitive. There is also no "closing" a file. The file handle can be discarded when no more reading/writing is required. Example code to open "README.TXT" for reading/writing (storing file handle to statVars):

ld hl,sFilename
ld de,statVars
U_CALL DOS_openFile
jr c,openFileError
;HL points to file handle
...
openFileError:
...
sFilename: DB "/TESTDIR/README.TXT",0

See Also

  • [[../DOS_fileSeek|DOS_fileSeek]] - Set seek pointer of file handle
  • [[../DOS_fileRead|DOS_fileRead]] - Read bytes from a file
  • [[../DOS_fileWrite|DOS_fileWrite]] - Write bytes to a file