SdFat icon indicating copy to clipboard operation
SdFat copied to clipboard

Need to recover modification date and time of files and directories

Open gallegojm opened this issue 5 years ago • 2 comments

Hi I am updating my FtpServer library to use your new version of SdFat. I need to recover the modification date and time of files and can not do it out of SdFat anymore as I was doing with older version. I solved it adding those three routines (based on existing routines printModifyDateTime() ) In FatFile class:

bool FatFile::getModifyDateTime( uint16_t * pdate, uint16_t * ptime ) {
  DirFat_t dir;
  if (!dirEntry(&dir)) {
    DBG_FAIL_MACRO;
    goto fail;
  }
    * pdate = getLe16( dir.modifyDate );
    * ptime = getLe16( dir.modifyTime );
  return true;
fail:
  return false;
}

In ExtFatFile class:

bool ExFatFile::getModifyDateTime( uint16_t * pdate, uint16_t * ptime ) {
  DirFile_t* df = reinterpret_cast<DirFile_t*>
                 (m_vol->dirCache(&m_dirPos, FsCache::CACHE_FOR_READ));
  if (!df) {
    DBG_FAIL_MACRO;
    goto fail;
  }
    * pdate = getLe16( df->modifyDate );
    * ptime = getLe16( df->modifyTime );
  return true;
fail:
  return false;
}

In FsBaseFile class (inline inFsFile.h)

  bool getModifyDateTime( uint16_t * pdate, uint16_t * ptime ) {
    return m_fFile ? m_fFile->getModifyDateTime(pdate,ptime) :
           m_xFile ? m_xFile->getModifyDateTime(pdate,ptime) : false;
  }

Is it possible you add those routines in your next release? Or to give me an idea of how to solve it out of the library?

Thank you for your library

gallegojm avatar Nov 23 '20 10:11 gallegojm

I will provide these functions in the next release:

bool getAccessDateTime( uint16_t * pdate, uint16_t * ptime );
bool getCreateDateTime( uint16_t * pdate, uint16_t * ptime );
bool getModifyDateTime( uint16_t * pdate, uint16_t * ptime );

FAT32/FAT16 only has access date so I will return zero for time.

greiman avatar Nov 23 '20 15:11 greiman

Thank you so much!

gallegojm avatar Nov 23 '20 16:11 gallegojm