| 93 | } |
| 94 | |
| 95 | std::vector<PairedDevice> loadAll() { |
| 96 | std::vector<dirent> entries; |
| 97 | file::scandir(DATA_DIR, entries, [](const dirent* entry) -> int { |
| 98 | if (entry->d_type != file::TT_DT_REG && entry->d_type != file::TT_DT_UNKNOWN) return -1; |
| 99 | std::string name = entry->d_name; |
| 100 | return name.ends_with(".device.properties") ? 0 : -1; |
| 101 | }, nullptr); |
| 102 | |
| 103 | std::vector<PairedDevice> result; |
| 104 | result.reserve(entries.size()); |
| 105 | for (const auto& entry : entries) { |
| 106 | std::string filename = entry.d_name; |
| 107 | constexpr std::string_view suffix = ".device.properties"; |
| 108 | if (filename.size() <= suffix.size()) continue; |
| 109 | const std::string addr_hex = filename.substr(0, filename.size() - suffix.size()); |
| 110 | PairedDevice device; |
| 111 | if (load(addr_hex, device)) { |
| 112 | result.push_back(std::move(device)); |
| 113 | } |
| 114 | } |
| 115 | return result; |
| 116 | } |
| 117 | |
| 118 | } // namespace tt::bluetooth::settings |
no test coverage detected