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

Method setEntriesForPath

Tactility/Source/app/files/State.cpp:37–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37bool 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
74bool State::setEntriesForChildPath(const std::string& childPath) {
75 auto path = file::getChildPath(current_path, childPath);

Callers 4

onNavigateUpPressedMethod · 0.45
onEjectPressedMethod · 0.45
onResultMethod · 0.45
doPasteMethod · 0.45

Calls 8

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

Tested by

no test coverage detected