Unify time modification on SD and SPIFFS (#738)

* Add access to last write date time

add example

* rename cpp to ino orz

* wrong copy -past

* No comment orz

* Add missing space
This commit is contained in:
Luc
2018-03-04 21:20:34 +01:00
committed by Me No Dev
parent 7141e3e29d
commit adf513fc17
8 changed files with 620 additions and 0 deletions

View File

@ -32,6 +32,15 @@ size_t File::write(uint8_t c)
return _p->write(&c, 1);
}
time_t File::getLastWrite()
{
if (!_p) {
return 0;
}
return _p->getLastWrite();
}
size_t File::write(const uint8_t *buf, size_t size)
{
if (!_p) {

View File

@ -70,6 +70,7 @@ public:
size_t size() const;
void close();
operator bool() const;
time_t getLastWrite();
const char* name() const;
boolean isDirectory(void);

View File

@ -37,6 +37,7 @@ public:
virtual size_t position() const = 0;
virtual size_t size() const = 0;
virtual void close() = 0;
virtual time_t getLastWrite() = 0;
virtual const char* name() const = 0;
virtual boolean isDirectory(void) = 0;
virtual FileImplPtr openNextFile(const char* mode) = 0;

View File

@ -295,6 +295,11 @@ VFSFileImpl::operator bool()
return (_isDirectory && _d != NULL) || _f != NULL;
}
time_t VFSFileImpl::getLastWrite() {
_getStat() ;
return _stat.st_mtime;
}
void VFSFileImpl::_getStat() const
{
if(!_path) {

View File

@ -67,6 +67,7 @@ public:
size_t size() const override;
void close() override;
const char* name() const override;
time_t getLastWrite() override;
boolean isDirectory(void) override;
FileImplPtr openNextFile(const char* mode) override;
void rewindDirectory(void) override;