1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-06 05:21:22 +03:00

Merge remote-tracking branch 'remotes/esp8266/master'

This commit is contained in:
Markus Sattler 2015-12-05 17:19:05 +01:00
commit 0173749ef2
2 changed files with 20 additions and 1 deletions

View File

@ -410,6 +410,17 @@ protected:
FileImplPtr SPIFFSImpl::open(const char* path, OpenMode openMode, AccessMode accessMode) {
int mode = getSpiffsMode(openMode, accessMode);
int fd = SPIFFS_open(&_fs, path, mode, 0);
if (fd < 0 && _fs.err_code == SPIFFS_ERR_DELETED && (openMode & OM_CREATE)) {
DEBUGV("SPIFFSImpl::open: fd=%d path=`%s` openMode=%d accessMode=%d err=%d, trying to remove\r\n",
fd, path, openMode, accessMode, _fs.err_code);
auto rc = SPIFFS_remove(&_fs, path);
if (rc != SPIFFS_OK) {
DEBUGV("SPIFFSImpl::open: SPIFFS_ERR_DELETED, but failed to remove path=`%s` openMode=%d accessMode=%d err=%d\r\n",
path, openMode, accessMode, _fs.err_code);
return FileImplPtr();
}
fd = SPIFFS_open(&_fs, path, mode, 0);
}
if (fd < 0) {
DEBUGV("SPIFFSImpl::open: fd=%d path=`%s` openMode=%d accessMode=%d err=%d\r\n",
fd, path, openMode, accessMode, _fs.err_code);

View File

@ -139,7 +139,15 @@ void setup() {
fail("some files left after format");
}
}
{
File tmp = SPIFFS.open("/tmp.txt", "w");
}
{
File tmp = SPIFFS.open("/tmp.txt", "w");
if (!tmp) {
fail("failed to re-open empty file");
}
}
Serial.println("success");
}