* Open the next file or subdirectory in a directory. * * \param[in] dirFile An open SdFat instance for the directory containing the * file to be opened. * * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive * OR of flags O_READ, O_WRITE, O_TRUNC, and O_SYNC. * * See open() by path for definition of flags. * \return true for success or false for failure. */
| 962 | * \return true for success or false for failure. |
| 963 | */ |
| 964 | bool SdBaseFile::openNext(SdBaseFile *dirFile, const uint8_t oflag) { |
| 965 | if (!dirFile) return false; |
| 966 | |
| 967 | // error if already open |
| 968 | if (isOpen()) return false; |
| 969 | |
| 970 | vol_ = dirFile->vol_; |
| 971 | |
| 972 | while (1) { |
| 973 | uint8_t index = 0xF & (dirFile->curPosition_ >> 5); |
| 974 | |
| 975 | // read entry into cache |
| 976 | dir_t *p = dirFile->readDirCache(); |
| 977 | if (!p) return false; |
| 978 | |
| 979 | // done if last entry |
| 980 | if (p->name[0] == DIR_NAME_FREE) return false; |
| 981 | |
| 982 | // skip empty slot or '.' or '..' |
| 983 | if (p->name[0] == DIR_NAME_DELETED || p->name[0] == '.') { |
| 984 | continue; |
| 985 | } |
| 986 | // must be file or dir |
| 987 | if (DIR_IS_FILE_OR_SUBDIR(p)) { |
| 988 | return openCachedEntry(index, oflag); |
| 989 | } |
| 990 | } |
| 991 | return false; |
| 992 | } |
| 993 | |
| 994 | #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) |
| 995 |
nothing calls this directly
no test coverage detected