Creating, Deleting, and Renaming Files
|Top Previous Next|
You can't really do anything useful with the flash disk unless you create at least one file. The fd.create method is used for this. The string you supply as an argument must include a file name and may also contain the attributes. Some examples:
Naturally, each file on the flash disk must have a unique name, or the 5- PL_FD_STATUS_DUPLICATE_NAME error will be generated. Every existing file always has at least one data sector allocated to it. This is how the 7- PL_FD_STATUS_DATA_FULL error may be generated when you are creating a new file. Finally, the total number of files stored on the flash disk is limited to what you defined when formatting your disk. This maximum can be checked through the fd.maxstoredfiles R/O property. Try to exceed this number and you will get the 6- PL_FD_STATUS_FILE_TABLE_FULL error code. Current file count can be obtained through fd.getnumfiles.
To delete a file, use the fd.delete method:
The file you are deleting must, of course, still exist, or you will get the 9- PL_FD_STATUS_NOT_FOUND error. You can also rename a file using the fd.rename method (this will preserve file attributes). It is OK to delete or rename a file which is currently opened.