mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Fix SPIFFS.openDir("") (#2143)
* Update spiffs_api.cpp Fixes a bug where un-prefixed files are irretrievable with openDir(""). Described: https://github.com/esp8266/Arduino/issues/1818. * Update FS test cases
This commit is contained in:
parent
91720337d3
commit
b9dfe01903
@ -63,9 +63,9 @@ bool SPIFFSImpl::exists(const char* path)
|
||||
return rc == SPIFFS_OK;
|
||||
}
|
||||
|
||||
DirImplPtr SPIFFSImpl::openDir(const char* path)
|
||||
DirImplPtr SPIFFSImpl::openDir(const char* path)
|
||||
{
|
||||
if (!isSpiffsFilenameValid(path)) {
|
||||
if (strlen(path) > 0 && !isSpiffsFilenameValid(path)) {
|
||||
DEBUGV("SPIFFSImpl::openDir: invalid path=`%s` \r\n", path);
|
||||
return DirImplPtr();
|
||||
}
|
||||
|
@ -160,11 +160,10 @@ TEST_CASE("File names which are too long are rejected", "[fs]")
|
||||
REQUIRE(SPIFFS.open(longName_31, "w"));
|
||||
REQUIRE(SPIFFS.open(longName_31, "r"));
|
||||
REQUIRE(SPIFFS.exists(longName_31));
|
||||
auto files = listDir("");
|
||||
REQUIRE(files.empty());
|
||||
}
|
||||
|
||||
TEST_CASE("#1685 Duplicate files", "[fs][bugreport]") {
|
||||
TEST_CASE("#1685 Duplicate files", "[fs][bugreport]")
|
||||
{
|
||||
SPIFFS_MOCK_DECLARE(64, 8, 512);
|
||||
REQUIRE(SPIFFS.begin());
|
||||
createFile("/config", "some text");
|
||||
@ -173,3 +172,15 @@ TEST_CASE("#1685 Duplicate files", "[fs][bugreport]") {
|
||||
createFile("/data", "more text");
|
||||
listDir("/");
|
||||
}
|
||||
|
||||
TEST_CASE("#1819 Can list all files with openDir(\"\")", "[fs][bugreport]")
|
||||
{
|
||||
SPIFFS_MOCK_DECLARE(64, 8, 512);
|
||||
REQUIRE(SPIFFS.begin());
|
||||
createFile("/file1", "some text");
|
||||
createFile("/file2", "other text");
|
||||
createFile("file3", "more text");
|
||||
createFile("sorta-dir/file4", "\n");
|
||||
auto files = listDir("");
|
||||
REQUIRE(files.size() == 4);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user