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

Function loadAll

Tactility/Source/bluetooth/BluetoothPairedDevice.cpp:95–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95std::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

Callers 3

autoConnectHidHostFunction · 0.85
bt_event_bridgeFunction · 0.85
getPairedPeersFunction · 0.85

Calls 2

scandirFunction · 0.85
loadFunction · 0.70

Tested by

no test coverage detected