Trying to list root directory of LittleFS; but only files beginging with "/LOG."
String str;
if (!LittleFS.begin())
{
Serial.println("LittleFS failed to mount !");
}
Dir dir = LittleFS.openDir("/");
while (dir.next())
{
if(strncmp(dir.fileName().c_str(), "/LOG", 4) == 0)
{
str += "<a href=\"";
str += dir.fileName();
str += "\">";
str += dir.fileName();
str += "</a>";
str += " ";
str += dir.fileSize();
str += "<br>\r\n";
}
}
client.print(str);
If I comment out "if(strncmp(dir.fileName().c_str(), "/LOG", 4) == 0)" and associated braces; all files list. Code with "if(strncmp(dir.fileName().c_str(), "/LOG", 4) == 0)" no files are listed.
How can I list only files that begin with "/LOG?"
William
/LOG?/used as path separator? In my world/is an invalid character for file or directory names. Listed file names in directory/should not contain/then./LOGstrncmpis case-sensitive!