83Plus:Software:usb8x/Asm Interface/MSD/DOS deleteFileEntry
From WikiTI
Synopsis
Name: DOS_deleteFileEntry
Minimum usb8x version: 0.10
Deletes a file or folder along with its contents.
Inputs
- HL is the starting cluster of a directory (obtained with [[../FAT_getStartingCluster|FAT_getStartingCluster]])
- DE points to a filename (11-character format, obtained with [[../FAT_nameConvertTo11|FAT_nameConvertTo11]])
Outputs
- If file, it is deleted; if folder, it along with its contents are also deleted
- C set if problems
Destroys
- AF, BC, DE, HL
Notes
This works with both file and folder names.
Example code to delete "test.txt" in the "folder1" directory:
ld hl,sDirectory U_CALL FAT_getStartingCluster push hl ld hl,sFilename ld de,OP1 ;used as temporary space U_CALL FAT_nameConvertTo11 ex de,hl pop hl U_CALL DOS_deleteFileEntry ... sFilename: DB "test.txt",0 sDirectory: DB "/folder1",0
Since the filename ("test.txt") was known, hard-coding "TEST TXT
" would have been easier, but this is just an example.
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_getStartingCluster|FAT_getStartingCluster]] - Get starting cluster of specified directory
- [[../FAT_nameConvertTo11|FAT_nameConvertTo11]] - Convert ASCIIZ name to 11-character format