Skip to content

SPIFFS can open nonexisting file for reading? #681

@ghost

Description

Device: ESP32-WROOM32
IDE: Arduino 1.8.4
OS: Mac OS

It seems like SPIFFS can open (read) a file, that is not existing..


#include "FS.h"
#include "SPIFFS.h"


void setup() {

 Serial.begin(9600);
 delay(1000);
 
 Serial.println("Mounting FS...");
  
  while (!SPIFFS.begin(true))
  {
    Serial.println("Failed to mount file system, formatted");
    delay(5000);
  }  

  SPIFFS.remove("/somefile.txt");
  delay(1000);
  
  File configFile = SPIFFS.open("/somefile.txt","r");
  
  if (!configFile) 
  {
    Serial.println("Failed to open config file");
  }
  else
  {
    Serial.println("File Opened");
  }

}

void loop() {
  // put your main code here, to run repeatedly:

}

Output:

Mounting FS...
File Opened

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions