MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / setEntriesForPath

Method setEntriesForPath

Tactility/Source/app/fileselection/State.cpp:36–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36bool State::setEntriesForPath(const std::string& path) {
37 LOGGER.info("Changing path: {} -> {}", current_path, path);
38
39 auto lock = mutex.asScopedLock();
40 if (!lock.lock(100)) {
41 LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath");
42 return false;
43 }
44
45 /**
46 * ESP32 does not have a root directory, so we have to create it manually.
47 * We'll add the NVS Flash partitions and the binding for the sdcard.
48 */
49 bool show_custom_root = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
50 if (show_custom_root) {
51 LOGGER.info("Setting custom root");
52 dir_entries = file::getFileSystemDirents();
53 current_path = path;
54 selected_child_entry = "";
55 return true;
56 } else {
57 dir_entries.clear();
58 int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType);
59 if (count >= 0) {
60 LOGGER.info("{} has {} entries", path, count);
61 current_path = path;
62 selected_child_entry = "";
63 return true;
64 } else {
65 LOGGER.error("Failed to fetch entries for {}", path);
66 return false;
67 }
68 }
69}
70
71bool State::setEntriesForChildPath(const std::string& childPath) {
72 auto path = file::getChildPath(current_path, childPath);

Callers 1

onNavigateUpPressedMethod · 0.45

Calls 8

getPlatformFunction · 0.85
getFileSystemDirentsFunction · 0.85
scandirFunction · 0.85
infoMethod · 0.80
asScopedLockMethod · 0.80
errorMethod · 0.80
clearMethod · 0.80
lockMethod · 0.45

Tested by

no test coverage detected