SPIFFSIniFile-library multiple compiler-errors help appreciated

Hi is there any kind of quality-checking before a library is implemented into the arduino-IDE?

I tried the SPIFFSINIFile-library. The example-code on GitHub - yurilopes/SPIFFSIniFile: ESP8226 and ESP32 library to parse ini files

does not compile

best regards

Stefan

No, Arduino doesn't do any quality checking of 3rd party libraries. The closest they come is rejecting any libraries that contain symlinks or executables, since these might be used for malicious purposes.

There are thousands of 3rd party libraries in the Arduino Library Manager index and it would be very difficult to do any completely automated testing of these libraries, since many only work on a specific board.

The responsibility is on the 3rd party library developer. They should have automated testing to help ensure quality of their development work and contributions, then thoroughly test the library before making a release.

If you post the error you are having, people here on the forum may be able to provide assistance.

Hello pert,

thank you for moving the question to the right forum.
I was unsecure where to post it.

OK I'm using Arduino IDE 1.8.12
I have installed the IniFile-file library (which supports SD-cart inside)
And I have installed the SPIFFSIniFile-library
If I do a plain copy&paste of the sourcecode given in the example

/*
  Remeber to upload the data directory to your board!
  
  Serial baud rate in this example is 9600
*/

#include "FS.h"

#include <SPIFFSIniFile.h>

void printErrorMessage(uint8_t e, bool eol = true)
{
  switch (e) {
  case SPIFFSIniFile::errorNoError:
    Serial.print("no error");
    break;
  case SPIFFSIniFile::errorFileNotFound:
    Serial.print("file not found");
    break;
  case SPIFFSIniFile::errorFileNotOpen:
    Serial.print("file not open");
    break;
  case SPIFFSIniFile::errorBufferTooSmall:
    Serial.print("buffer too small");
    break;
  case SPIFFSIniFile::errorSeekError:
    Serial.print("seek error");
    break;
  case SPIFFSIniFile::errorSectionNotFound:
    Serial.print("section not found");
    break;
  case SPIFFSIniFile::errorKeyNotFound:
    Serial.print("key not found");
    break;
  case SPIFFSIniFile::errorEndOfFile:
    Serial.print("end of file");
    break;
  case SPIFFSIniFile::errorUnknownError:
    Serial.print("unknown error");
    break;
  default:
    Serial.print("unknown error value");
    break;
  }
  if (eol)
    Serial.println();
}

void setup()
{
  
  const size_t bufferLen = 80;
  char buffer[bufferLen];

  const char *filename = "/net.ini";
  Serial.begin(9600);
  
  //Mount the SPIFFS  
  if (!SPIFFS.begin())
    while (1)
      Serial.println("SPIFFS.begin() failed");
  
  SPIFFSIniFile ini(filename);
  if (!ini.open()) {
    Serial.print("Ini file ");
    Serial.print(filename);
    Serial.println(" does not exist");
    // Cannot do anything else
    while (1)
      ;
  }
  Serial.println("Ini file exists");

  // Check the file is valid. This can be used to warn if any lines
  // are longer than the buffer.
  if (!ini.validate(buffer, bufferLen)) {
    Serial.print("ini file ");
    Serial.print(ini.getFilename());
    Serial.print(" not valid: ");
    printErrorMessage(ini.getError());
    // Cannot do anything else
    while (1)
      ;
  }
  
  // Fetch a value from a key which is present
  if (ini.getValue("network", "mac", buffer, bufferLen)) {
    Serial.print("section 'network' has an entry 'mac' with value ");
    Serial.println(buffer);
  }
  else {
    Serial.print("Could not read 'mac' from section 'network', error was ");
    printErrorMessage(ini.getError());
  }
  
  // Try fetching a value from a missing key (but section is present)
  if (ini.getValue("network", "nosuchkey", buffer, bufferLen)) {
    Serial.print("section 'network' has an entry 'nosuchkey' with value ");
    Serial.println(buffer);
  }
  else {
    Serial.print("Could not read 'nosuchkey' from section 'network', error was ");
    printErrorMessage(ini.getError());
  }
  
  // Try fetching a key from a section which is not present
  if (ini.getValue("nosuchsection", "nosuchkey", buffer, bufferLen)) {
    Serial.print("section 'nosuchsection' has an entry 'nosuchkey' with value ");
    Serial.println(buffer);
  }
  else {
    Serial.print("Could not read 'nosuchkey' from section 'nosuchsection', error was ");
    printErrorMessage(ini.getError());
  }

  // Fetch a boolean value
  bool allowPut; // variable where result will be stored
  bool found = ini.getValue("/upload", "allow put", buffer, bufferLen, allowPut);
  if (found) {
    Serial.print("The value of 'allow put' in section '/upload' is ");
    // Print value, converting boolean to a string
    Serial.println(allowPut ? "TRUE" : "FALSE");
  }
  else {
    Serial.print("Could not get the value of 'allow put' in section '/upload': ");
    printErrorMessage(ini.getError());
  }
}


void loop()
{


}

I get these error-messages:
In file included from C:\Users\Stefan\Documents\Arduino\Original-SPIFFS-Ini-Demo\Original-SPIFFS-Ini-Demo.ino:9:0:

C:\Users\Stefan\Documents\Arduino\libraries\SPIFFSIniFile\src/SPIFFSIniFile.h:31:51: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
SPIFFSIniFile(const char* filename, char* mode = "r",

C:\Users\Stefan\Documents\Arduino\libraries\SPIFFSIniFile\src/SPIFFSIniFile.h: In member function 'bool SPIFFSIniFile::open()':

C:\Users\Stefan\Documents\Arduino\libraries\SPIFFSIniFile\src/SPIFFSIniFile.h:130:10: error: 'SPIFFS' was not declared in this scope
_file = SPIFFS.open(_filename, _mode);

C:\Users\Stefan\Documents\Arduino\Original-SPIFFS-Ini-Demo\Original-SPIFFS-Ini-Demo.ino: In function 'void setup()':
Original-SPIFFS-Ini-Demo:59:8: error: 'SPIFFS' was not declared in this scope
if (!SPIFFS.begin())

C:\Users\Stefan\Documents\Arduino\Original-SPIFFS-Ini-Demo\Original-SPIFFS-Ini-Demo.ino:63:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
SPIFFSIniFile ini(filename);

Bibliothek FS in Version 1.0 im Ordner: C:\Users\Stefan\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS wird verwendet
Bibliothek SPIFFSIniFile in Version 1.0.0 im Ordner: C:\Users\Stefan\Documents\Arduino\libraries\SPIFFSIniFile wird verwendet
exit status 1
'SPIFFS' was not declared in this scope

guys what the hell did the author tweak and screw up his Arduino-IDE to make such a code compiling?
OK any help would be much appreciciated.

best regards

Stefan

OK as nobody is answering I developed another solution:

Found the StackString-library and installed this library through the library-manager of the Arduino-IDE.
strings in StackString do not eat up all RAM over time like standard strings do.
You have to write a bit more of code to use it but IMHO the security of not violating the values of other variables like standard strings CAN do ist worth it.

The StackString-library offers functions like .find and .substring which make parsing a string a breeze.

Then I wrote my own little KISS ini-parser. I don't need ini-Files with sections thouw it would be pretty easy to add ini-filesections to the code (you could use .find("[Mysectionname]") or .startsWith("[Mysectionname]") for this.

Here is a demo-Code that shows the use of the StackString-Library

#include <StackString.hpp> 
using namespace Stack;  // it is very important to have this line of code. Otherwise the code won't compile

StackString<50> myString = StackString<50>("Hello, World!");

void setup() 
{ 
  Serial.begin(115200); 
  Serial.println();
  Serial.println();
  Serial.println(myString.c_str());

  myString.prepend("Everybody say: ");
  Serial.println(myString.c_str());

  myString.append(" How are you doing?");
  Serial.println(myString.c_str());
  Serial.println();

  StackString<100> myString1 = StackString<100>("http://arjenstens.com");
  Serial.println(                                 "012345678901234567890");
  Serial.println(                                 "|           |   |    ");
  Serial.println( myString1.c_str()  );
  Serial.print("first occurence of letter 's' is position ");
  Serial.println( myString1.find("s")  );   
  Serial.print("second occurence of letter 's' is position ");
  Serial.println( myString1.find("s", 2) ); 
  Serial.println();

                                             //0123456789012345
  StackString<64>  MyIniStr = StackString<64>("123456789=abcde");
  StackString<64>  MyIniIdentifier = StackString<64>("");
  StackString<64>  MyIniValueStr   = StackString<64>("");

  Serial.println("0123456789012345");
  Serial.println("|        |    |");
  Serial.println("123456789=abcde");
  int PosOfEqualSign = MyIniStr.find("=");
  Serial.print("PosOfEqualSign:");
  Serial.println(PosOfEqualSign);

  int Len            = MyIniStr.length();
  Serial.print("Len:");
  Serial.println(Len);

  
  MyIniIdentifier = MyIniStr.substring(0,PosOfEqualSign);
  //MyIniIdentifier = MyIniStr.substring(0,9);
  Serial.print("MyIniIdentifier =#");
  Serial.print(MyIniIdentifier.c_str());
  Serial.println("#");

  MyIniValueStr   = MyIniStr.substring(PosOfEqualSign + 1, (Len - PosOfEqualSign - 1));
  Serial.print("MyIniValueStr =#");
  Serial.print(MyIniValueStr.c_str());
  Serial.println("#");
  Serial.println();

  StackString<10> myNumberAsString = StackString<10>("1133");
  int MyNumberAsInteger = myNumberAsString.toInt() * 2;
  Serial.print("myNumberAsString =#");
  Serial.print(myNumberAsString.c_str());
  Serial.println("#");

  Serial.print("MyNumberAsInteger = myNumberAsString.toInt() * 2=");
  Serial.println(MyNumberAsInteger);
  Serial.println();

  Serial.println( myString1.c_str()  );
  Serial.print("does the string above start with 'https'? ");
  if (!myString1.startsWith ("https"))
    { 
    Serial.println("no !");
    Serial.println();
    }

  Serial.print("does the string above start with 'http'? ");
  if (myString1.startsWith ("http"))
    { 
    Serial.println("YES !");
    Serial.println();
    }
}

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

}

best

StackString-Demo-example.ino (2.78 KB)