This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Reading file creation date /time on FATFs

Hi All,

I am working on a TM4C129x custom board.  We have ported TI-RTOS 2.14 onto the board. FatFs support was needed and has been enabled.  RTC is enabled and tested. Shows the correct date/time.

One of requirements of the project  is logging data onto SD card. One file is created for each day in the format YYYYMMDD.log  e.g  20160808.log (file created on 8th August 2016).

Another requirement is deleting files that are 200 days old.

i am using the f_readdir to traverse the directory and get the file information in  struct FILINFO defined in ff.h.  The file information should contain the file name, date and time when it was modified.

But  on testing found that date of  file created/modified remained a constant 0xECO1 after testing on different dates and different times.

When I open the SD card on a windows PC, I only see filenames and no date/time is displayed. 

Does the FATfs support storing metadata information about file creation/modification?

TIA

Narendra

  • Hi Narendra,

    The FatFS module does support timestamp data but it needs to be initialized within your application with the current time.

    As the FatFS get_fattime() function uses the SYS/BIOS Seconds module, you can call the Seconds_set() API with the number of seconds since 1970(UNIX Epoch).

    Ex)

    #include <ti/sysbios/hal/Seconds.h>
    
    
    /* 8/10/2016 = 1470850656 seconds */
    Seconds_set(1470850656);

    See the SYS/BIOS API reference guide for all Seconds module API's:

    <TIRTOS_INSTALL>/products/bios_6_42_03_35/docs/cdoc/indexChrome.html

    More information on FatFS:

    <TIRTOS_INSTALL>/docs/tirtos_User_Guide.pdf#F11

    Best,

    Alexander

  • Thanks Alexander. Its working now. 1 more question. Can we order the reading of the files according to date/time.
  • Hi Narendra,

    From some light research, it doesn't look like FatFS supports file ordering prior to the f_readdir call. As such, you'll have to perform any sorting in your application by reading all of the files and manually checking each timestamp.

    Best,
    Alexander