| 39 | // endregion |
| 40 | |
| 41 | void 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 | |
| 67 | void View::onDirEntryPressed(uint32_t index) { |
| 68 | dirent dir_entry; |
nothing calls this directly
no test coverage detected