MCPcopy Create free account
hub / github.com/carbonengine/trinity / Tr2CmfContents

Method Tr2CmfContents

trinity/Resources/Tr2CmfContent.cpp:10–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10Tr2CmfContents::Tr2CmfContents( IBlueStream& stream, const char* filename )
11{
12 void* data;
13 if( !stream.LockData( &data, 0 ) )
14 {
15 CCP_LOGERR( "Failed to read CMF file %s", filename );
16 return;
17 }
18 auto size = stream.GetSize();
19 auto validated = cmf::ValidateFile( data, size, { true, true } );
20 if( !validated )
21 {
22 CCP_LOGERR( "Invalid CMF file %s: %s", filename, validated.error.c_str() );
23 return;
24 }
25 auto header = static_cast<cmf::Header*>( data );
26 m_sections.reserve( header->sections.size() );
27 for( const auto& section : header->sections )
28 {
29 m_sections.emplace_back();
30 auto& dest = m_sections.back();
31 dest.section = section;
32 dest.data = std::make_unique<uint8_t[]>( section.compressedSize );
33 memcpy( dest.data.get(), (uint8_t*)data + section.offset, section.compressedSize );
34 }
35 cmf::OffsetsToPointers( *reinterpret_cast<cmf::Data*>( m_sections[0].data.get() ) );
36}
37
38Tr2CmfContents::operator bool() const
39{

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.80
getMethod · 0.80
GetSizeMethod · 0.45

Tested by

no test coverage detected