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

Method onTapFile

Tactility/Source/app/fileselection/View.cpp:41–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39// endregion
40
41void View::onTapFile(const std::string& path, const std::string& filename) {
42 std::string file_path = path + "/" + filename;
43
44 // For PC we need to make the path relative to the current work directory,
45 // because that's how LVGL maps its 'drive letter' to the file system.
46 std::string processed_filepath;
47 if (kernel::getPlatform() == kernel::PlatformSimulator) {
48 char cwd[PATH_MAX];
49 if (getcwd(cwd, sizeof(cwd)) == nullptr) {
50 LOGGER.error("Failed to get current working directory");
51 return;
52 }
53 if (!file_path.starts_with(cwd)) {
54 LOGGER.error("Can only work with files in working directory {}", cwd);
55 return;
56 }
57 processed_filepath = file_path.substr(strlen(cwd));
58 } else {
59 processed_filepath = file_path;
60 }
61
62 LOGGER.info("Clicked {}", processed_filepath);
63
64 lv_textarea_set_text(path_textarea, processed_filepath.c_str());
65}
66
67void View::onDirEntryPressed(uint32_t index) {
68 dirent dir_entry;

Callers

nothing calls this directly

Calls 3

getPlatformFunction · 0.85
errorMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected