| 10 | auto nop_deleter = [](unsigned char* p) { }; |
| 11 | |
| 12 | const ResourceData ResourceManager::getFileData(const std::string& path) const |
| 13 | { |
| 14 | //check if its embedded |
| 15 | |
| 16 | if(res2hMap.find(path) != res2hMap.end()) |
| 17 | { |
| 18 | //it is |
| 19 | Res2hEntry embeddedEntry = res2hMap.find(path)->second; |
| 20 | ResourceData data = { |
| 21 | std::shared_ptr<unsigned char>(const_cast<unsigned char*>(embeddedEntry.data), nop_deleter), |
| 22 | embeddedEntry.size |
| 23 | }; |
| 24 | return data; |
| 25 | } |
| 26 | |
| 27 | //it's not embedded; load the file |
| 28 | if(!fs::exists(path)) |
| 29 | { |
| 30 | //if the file doesn't exist, return an "empty" ResourceData |
| 31 | ResourceData data = {NULL, 0}; |
| 32 | return data; |
| 33 | }else{ |
| 34 | ResourceData data = loadFile(path); |
| 35 | return data; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | ResourceData ResourceManager::loadFile(const std::string& path) const |
| 40 | { |