Skip to content

Possible enhancement: allow SPIFFS.openDir to return false #1366

@andig

Description

@andig

Not a C expert, excuse me. While I can do

  File configFile = SPIFFS.open("/config.json", "w");
  if (!configFile) {
    Serial.println("Failed to open config file for writing");
    return false;
  }

I cannot do:

  Dir dir = SPIFFS.openDir(path);
  if (!dir) {
    Serial.print("Failed to open directory ");
    Serial.println(path);
  }

due to:

webserver.cpp:169: error: no match for 'operator!' (operand type is 'fs::Dir')
sketch\webserver.cpp:169:7: note: candidate is:
sketch\webserver.cpp:169:7: note: operator!(bool) <built-in>
sketch\webserver.cpp:169:7: note:   no known conversion for argument 1 from 'fs::Dir' to 'bool'

Would it make sense to allow conversion for false similar to open?

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