Hi, dear all:
I’m trying to use usbd_msc example(nrf 52840 DK/sdk 17.0.2 ) and written a string A (8 bytes) into a .txt file;
Now I want write the same file another string B at the end of A;
And,I know I should use f_lseek(&file, 8) to move the pointer to the end of content(string A) after I open the file next time ,and before write a new one;
It actually write successfully when I use f_lseek(&file, 8) and the content is "AB" now;
However, my question is :
How should I set the parameter to move the write pointer to the end of A instead of calculating the offset and make It more simple?
The following code is my code use f_lseek(),
ff_result = f_open(my_file, my_filename, FA_CREATE_ALWAYS | FA_WRITE); if (ff_result != FR_OK) { NRF_LOG_ERROR("\r\nUnable to open or create file: %u", ff_result); NRF_LOG_FLUSH(); return ff_result; } ff_result = f_lseek(my_file, 8); ff_result = f_write(&file, test, (UINT)strlen(test), &written); if (ff_result != FR_OK) { NRF_LOG_ERROR("\r\nUnable to write data: %u", ff_result); NRF_LOG_FLUSH(); return ff_result; }
Thank all kind of you for replying!