83Plus:Software:usb8x/Asm Interface/MSD/DOS countFilesInDir
From WikiTI
Synopsis
Name: DOS_countFilesInDir
Minimum usb8x version: 0.10
Gets number of files in specified directory.
Inputs
- HL points to an ASCIIZ string of the directory path
Outputs
- BC is number of entries
- C set if problems
Destroys
- AF, BC, DE, HL
Notes
If the root directory is checked, no further action is necessary. However, if you use this function on a subdirectory, it will count the "." and ".." directory entries as folders. These are pointers to the current and previous directory used by FAT16. To you, this simply means you need to subtract two when dealing with a subdirectory.
Example code to count number of files/folders in the "test" directory, which is in the root directory:
ld hl,sDirectory U_CALL DOS_countFilesInDir dec bc dec bc ;BC contains number of files/directories ... sDirectory: DB "/test",0
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