Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By danbicks
#25993 Martin,

If a file is bigger than 1024, do I take it that you split it between files?

E.g: 2kb is split 1024 file 1 and then 976 bytes for file 2?

Dans
User avatar
By martinayotte
#25999
danbicks wrote:Martin,

If a file is bigger than 1024, do I take it that you split it between files?

E.g: 2kb is split 1024 file 1 and then 976 bytes for file 2?

Dans


No needs ... Take this new snippet instead :

Code: Select all    File f = SPIFFS.open("/Config.cfg", "r");
    if (!f) {
      client.println("Can't open Config.cfg !\r\n");         
    }
    else {
      char buf[1024];
      int siz = f.size();
      while(siz > 0) {
        size_t len = std::min((int)(sizeof(buf) - 1), siz);
        f.read((uint8_t *)buf, len);
        buf[len] = 0;
        client.println(buf);
        siz -= sizeof(buf) - 1;
      }
      f.close();


But beware that there is still the bug of SPIFFS where files bigger than 4096 is corrupting the filesystem parsing.
I will verify in few minutes if latest commits fix that ...

EDIT : The 4096 bug is still there... :(
User avatar
By danbicks
#26000 Martin, Awesome work.

You are pure genius :)

Loving this SPIFFS structure, amazing to have the ability to store files in flash on the fly.

Huge thanks buddy

Dans

Get the following error, what am I missing?

C:\ARDUINO\arduino-1.6.5\arduino-1.6.5-r2\portable\packages\esp8266\hardware\esp8266\1.6.5-1044-g170995a\cores\esp8266/Arduino.h:252:18: error: expected unqualified-id before '(' token
#define min(a,b) ((a)<(b)?(a):(b))
^
SPIFFS_MOD.ino:14:27: note: in expansion of macro 'min'
Error compiling.
Last edited by danbicks on Fri Aug 14, 2015 4:12 pm, edited 1 time in total.