MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / write_content

Function write_content

dependencies/httplib/httplib.h:3492–3525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3490
3491template <typename T>
3492inline bool write_content(Stream &strm, const ContentProvider &content_provider,
3493 size_t offset, size_t length, T is_shutting_down,
3494 Error &error) {
3495 size_t end_offset = offset + length;
3496 auto ok = true;
3497 DataSink data_sink;
3498
3499 data_sink.write = [&](const char *d, size_t l) -> bool {
3500 if (ok) {
3501 if (write_data(strm, d, l)) {
3502 offset += l;
3503 } else {
3504 ok = false;
3505 }
3506 }
3507 return ok;
3508 };
3509
3510 data_sink.is_writable = [&](void) { return ok && strm.is_writable(); };
3511
3512 while (offset < end_offset && !is_shutting_down()) {
3513 if (!content_provider(offset, end_offset - offset, data_sink)) {
3514 error = Error::Canceled;
3515 return false;
3516 }
3517 if (!ok) {
3518 error = Error::Write;
3519 return false;
3520 }
3521 }
3522
3523 error = Error::Success;
3524 return true;
3525}
3526
3527template <typename T>
3528inline bool write_content(Stream &strm, const ContentProvider &content_provider,

Callers 2

Calls 2

write_dataFunction · 0.85
is_writableMethod · 0.80

Tested by

no test coverage detected