espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.41k stars 7.37k forks source link

SPIFFS free space #3712

Closed joseitor closed 4 years ago

joseitor commented 4 years ago

¿Is there any method that return the space available in SPIFFS? If not, I think it must be included, due it's important in cycle data systems, where for example you save in SPIFFS the data of the device every hour to have an file with the historical data, and wanted that once the SPIFFS memory get full it start to overwrite the oldest data to always have data of for example the last year.

lbernstone commented 4 years ago

https://github.com/espressif/arduino-esp32/blob/master/libraries/SPIFFS/src/SPIFFS.h#L28-L29

stale[bot] commented 4 years ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

duncanhames commented 4 years ago

For anyone who would like an explicit example:

int tBytes = SPIFFS.totalBytes(); int uBytes = SPIFFS.usedBytes();

rtek1000 commented 6 months ago

For anyone who would like an explicit example:

int tBytes = SPIFFS.totalBytes(); int uBytes = SPIFFS.usedBytes();

uint32_t SPIFFS_freeBytes = (SPIFFS.totalBytes() - SPIFFS.usedBytes());

Note: FatFS has a proper freeBytes()

FFat.freeBytes();

Ref.: https://mischianti.org/esp32-integrated-ffat-fat-exfat-filesystem-6/