Go Down

Topic: Add ability to get to SD File modified time to SD Library Request (Read 808 times) previous topic - next topic


I like the simplicity of the code when using the SD library, but miss the ability to get the modified date of the files on the SD card for directory listings to know when the file originated.

I did the unthinkable and hacked the SD library to add a single function that allows me to get to the modification time.

I had considered having the function return the time (as a time_t) but discarded that approach because it added another dependancy to the library (#include <Time.h>), and my goal was to do the absolute minimum changes to the library.

I ultimately chose to have the function return the directory file (dir_t) from the underlying SdFile using the SdFile::dirEntry(dir_t* sd_dir) function.  The underlying data structure is protected from tinkering since SdFile::dirEntry does a memcopy of the internal data structure to the supplied data structure, breaking the linkage between the two.

In SD.h
Code: [Select]

void rewindDirectory(void);

//Add the following
void dirEntry(dir_t* sd_dir);
//End of Add

using Print::write;

In SD.cpp
Code: [Select]

void File::rewindDirectory(void) { 
  if (isDirectory())

//Add the following
void File::dirEntry(dir_t* sd_dir) {
//End of Add

SDClass SD;

Printing the modified time then can be done with this snippet, need to do all of the initiation, etc. to get to this point

Code: [Select]

File dir;
File entry;
dir_t p;



Any reason that adding this to the standard SD library would be a problem in future releases?
...and dinosaurs roamed the earth.....

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131