You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/filesystem.md
+17Lines changed: 17 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@ title: File System
4
4
5
5
## Table of Contents
6
6
*[Flash layout](#flash-layout)
7
+
*[File system limitations](#file-system-limitations)
7
8
*[Uploading files to file system](#uploading-files-to-file-system)
8
9
*[File system object (SPIFFS)](#file-system-object-spiffs)
9
10
*[begin](#begin)
@@ -59,6 +60,22 @@ ESPDuino | 4M | 1M, 3M
59
60
```c++
60
61
#include"FS.h"
61
62
```
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).
0 commit comments