spiffs icon indicating copy to clipboard operation
spiffs copied to clipboard

Error size when create empty file

Open tomzbj opened this issue 7 years ago • 1 comments

code like this:

void SPIFLASH_CMD_test1(char* fname)
{ 
    unsigned char buf[64];
    int ret;
    spiffs_file fd = SPIFFS_open(&g_fs, fname, SPIFFS_CREAT | SPIFFS_RDWR, 0); 
    SPIFFS_CHECK(fd);
    memset(buf, 0x00, 64);
    for(int i = 0; i < 512; i++) {
        ret = SPIFFS_write(&g_fs, fd, buf, 64);
        SPIFFS_CHECK(ret);
        ret = SPIFFS_fflush(&g_fs, fd); 
        SPIFFS_CHECK(ret);
    } 
    SPIFFS_close(&g_fs, fd);
    printf("OK\n");
}

when i created several files of size 4096, everything was ok. 8192 & 16384 were also ok. for 24576, one of the files was shorter: 24576 bb
24576 bb1
24512 bb2
for 32768, every file was shorter. 32627 cc
32435 cc1
31987 cc2

someone tell me what happened?

tomzbj avatar Jan 03 '18 08:01 tomzbj

ps. after i added SPIFFS_lseek(&g_fs, fd, i * 64, SPIFFS_SEEK_SET); before SPIFFS_write, the file sizes become correct.

tomzbj avatar Jan 03 '18 08:01 tomzbj