| 35 | } |
| 36 | |
| 37 | bool State::setEntriesForPath(const std::string& path) { |
| 38 | auto lock = mutex.asScopedLock(); |
| 39 | if (!lock.lock(100)) { |
| 40 | LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath"); |
| 41 | return false; |
| 42 | } |
| 43 | |
| 44 | LOGGER.info("Changing path: {} -> {}", current_path, path); |
| 45 | |
| 46 | /** |
| 47 | * On PC, the root entry point ("/") is a folder. |
| 48 | * On ESP32, the root entry point contains the various mount points. |
| 49 | */ |
| 50 | bool get_mount_points = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/"); |
| 51 | if (get_mount_points) { |
| 52 | LOGGER.info("Setting custom root"); |
| 53 | dir_entries = file::getFileSystemDirents(); |
| 54 | current_path = path; |
| 55 | selected_child_entry = ""; |
| 56 | action = ActionNone; |
| 57 | return true; |
| 58 | } else { |
| 59 | dir_entries.clear(); |
| 60 | int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType); |
| 61 | if (count >= 0) { |
| 62 | LOGGER.info("{} has {} entries", path, count); |
| 63 | current_path = path; |
| 64 | selected_child_entry = ""; |
| 65 | action = ActionNone; |
| 66 | return true; |
| 67 | } else { |
| 68 | LOGGER.error("Failed to fetch entries for {}", path); |
| 69 | return false; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | bool State::setEntriesForChildPath(const std::string& childPath) { |
| 75 | auto path = file::getChildPath(current_path, childPath); |
no test coverage detected