Page 1 of 1

How to append file using spiffs??

Posted: Fri Feb 15, 2019 9:46 am
by Ritu21
Hi Team,

I am trying to append a file in run time using spiffs. Attaching the code in which I have written "Hello World!" 10 times but it has printed only 1 time. Below is the output of my code.

I (282) spiffs example: Initializing SPIFFS
I (372) spiffs example: Partition size: total: 896321, used: 1004
I (382) spiffs example: Opening file
Appending file
Appending file
Appending file
Appending file
Appending file
Appending file
Appending file
Appending file
Appending file
Appending file
I (432) spiffs example: File written
I (432) spiffs example: Reading file
I (442) spiffs example: Read from file: 'Hello World!'
I (442) spiffs example: SPIFFS unmounted

Please suggest how to append string in a file using spiffs in run time??

Thanks
R.

Re: How to append file using spiffs??

Posted: Fri Feb 15, 2019 11:33 am
by ESP_Sprite
fgets only gets one line at a time, and you only call it once, so your code will only ever show the first line in the file, even if there are more. You probably meant to use something like fread instead.