lorol / LITTLEFS

LittleFS library for arduino-esp32
GNU General Public License v2.0
168 stars 68 forks source link

Version 1.0.6. no matching function for call to 'LITTLEFSImpl::open(const char*&, const char [2])' #69

Open VolodymyrBaisa opened 3 months ago

VolodymyrBaisa commented 3 months ago

Hi All. I got issue when I start using 1.0.6 version. No issue with 1.0.5 version. Error message:

C:\Users\user\OneDrive\Documents\Arduino\libraries\LittleFS_esp32\src\LITTLEFS.cpp: In member function 'virtual bool LITTLEFSImpl::exists(const char)': C:\Users\user\OneDrive\Documents\Arduino\libraries\LittleFS_esp32\src\LITTLEFS.cpp:44:18: error: no matching function for call to 'LITTLEFSImpl::open(const char&, const char [2])' 44 | File f = open(path, "r"); | ~~^~~~~ In file included from C:\Users\user\OneDrive\Documents\Arduino\libraries\LittleFS_esp32\src\LITTLEFS.cpp:17: C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\libraries\FS\src/vfs_api.h:37:15: note: candidate: 'virtual fs::FileImplPtr VFSImpl::open(const char, const char, bool)' 37 | FileImplPtr open(const char path, const char mode, const bool create) override; | ^~~~ C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\libraries\FS\src/vfs_api.h:37:15: note: candidate expects 3 arguments, 2 provided

exit status 1

Compilation error: exit status 1

My code:

#include "Stream.h"
#include "storage.h" 

Storage::Storage(){}

bool Storage::mount() {
  if (!LITTLEFS.begin(FORMAT_LITTLEFS_IF_FAILED)) {
        Serial.println("LITTLEFS Mount Failed");
        return false;
    }
    return true;
}

bool Storage::readWifiConfig(String &ssid, String &password) {
    File file = LITTLEFS.open(wifiConfigFile, FILE_READ, false);
    if (!file) {
        Serial.println("Failed to open WiFi config file");
        return false;
    }

    // Allocate a temporary JsonDocument
    StaticJsonDocument<256> doc;

    // Deserialize the JSON document
    DeserializationError error = deserializeJson(doc, file);
    if (error) {
        Serial.print(F("deserializeJson() failed: "));
        Serial.println(error.f_str());
        file.close();
        return false;
    }

    ssid = doc["ssid"].as<String>();
    password = doc["password"].as<String>();

    file.close();
    return true;
}

Please advice.

lesept777 commented 2 months ago

I had the same problem and corrected it by changing the library File f = open(path, "r", false); in file LITTLEFS.cpp line 44 (add argument false)