This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

fds_file_delete delete all files with given id?

Hi

I'm trying to delete all files with a given file id. Will fds_file_delete() delete all files with a given file id, or just the first one it finds?

thanks

SDK14

Parents
  • According to the documentation...

    ret_code_t fds_file_delete	(	uint16_t 	file_id	)
    
    Function for deleting all records in a file.
    
    This function deletes a file, including all its records. Deleted records cannot be located using fds_record_find, fds_record_find_by_key, or fds_record_find_in_file. Additionally, they can no longer be opened using fds_record_open.
    
    Note that deleting records does not free the space they occupy in flash memory. To reclaim flash space used by deleted records, call fds_gc to run garbage collection.
    
    This function is asynchronous. Completion is reported through an event that is sent to the registered event handler function.
    
  • The documentation is not ambiguous at all. It is crystal clear. You do not need to iterate through fds_record_find() as you are deleting the entire file, not just one record of many with the same FILE_ID & REC_ID as in the case of fds_record_delete(). If you notice the fds_record_delete() you need to pass the &record_desc and the most efficient way to get this is to perform a search beforehand. For fds_file_delete(), you just give it the FILE_ID, and viola all records with that FILE_ID are marked deleted until gc called and then truly deleted thereafter.

Reply
  • The documentation is not ambiguous at all. It is crystal clear. You do not need to iterate through fds_record_find() as you are deleting the entire file, not just one record of many with the same FILE_ID & REC_ID as in the case of fds_record_delete(). If you notice the fds_record_delete() you need to pass the &record_desc and the most efficient way to get this is to perform a search beforehand. For fds_file_delete(), you just give it the FILE_ID, and viola all records with that FILE_ID are marked deleted until gc called and then truly deleted thereafter.

Children
No Data
Related