Littlefs to delete the file

Hi all,

i am using Littlefs in nrf_connect_sdk,

how can i flush the contents of file

Regards

Tushar

Parents Reply
  • Hi Tushar

    There is no function for clearing a file directly. 

    Either you would have to use fs_write() to overwrite the existing data with 0's, or you could possibly use the fs_truncate() function twice. One time to reduce the size of the file to 0, and a second time to increase the size back to the original size (but now filled with 0's only). 

    As a side note, ignore my previous suggestion to use the lfs_file_sync() method, instead the fs_sync() method should be used for flushing the data buffers. 

    Best regards
    Torbjørn

Children
No Data
Related