| 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 | { |
nothing calls this directly
no test coverage detected