From 73168d4657fb6e7e3ddff892a837568331f8f0be Mon Sep 17 00:00:00 2001 From: Marc MERLIN Date: Wed, 24 Apr 2019 12:45:59 -0700 Subject: [PATCH] Fixed ESP8266 SPIFFS support. Sadly the API is different from all other FS implementations :( --- FilenameFunctions.cpp | 6 +++++- GifAnim_Impl.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/FilenameFunctions.cpp b/FilenameFunctions.cpp index dd3e4db..2f122d3 100644 --- a/FilenameFunctions.cpp +++ b/FilenameFunctions.cpp @@ -173,7 +173,11 @@ int openGifFilenameByIndex(const char *directoryName, int index) { if (file) file.close(); // Attempt to open the file for reading - if (! (file = FSO.open(pathname)) ) die ("Error opening GIF file"); + #ifdef ESP8266 + if (! (file = SPIFFS.open(pathname, "r")) ) die ("Error opening GIF file"); + #else + if (! (file = FSO.open(pathname)) ) die ("Error opening GIF file"); + #endif return 0; } diff --git a/GifAnim_Impl.h b/GifAnim_Impl.h index 3e9bbd4..b32f731 100644 --- a/GifAnim_Impl.h +++ b/GifAnim_Impl.h @@ -143,7 +143,7 @@ void sav_setup() { Serial.println("Directory listing:"); #endif - // ESP32 SPIFFS uses special directory objects + // ESP8266 SPIFFS uses special directory objects #ifdef ESP8266 Dir dir = SPIFFS.openDir("/"); while (dir.next()) { @@ -182,7 +182,11 @@ void sav_setup() { bool sav_newgif(const char *pathname) { if (file) file.close(); Serial.print(pathname); + #ifdef ESP8266 + file = SPIFFS.open(pathname, "r"); + #else file = FSO.open(pathname); + #endif if (!file) { Serial.println(": Error opening GIF file"); return 1;