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

From WikiTI
Jump to: navigation, search
(Brandon forgot he used the OP registers. . .)
 
Line 33: Line 33:
 
</code>
 
</code>
 
To read/write to this file, you must then open the file with [[../DOS_openFile|DOS_openFile]].
 
To read/write to this file, you must then open the file with [[../DOS_openFile|DOS_openFile]].
 +
 +
It looks like most FAT file routines will clobber the OP registers due to calling FAT_getEntryInfo. Yes, all six of them.
  
 
== See Also ==
 
== See Also ==
 
* [[../FAT_getStartingCluster|FAT_getStartingCluster]] - Get starting cluster of specified directory
 
* [[../FAT_getStartingCluster|FAT_getStartingCluster]] - Get starting cluster of specified directory
 
* [[../DOS_openFile|DOS_openFile]] - Open file for reading and writing
 
* [[../DOS_openFile|DOS_openFile]] - Open file for reading and writing

Latest revision as of 17:17, 19 October 2008

Synopsis

Name: DOS_createFile

Minimum usb8x version: 0.10

Creates a new file in specified directory of size 0.

Inputs

  • BC points to the starting cluster of the directory to create file in (obtained with [[../FAT_getStartingCluster|FAT_getStartingCluster]])
  • HL points to an ASCIIZ string of the filename (ex. "test.txt")

Outputs

  • File is created with size 0
  • C set if problems

Destroys

  • AF, BC, DE, HL
  • OP registers

Notes

The file created date/time attributes are set according to the 84+/SE clock. Example code to create "readme.txt" in "test" directory:

ld hl,sDirectory
U_CALL FAT_getStartingCluster
push hl
pop bc ;BC contains starting cluster
ld hl,sFilename
U_CALL DOS_createFile
...
sFilename: DB "readme.txt",0
sDirectory: DB "/test",0

To read/write to this file, you must then open the file with [[../DOS_openFile|DOS_openFile]].

It looks like most FAT file routines will clobber the OP registers due to calling FAT_getEntryInfo. Yes, all six of them.

See Also

  • [[../FAT_getStartingCluster|FAT_getStartingCluster]] - Get starting cluster of specified directory
  • [[../DOS_openFile|DOS_openFile]] - Open file for reading and writing