Version 3.0.0 brings dynamic backend switching and unified file-and-folder management with streaming UI feedback, plus a companion transport layer that handles cross-filesystem copy/move and conflict resolution seamlessly.
- Dynamic FS binding (SPIFFS, LittleFS, SD, RAMDisk…)
- FS switching at runtime:
changeFS()&getFS() - Unified C-string API (no
Stringoverhead) for:- file open/read/write/append
- directory list/create/format/remove
- existence checks & size queries (files & folders)
- Advanced utilities:
formatDir()— wipe a folder’s contentsreadLines()&cursorLines()— stream lines with UI callbacks- I/O benchmark
testIO()for read/write throughput - FS format
format()for SPIFFS/LittleFS
- Optional debug logs via
#define Debug_Serial_Memory
- Inherits
memoryAccess_t— full FS API - File/Folder copy with optional “cut” (move) semantics
- Origin/Goal setup helpers: define source/destination FS, paths, and cargo
- Unique name generation to avoid overwrites
- State reset & validation (
isOrigin(),isGoal())
You can install via PlatformIO or manually in Arduino IDE:
[env:esp32dev]
platform = espressif32
framework = arduino
lib_deps =
milad-nikpendar/initMemory @ ^3.0.0- Clone this repository into your Arduino
libraries/folder:git clone https://github.com/milad-nikpendar/initMemory.git \ ~/Arduino/libraries/initMemory - Restart the Arduino IDE.
- Include headers in your sketch:
#include <initMemory.h> #include <initTransport.h>
| Method | Description |
|---|---|
memoryAccess_t(fs::FS *backend) |
Constructor: bind to SPIFFS, SD, LittleFS… |
changeFS(fs::FS *backend) |
Switch active FS at runtime |
File open(const char* path) |
Open a file for read/write |
size(File file) |
Get size of file or directory (recursive) |
exists(const char* path) |
File/directory existence check |
listDir(const char* dir, uint8_t lv) |
Recursive directory listing |
createDir(const char* path) |
Create a directory |
formatDir(const char* dir) |
Wipe all contents of a directory |
removeDir(const char* path) |
Remove directory and contents |
read(const char* path) |
Read entire file into String |
readLines(File &f, int n, bool end) |
Read up to n lines from file |
write(const char* p, const char* msg) |
Overwrite or create file |
append(const char* p, const char* msg) |
Append to file |
cursorLines(File &f, uint32_t pos, int mv) |
Seek by lines with UI refresh |
rename(const char* o, const char* n) |
Rename file |
remove(const char* path) |
Delete file |
testIO(const char* path) |
Benchmark read/write speed |
set_refresh_ui(void (*fn)()) |
UI refresh callback during long ops |
format() |
Format SPIFFS/LittleFS |
| Method | Description |
|---|---|
transportAccess_t(fs::FS *backend) |
Constructor: bind source FS |
origin_setup(fs::FS*, std::string p, std::string cargo, bool) |
Define source path/cargo (file or dir) |
goal_setup(fs::FS*, std::string path) |
Define destination FS & path |
set_transport_cut(bool cut) |
Enable “cut” (move) instead of copy |
copyFile() / copyFolder() |
Perform file or folder transfer |
isOrigin() / isGoal() |
Validate origin/goal match |
resert_transport() |
Reset internal state |
- FS_Explorer (SPIFFS directory & file demo)
- SD_BenchLogger (SD logging + benchmark)
- TransportDemo (copy/move files between SPIFFS & SD)
Find them under the /examples folder, each in its own subdirectory.
- Class rename:
- v2:
memoryAccess_t - v3: still
memoryAccess_tbut expanded—no constructor change.
- v2:
- FS binding:
- v2:
memoryAccess_t mem(&SPIFFS); - v3: same, plus
mem.changeFS(&SD);to swap FS.
- v2:
- New methods:
formatDir(),size(),format(), andset_refresh_ui(). - Transport: move file operations into
transportAccess_t—no more manual copy loops.
- Board: ESP32 (DevKitC or similar)
- Framework: Arduino
- Libraries:
- FS (SPIFFS/LittleFS)
- SD (for SD-card support)
This project is licensed under the MIT License – see LICENSE for details.
Milad Nikpendar
GitHub: milad-nikpendar/initMemory
Email: milad82nikpendar@gmail.com