MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / read

Method read

source/base/StarMemoryAssetSource.cpp:107–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107ByteArray MemoryAssetSource::read(String const& path) {
108 auto p = m_files.ptr(path);
109 if (!p)
110 throw AssetSourceException::format("Requested file '{}' does not exist in memory", path);
111 else if (auto bytes = p->ptr<ByteArray>())
112 return *bytes;
113 else {
114 Image const* image = p->get<ImagePtr>().get();
115 return ByteArray((char const*)image->data(), image->width() * image->height() * image->bytesPerPixel());
116 }
117}
118
119ImageConstPtr MemoryAssetSource::image(String const& path) {
120 auto p = m_files.ptr(path);

Callers

nothing calls this directly

Calls 8

ByteArrayClass · 0.85
bytesPerPixelMethod · 0.80
formatFunction · 0.50
ptrMethod · 0.45
getMethod · 0.45
dataMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected