Skip to content

Commit cdad284

Browse files
vicnevicneigrr
authored andcommitted
Added a section on filesystem limitations due to issue esp8266#2858 (esp8266#2860)
1 parent a546d64 commit cdad284

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/filesystem.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: File System
44

55
## Table of Contents
66
* [Flash layout](#flash-layout)
7+
* [File system limitations](#file-system-limitations)
78
* [Uploading files to file system](#uploading-files-to-file-system)
89
* [File system object (SPIFFS)](#file-system-object-spiffs)
910
* [begin](#begin)
@@ -59,6 +60,22 @@ ESPDuino | 4M | 1M, 3M
5960
```c++
6061
#include "FS.h"
6162
```
63+
## File system limitations
64+
65+
The filesystem implementation for ESP8266 had to accomodate the constraints of the chip, among which its limited RAM. [SPIFFS](https://github.com/pellepl/spiffs) was selected because it is designed for small systems, but that comes at the cost of some simplifications and limitations.
66+
67+
First, behind the scenes, SPIFFS does not support directories, it just stores a "flat" list of files.
68+
But contrary to traditional filesystems, the slash character `'/'` is allowed in filenames, so the functions that deal with directory listing (e.g. `openDir("/website")`) basically just filter the filenames and keep the ones that start with the requested prefix (`/website/`).
69+
Practically speaking, that makes little difference though.
70+
71+
Second, there is a limit of 32 chars in total for filenames. One `'\0'` char is reserved for C string termination, so that leaves us with 31 usable characters.
72+
73+
Combined, that means it is advised to keep filenames short and not use deeply nested directories, as the full path of each file (including directories, `'/'` characters, base name, dot and extension) has to be 31 chars at a maximum.
74+
For example, the filename `/website/images/bird_thumbnail.jpg` is 34 chars and will cause some problems if used, for example in `exists()` or in case another file starts with the same first 31 characters.
75+
76+
**Warning**: That limit is easily reached and if ignored, problems might go unnoticed because no error message will appear at compilation nor runtime.
77+
78+
For more details on the internals of SPIFFS implementation, see the [SPIFFS readme file](https://github.com/esp8266/Arduino/blob/master/cores/esp8266/spiffs/README.md).
6279

6380
## Uploading files to file system
6481

0 commit comments

Comments
 (0)