//------------------------------------------------------------------------------ bool FatFile::printModifyDateTime(print_t* pr) { dir_t dir; if (!dirEntry(&dir)) { DBG_FAIL_MACRO; goto fail; } printFatDate(pr, dir.lastWriteDate); pr->write(' '); printFatTime(pr, dir.lastWriteTime); return true; fail: return false; }
void listFiles(const char* path, SdBaseFile* file, Client* client, uint8_t flags) { // 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; if(strcmp(path, "/") != 0) { int idx = strrchr( path, '/' ) - path; char parent[idx + 1]; strncpy(parent, path, idx); parent[idx] = 0; client->print(F("<a href=\"")); client->print(F("http://")); client->print(Ethernet.localIP()); client->print(parent); client->println(F("\">[To Parent Directory]</a>\n")); } file->rewind(); while (file->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 modify date/time if requested if (flags & LS_DATE) { printFatDate(client, p.lastWriteDate); client->print(' '); printFatTime(client, p.lastWriteTime); } // print size if requested if (!DIR_IS_SUBDIR(&p) && (flags & LS_SIZE)) { client->print(' '); client->print(p.fileSize); } if (DIR_IS_SUBDIR(&p)) { client->print(F(" <dir>")); } // print file name with possible blank fill char name[13]; file->dirName(p, name); client->print(F(" <a href=\"")); client->print(F("http://")); client->print(Ethernet.localIP()); client->print(path); if(strcmp(path, "/") != 0) client->print('/'); client->print(name); client->print("\">"); client->print(name); client->println("</a>"); } }