How to append file using spiffs??

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

How to append file using spiffs??

Postby Ritu21 » Fri Feb 15, 2019 9:46 am

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.
Attachments
spiffs_example_main.c
(2.93 KiB) Downloaded 677 times

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: How to append file using spiffs??

Postby ESP_Sprite » Fri Feb 15, 2019 11:33 am

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.

Who is online

Users browsing this forum: No registered users and 114 guests