Skip to content

Commit 314da51

Browse files
committed
Merge branch 'master' into bstream2
2 parents 474d5a1 + fa5040d commit 314da51

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

libraries/LittleFS/src/LittleFS.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ FileImplPtr LittleFSImpl::open(const char* path, OpenMode openMode, AccessMode a
7272
if (rc == LFS_ERR_ISDIR) {
7373
// To support the SD.openNextFile, a null FD indicates to the LittleFSFile this is just
7474
// a directory whose name we are carrying around but which cannot be read or written
75-
return std::make_shared<LittleFSFileImpl>(this, path, nullptr);
75+
return std::make_shared<LittleFSFileImpl>(this, path, nullptr, flags);
7676
} else if (rc == 0) {
77-
return std::make_shared<LittleFSFileImpl>(this, path, fd);
77+
return std::make_shared<LittleFSFileImpl>(this, path, fd, flags);
7878
} else {
7979
DEBUGV("LittleFSDirImpl::openFile: rc=%d fd=%p path=`%s` openMode=%d accessMode=%d err=%d\n",
8080
rc, fd.get(), path, openMode, accessMode, rc);

libraries/LittleFS/src/LittleFS.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class LittleFSImpl : public FSImpl
323323
class LittleFSFileImpl : public FileImpl
324324
{
325325
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) {
327327
_name = std::shared_ptr<char>(new char[strlen(name) + 1], std::default_delete<char[]>());
328328
strcpy(_name.get(), name);
329329
}
@@ -419,7 +419,7 @@ class LittleFSFileImpl : public FileImpl
419419
lfs_file_close(_fs->getFS(), _getFD());
420420
_opened = false;
421421
DEBUGV("lfs_file_close: fd=%p\n", _getFD());
422-
if (timeCallback) {
422+
if (timeCallback && (_flags & LFS_O_WRONLY)) {
423423
// Add metadata with last write time
424424
time_t now = timeCallback();
425425
int rc = lfs_setattr(_fs->getFS(), _name.get(), 't', (const void *)&now, sizeof(now));
@@ -483,6 +483,7 @@ class LittleFSFileImpl : public FileImpl
483483
std::shared_ptr<lfs_file_t> _fd;
484484
std::shared_ptr<char> _name;
485485
bool _opened;
486+
int _flags;
486487
};
487488

488489
class LittleFSDirImpl : public DirImpl
@@ -567,6 +568,10 @@ class LittleFSDirImpl : public DirImpl
567568
bool rewind() override {
568569
_valid = false;
569570
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);
570575
return (rc == 0);
571576
}
572577

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy