| 196 | #endif |
| 197 | |
| 198 | FlaxChunk* BinaryAsset::GetOrCreateChunk(int32 index) const |
| 199 | { |
| 200 | if (IsVirtual()) // Virtual assets don't own storage container |
| 201 | return nullptr; |
| 202 | ASSERT(Math::IsInRange(index, 0, ASSET_FILE_DATA_CHUNKS - 1)); |
| 203 | |
| 204 | // Try get |
| 205 | auto chunk = _header.Chunks[index]; |
| 206 | if (chunk) |
| 207 | { |
| 208 | chunk->RegisterUsage(); |
| 209 | return chunk; |
| 210 | } |
| 211 | |
| 212 | // Allocate |
| 213 | ASSERT(Storage); |
| 214 | const_cast<BinaryAsset*>(this)->_header.Chunks[index] = chunk = Storage->AllocateChunk(); |
| 215 | if (chunk) |
| 216 | chunk->RegisterUsage(); |
| 217 | |
| 218 | return chunk; |
| 219 | } |
| 220 | |
| 221 | void BinaryAsset::SetChunk(int32 index, const Span<byte>& data) |
| 222 | { |
no test coverage detected