RuiViana

SPIFSS.ino

Jul 14th, 2020
1,327
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include "FS.h"
  3. //---------------------
  4. void setup()
  5. {
  6.   Serial.begin(115200);
  7.   Serial.println("");
  8.   Serial.println("Abrindo arquivos");
  9.   SPIFFS.begin();
  10.   //SPIFFS.format();
  11.   Dir dir = SPIFFS.openDir("/");
  12.   while (dir.next())
  13.   {
  14.     Serial.print(dir.fileName());
  15.     File f = dir.openFile("r");
  16.     Serial.print("   size:  ");
  17.     Serial.println(f.size());
  18.   }
  19.   Serial.println(" ");
  20.   //SPIFFS.remove("/f.txt");
  21.   //SPIFFS.remove("/g.txt");
  22.   delay(1500);
  23.  
  24.   File file2 = SPIFFS.open("/mesh.json","r");
  25.   if (!file2) {
  26.     Serial.println("Failed to open file for reading");
  27.     return;
  28.   }
  29.   Serial.println("File Content:");
  30.   while (file2.available()) {
  31.     Serial.write(file2.read());
  32.   }
  33.   file2.close();
  34. }
  35. //---------------------
  36. void loop()
  37. {
  38.   //  Dir dir = SPIFFS.openDir("/");
  39.   //  while (dir.next())
  40.   //  {
  41.   //    Serial.print(dir.fileName());
  42.   //    File f = dir.openFile("r");
  43.   //    Serial.print("   size:  ");
  44.   //    Serial.println(f.size());
  45.   //  }
  46.   //  Serial.println(" ");
  47.   //  //SPIFFS.remove("/f.txt");
  48.   //  //SPIFFS.remove("/g.txt");
  49.   //  delay(1500);
  50. }
RAW Paste Data