6#include "AudioTools/Disk/VFS.h"
26 LOGI(
"Initializing SPIFFS");
28 conf = {.base_path = mount_point,
29 .partition_label = NULL,
30 .max_files = max_files,
31 .format_if_mount_failed = format_if_mount_failed};
35 LOGI(
"Mounting filesystem at %s", mount_point);
36 esp_err_t ret = esp_vfs_spiffs_register(&conf);
39 if (ret == ESP_FAIL) {
40 LOGE(
"Failed to mount or format filesystem");
41 }
else if (ret == ESP_ERR_NOT_FOUND) {
42 LOGE(
"Failed to find SPIFFS partition");
44 LOGE(
"Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
49 LOGI(
"Performing SPIFFS_check().");
50 ret = esp_spiffs_check(conf.partition_label);
52 LOGE(
"SPIFFS_check() failed (%s)", esp_err_to_name(ret));
55 LOGI(
"SPIFFS_check() successful");
58 size_t total = 0, used = 0;
59 ret = esp_spiffs_info(conf.partition_label, &total, &used);
61 LOGE(
"Failed to get SPIFFS partition information (%s). Formatting...",
62 esp_err_to_name(ret));
66 LOGI(
"Partition size: total: %d, used: %d", total, used);
72 "Number of used bytes cannot be larger than total. Performing "
74 ret = esp_spiffs_check(conf.partition_label);
79 LOGE(
"SPIFFS_check() failed (%s)", esp_err_to_name(ret));
82 LOGI(
"SPIFFS_check() successful");
90 esp_vfs_spiffs_unregister(conf.partition_label);
91 LOGI(
"SPIFFS unmounted");
94 void setMaxFile(
int files) { max_files = files; }
95 void setFormatIfMountFailed(
bool format) { format_if_mount_failed = format; }
98 esp_vfs_spiffs_conf_t conf;
100 bool format_if_mount_failed =
true;