MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / get

Function get

TheForceEngine/TFE_Asset/gmidAsset.cpp:23–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21 bool parseGMidi(GMidiAsset* midi);
22
23 GMidiAsset* get(const char* name)
24 {
25 GMidMap::iterator iGMid = s_gmidAssets.find(name);
26 if (iGMid != s_gmidAssets.end())
27 {
28 return iGMid->second;
29 }
30
31 FilePath filePath;
32 if (!TFE_Paths::getFilePath(name, &filePath))
33 {
34 return nullptr;
35 }
36
37 FileStream gmidAsset;
38 if (!gmidAsset.open(&filePath, Stream::MODE_READ))
39 {
40 return nullptr;
41 }
42 size_t size = gmidAsset.getSize();
43 s_buffer.resize(size + 1);
44 gmidAsset.readBuffer(s_buffer.data(), (u32)size);
45 gmidAsset.close();
46
47 GMidiAsset* midi = new GMidiAsset;
48 if (!parseGMidi(midi))
49 {
50 delete midi;
51 return nullptr;
52 }
53
54 s_gmidAssets[name] = midi;
55 strcpy(midi->name, name);
56 return midi;
57 }
58
59 void free(GMidiAsset* asset)
60 {

Callers

nothing calls this directly

Calls 9

parseGMidiFunction · 0.85
dataMethod · 0.80
getFilePathFunction · 0.50
endMethod · 0.45
openMethod · 0.45
getSizeMethod · 0.45
resizeMethod · 0.45
readBufferMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected