1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

Add FS::format (#702)

This commit is contained in:
Ivan Grokhotkov
2015-08-31 10:24:30 +03:00
parent b8a6b71a1f
commit 041f971a8b
5 changed files with 63 additions and 5 deletions

View File

@ -4,7 +4,7 @@
void fail(const char* msg) {
Serial.println(msg);
while(true) {
while (true) {
yield();
}
}
@ -15,6 +15,21 @@ void setup() {
WiFi.mode(WIFI_OFF);
Serial.println("\n\nFS test\n");
{
if (!SPIFFS.format()) {
fail("format failed");
}
Dir root = SPIFFS.openDir("/");
int count = 0;
while (root.next()) {
++count;
}
if (count > 0) {
fail("some files left after format");
}
}
if (!SPIFFS.begin()) {
fail("SPIFFS init failed");
}
@ -63,15 +78,15 @@ void setup() {
{
Dir root = SPIFFS.openDir("/");
while (root.next()) {
String fileName = root.fileName();
File f = root.openFile("r");
Serial.printf("%s: %d\r\n", fileName.c_str(), f.size());
String fileName = root.fileName();
File f = root.openFile("r");
Serial.printf("%s: %d\r\n", fileName.c_str(), f.size());
}
}
{
Dir root = SPIFFS.openDir("/");
while(root.next()) {
while (root.next()) {
String fileName = root.fileName();
Serial.print("deleting ");
Serial.println(fileName);
@ -96,6 +111,20 @@ void setup() {
}
}
{
if (!SPIFFS.format()) {
fail("format failed");
}
Dir root = SPIFFS.openDir("/");
int count = 0;
while (root.next()) {
++count;
}
if (count > 0) {
fail("some files left after format");
}
}
Serial.println("success");
}