Write the object details to file, returning true if successful
| 176 | |
| 177 | // Write the object details to file, returning true if successful |
| 178 | bool ObjectTracker::WriteObjectDirectory(FileStore *f) const noexcept |
| 179 | { |
| 180 | bool ok = true; |
| 181 | |
| 182 | // Write the object list |
| 183 | for (size_t i = 0; ok && i < min<unsigned int>(numObjects, MaxTrackedObjects); ++i) |
| 184 | { |
| 185 | String<StringLength100> buf; |
| 186 | buf.printf("M486 S%u", i); |
| 187 | if (!objectDirectory[i].name.IsNull()) |
| 188 | { |
| 189 | buf.catf(" A\"%s\"", objectDirectory[i].name.Get().Ptr()); |
| 190 | } |
| 191 | buf.cat('\n'); |
| 192 | ok = f->Write(buf.c_str()); |
| 193 | } |
| 194 | |
| 195 | if (ok) |
| 196 | { |
| 197 | // Write which objects have been cancelled |
| 198 | ok = objectsCancelled.IterateWhile([f](unsigned int index, bool first) noexcept -> bool |
| 199 | { |
| 200 | String<StringLength20> buf; |
| 201 | buf.printf("M486 P%u\n", index); |
| 202 | return f->Write(buf.c_str()); |
| 203 | }); |
| 204 | } |
| 205 | return ok; |
| 206 | } |
| 207 | |
| 208 | #endif |
| 209 |
no test coverage detected