Skip to content

SD file system, request to add file.CreationDate (). #6992

Closed
@NicoZuid

Description

@NicoZuid

In version 2.5.0 was a directory of utilities included.
A few years ago I found an example on the internet that made it possible to make the creation date of an SD file visible.
In version 2.6.3, Arduino SdFat Library by William Greiman is still used. (2009)

..\2.6.3\librarie\ESP8266\SdFat\src\Fatlib\FatFile.cpp

This file contains code to process the SD file creation date / time.
Is it possible to add this to the options of the SDFS library?

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;
File sdFile;

SdFile::dateTimeCallback(dateTime);                  // set callback for SD file date


//=============================================================================
// this function is called by SD if it wants to know the time
void dateTime(uint16_t* date, uint16_t* time)
{
  // return date using FAT_DATE macro to format fields
  *date = FAT_DATE(year(), month(), day());
  // return time using FAT_TIME macro to format fields
  *time = FAT_TIME(hour(), minute(), second());
}
//=============================================================================

void handleSDfilelist() {
  const char* br = "<br>\n";
  message = "<!DOCTYPE html> <html> <head> <title>SD files</title></head> <body>";
  message += "<table style='font-size:14px'><tr><td><b>SD files</b></td></tr>";

root.openRoot(volume);
  dir_t p;
  root.rewind();
  delay(1);  //yield();   //201909 probleem WDT restart oplossen (?)
  while (root.readDir(p) > 0) {
    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;
    message += "<tr><td><a href=\"../";
    for (uint8_t i = 0; i < 11; i++) {
      if (p.name[i] == ' ') continue;
      if (i == 8) {
        message += ".";
      }
      message +=  (char)p.name[i];
    }
    message += "\">";

    // print file name with possible blank fill
    for (uint8_t i = 0; i < 11; i++) {
      if (p.name[i] == ' ') continue;
      if (i == 8) {
        message += ".";
      }
      message += (char)p.name[i] ;
    }
    message += "</a></td><td>";
    message += p.fileSize;
    message += F("</td>");
    SDdatum(p.creationDate, p.creationTime);
    message += ioBuffer;
    message += "   ";
    SDdatum(p.lastWriteDate, p.lastWriteTime);
    message += ioBuffer;
  }
  message += "</tr> \n";

  message += "</table></body></html> \n";
  server.send(200, "text/html", message);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for feedbackWaiting on additional info. If it's not received, the issue may be closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions