char ListFiles(Adafruit_CC3000_ClientRef client, uint8_t flags, SdFile dir)
{
// This code is just copied from SdFile.cpp in the SDFat library
// and tweaked to print to the client output in html!
dir_t p;
dir.rewind();
client.println("<ul>");
while (dir.readDir(&p) > 0)
{
// done if past last used entry
if (p.name[0] == DIR_NAME_FREE) break;
// skip deleted entry and entries for . and ..
if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.') continue;
// only list subdirectories and files
if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
// print any indent spaces
client.print("<li><a href=\"");
for (uint8_t i = 0; i < 11; i++)
{
if (p.name[i] == ' ') continue;
if (i == 8)
{
client.print('.');
}
client.print((char)p.name[i]);
}
if (DIR_IS_SUBDIR(&p))
{
client.print('/');
}
client.print("\">");
// print file name with possible blank fill
for (uint8_t i = 0; i < 11; i++)
{
if (p.name[i] == ' ') continue;
if (i == 8)
{
client.print('.');
}
client.print((char)p.name[i]);
}
if (DIR_IS_SUBDIR(&p))
{
client.print('/');
}
client.print("</a>");
// print modify date/time if requested
if (flags & LS_DATE)
{
dir.printFatDate(p.lastWriteDate);
client.print(' ');
dir.printFatTime(p.lastWriteTime);
}
// print size if requested
if (!DIR_IS_SUBDIR(&p) && (flags & LS_SIZE))
{
client.print(' ');
client.print(p.fileSize);
}
client.println("</li>");
}
client.println("</ul>");
}This is what listFiles function looks like in client browser:
Help in moving listFiles function to the SPIFFS of the ESP8266, please.
All help, most appreciated.
William