MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/xstudio / write_content

Function write_content

extern/include/cpp-httplib/httplib.h:3602–3635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3600
3601template <typename T>
3602inline bool write_content(Stream &strm, const ContentProvider &content_provider,
3603 size_t offset, size_t length, T is_shutting_down,
3604 Error &error) {
3605 size_t end_offset = offset + length;
3606 auto ok = true;
3607 DataSink data_sink;
3608
3609 data_sink.write = [&](const char *d, size_t l) -> bool {
3610 if (ok) {
3611 if (write_data(strm, d, l)) {
3612 offset += l;
3613 } else {
3614 ok = false;
3615 }
3616 }
3617 return ok;
3618 };
3619
3620 data_sink.is_writable = [&](void) { return ok && strm.is_writable(); };
3621
3622 while (offset < end_offset && !is_shutting_down()) {
3623 if (!content_provider(offset, end_offset - offset, data_sink)) {
3624 error = Error::Canceled;
3625 return false;
3626 }
3627 if (!ok) {
3628 error = Error::Write;
3629 return false;
3630 }
3631 }
3632
3633 error = Error::Success;
3634 return true;
3635}
3636
3637template <typename T>
3638inline 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