MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / WriteObjectDirectory

Method WriteObjectDirectory

src/GCodes/ObjectTracker.cpp:178–206  ·  view source on GitHub ↗

Write the object details to file, returning true if successful

Source from the content-addressed store, hash-verified

176
177// Write the object details to file, returning true if successful
178bool 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

Callers 1

Calls 7

catfMethod · 0.80
catMethod · 0.80
IterateWhileMethod · 0.80
WriteMethod · 0.60
printfMethod · 0.45
IsNullMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected