-->
Page 1 of 1

read file from SPIFFS return null

PostPosted: Sat Dec 17, 2022 8:51 am
by steeve
hello, i am trying to read a file from the spiffs image i have buil├Čt and uploaded to esp.
Whatever file i try to open, when i read it i get null.

Code: Select all    struct stat st;
    stat("/spiffs/index.html", &st);
    ESP_LOGI(TAG, "index.html size is %ld", st.st_size);

    ESP_LOGI(TAG, "Reading file");
    FILE* f = fopen("/spiffs/index.html", "r");
    char line[32];
    fgets(line, sizeof(line), f);
    ESP_LOGI(TAG, "Read from file: '%s'", line);
    fclose(f);


this code produces the following log:
Code: Select allI (435) wifi softAP: index.html size is 546
I (437) wifi softAP: Reading file
I (444) wifi softAP: Read from file: ''



i have generated the image with mkspiffs. i also have tryed recompiling mkspiffs with SPIFFS_USE_MAGIC_LENGTH: 4 instead of 1 but nothing changes.
Any ideas??