From d16a71aa7c625b0bca7d1834f530824ef111afea Mon Sep 17 00:00:00 2001 From: seclorum Date: Fri, 25 Mar 2016 20:14:38 +0100 Subject: [PATCH] Update spiffs_api.cpp Fixes a bug where un-prefixed files are irretrievable with openDir(""). Described: https://github.com/esp8266/Arduino/issues/1818. --- cores/esp8266/spiffs_api.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cores/esp8266/spiffs_api.cpp b/cores/esp8266/spiffs_api.cpp index 5420174a94..f1c94791d4 100644 --- a/cores/esp8266/spiffs_api.cpp +++ b/cores/esp8266/spiffs_api.cpp @@ -63,12 +63,14 @@ bool SPIFFSImpl::exists(const char* path) return rc == SPIFFS_OK; } -DirImplPtr SPIFFSImpl::openDir(const char* path) -{ - if (!isSpiffsFilenameValid(path)) { - DEBUGV("SPIFFSImpl::openDir: invalid path=`%s` \r\n", path); - return DirImplPtr(); +DirImplPtr SPIFFSImpl::openDir(const char* path) { + if (strlen(path) > 0) { + if (!isSpiffsFilenameValid(path)) { + DEBUGV("SPIFFSImpl::openDir: invalid path=`%s` \r\n", path); + return DirImplPtr(); + } } + spiffs_DIR dir; spiffs_DIR* result = SPIFFS_opendir(&_fs, path, &dir); if (!result) {