MCPcopy Create free account
hub / github.com/SmingHub/Sming / opendir

Method opendir

Sming/Libraries/Spiffs/src/FileSystem.cpp:661–695  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

659}
660
661int FileSystem::opendir(const char* path, DirHandle& dir)
662{
663 CHECK_MOUNTED()
664
665 isRootPath(path);
666 unsigned pathlen = 0;
667 if(path != nullptr) {
668 pathlen = strlen(path);
669 if(pathlen >= sizeof(FileDir::path)) {
670 return Error::NameTooLong;
671 }
672 }
673
674 auto d = new FileDir{};
675 if(d == nullptr) {
676 return Error::NoMem;
677 }
678
679 if(SPIFFS_opendir(handle(), nullptr, &d->d) == nullptr) {
680 int err = SPIFFS_errno(handle());
681 err = translateSpiffsError(err);
682 debug_ifserr(err, "opendir");
683 delete d;
684 return err;
685 }
686
687 if(pathlen != 0) {
688 memcpy(d->path, path, pathlen);
689 }
690 d->path[pathlen] = '\0';
691 d->pathlen = pathlen;
692
693 dir = DirHandle(d);
694 return FS_OK;
695}
696
697int FileSystem::rewinddir(DirHandle dir)
698{

Callers 2

readCheckMethod · 0.80
fileOpenDirFunction · 0.80

Calls 1

translateSpiffsErrorFunction · 0.85

Tested by

no test coverage detected