DS_CAP_SYS_FS - denis-stepanov/esp-ds-system GitHub Wiki

DS_CAP_SYS_FS — File System

Description

This capability adds support for a file system. For this to work, you need to enable file system in Arduino settings (Tools -> Flash Size). The following fields are implemented:

Field Description Default Value
fs::FS& System::fs File System LittleFS

The library provides just a wrapper around the ESP8266 Arduino Core file system object, fs::FS. The file system used by default is LittleFS. It is possible to change to SPIFFS by defining DS_FS_TYPE macro to SPIFFS in MySystem.h. LittleFS was observed to make controller more responsive in general, and is a recommended choice. The file system API is the native one of LittleFS or SPIFFS (they are compatible).

Requires

Cooperates With

  • DS_CAP_WEBSERVER — if web server is enabled, a favicon file /favicon.png will be automatically probed and served if present. Also, the "System Information" page will report file system type, size and usage percentage.

Conflicts With

None.

Usage

MySystem.h:

#define DS_CAP_SYS_FS       // Enable file system
#define DS_FS_TYPE LittleFS // Optional; set to "SPIFFS" if needed

#include "System.h"         // System global definitions

sketch.ino:

#include "MySystem.h"

using namespace ds;

void setup() {
    System::begin();

    File my_file = System::fs.open("/hello.txt", "w");
    if(!my_file)
       return;
    my_file.println("Hello, world!");
    my_file.close();
}

void loop() {
}

Mandatory Calls

System::begin() Required
System::update() Not required

Examples

Bugs

None.

Availability

Version 1.0 or later. File system selection via DS_FS_TYPE macro is available from version 1.1.

See Also

None.

⚠️ **GitHub.com Fallback** ⚠️