MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / ReadBlob

Function ReadBlob

modules/engine/runtime/serde/binary/reader.cpp:382–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382int ReadBlob(skr_binary_reader_t* reader, skr::BlobId& out_id)
383{
384 // TODO: blob 应该特别处理
385 uint64_t size;
386 int ret = skr::binary::Read(reader, size);
387 if (ret != 0)
388 {
389 SKR_LOG_FATAL(u8"failed to read blob size! ret code: %d", ret);
390 return ret;
391 }
392 auto blob = skr::IBlob::Create(nullptr, size, false);
393 if (blob == nullptr)
394 {
395 SKR_LOG_FATAL(u8"failed to create blob! ret code: %d", ret);
396 return ret;
397 }
398
399 ret = ReadBytes(reader, blob->get_data(), blob->get_size());
400 if (ret != 0)
401 {
402 SKR_LOG_FATAL(u8"failed to read blob content! ret code: %d", ret);
403 return ret;
404 }
405
406 out_id = blob;
407 return ret;
408}
409int ReadTrait<skr::IBlob*>::Read(skr_binary_reader_t* reader, skr::IBlob*& out_blob)
410{
411 skr::BlobId new_blob = nullptr;

Callers 1

ReadMethod · 0.85

Calls 5

ReadBytesFunction · 0.85
ReadFunction · 0.50
CreateFunction · 0.50
get_dataMethod · 0.45
get_sizeMethod · 0.45

Tested by

no test coverage detected