How can I list only files that begin with "/LOG?" 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 += "&lt;a href=\"";
                            str += dir.fileName();
                            str += "\"&gt;";
                            str += dir.fileName();
                            str += "&lt;/a&gt;";
                            str += "    ";
                            str += dir.fileSize();
                            str += "&lt;br&gt;\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
Give a filename String to text...

String text = "/LOGsdfsdf";
if(text.startsWith("/LOG")){
//wee file begins with /LOG
}else{
// wops wrong file.
}


Look in here

https://www.arduino.cc/reference/en/language/variables/data-types/stringobject/

Method url startsWith("");

https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/startswith