@@ -323,7 +323,7 @@ class LittleFSImpl : public FSImpl
323
323
class LittleFSFileImpl : public FileImpl
324
324
{
325
325
public:
326
- LittleFSFileImpl (LittleFSImpl* fs, const char *name, std::shared_ptr<lfs_file_t > fd) : _fs(fs), _fd(fd), _opened(true ) {
326
+ LittleFSFileImpl (LittleFSImpl* fs, const char *name, std::shared_ptr<lfs_file_t > fd, int flags ) : _fs(fs), _fd(fd), _opened(true ), _flags(flags ) {
327
327
_name = std::shared_ptr<char >(new char [strlen (name) + 1 ], std::default_delete<char []>());
328
328
strcpy (_name.get (), name);
329
329
}
@@ -419,7 +419,7 @@ class LittleFSFileImpl : public FileImpl
419
419
lfs_file_close (_fs->getFS (), _getFD ());
420
420
_opened = false ;
421
421
DEBUGV (" lfs_file_close: fd=%p\n " , _getFD ());
422
- if (timeCallback) {
422
+ if (timeCallback && (_flags & LFS_O_WRONLY) ) {
423
423
// Add metadata with last write time
424
424
time_t now = timeCallback ();
425
425
int rc = lfs_setattr (_fs->getFS (), _name.get (), ' t' , (const void *)&now, sizeof (now));
@@ -483,6 +483,7 @@ class LittleFSFileImpl : public FileImpl
483
483
std::shared_ptr<lfs_file_t > _fd;
484
484
std::shared_ptr<char > _name;
485
485
bool _opened;
486
+ int _flags;
486
487
};
487
488
488
489
class LittleFSDirImpl : public DirImpl
@@ -567,6 +568,10 @@ class LittleFSDirImpl : public DirImpl
567
568
bool rewind () override {
568
569
_valid = false ;
569
570
int rc = lfs_dir_rewind (_fs->getFS (), _getDir ());
571
+ // Skip the . and .. entries
572
+ lfs_info dirent;
573
+ lfs_dir_read (_fs->getFS (), _getDir (), &dirent);
574
+ lfs_dir_read (_fs->getFS (), _getDir (), &dirent);
570
575
return (rc == 0 );
571
576
}
572
577
0 commit comments