83Plus:Software:usb8x/Asm Interface/MSD/DOS getFileSize

From WikiTI
Revision as of 11:13, 17 August 2006 by Brandonw (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Synopsis

Name: DOS_getFileSize

Minimum usb8x version: 0.10

Gets file size for a file or folder (though a folder's size is always zero).

Inputs

  • HL points to the directory entry for a specified file/folder

Outputs

  • DEHL is 32-bit size of file
  • C set if problems

Destroys

  • AF, BC, DE, HL

Notes

This works with both file and folder names, though it is pretty much worthless for folder names. Example code to get file size of "test.txt" in the root directory:

ld hl,sFilename
U_CALL FAT_lookupPath
U_CALL DOS_getFileSize
;DEHL is 32-bit size of file (ex. DE = 00 and HL = 15h means file size is 21 bytes)
...
sFilename: DB "/test.txt",0

This example takes advantage of the fact that [[../FAT_lookupPath|FAT_lookupPath]] will return the directory entry for a file as well as whether it exists. If you are writing an application, you must copy the strings you use to RAM first, or else usb8x will not be able to see them.

See Also

  • [[../FAT_lookupPath|FAT_lookupPath]] - Find whether specified file/directory exists
  • [[../DOS_getDirEntry|DOS_getDirEntry]] - Get directory entry for file in specified directory