Load the given file, trying different extensions (first OGG, then WAV) as fallback
| 27 | |
| 28 | // Load the given file, trying different extensions (first OGG, then WAV) as fallback |
| 29 | ArchiveFilePtr openSoundFile(const std::string& fileName) |
| 30 | { |
| 31 | // Try to open the file as it is |
| 32 | auto file = GlobalFileSystem().openFile(fileName); |
| 33 | |
| 34 | if (file) |
| 35 | { |
| 36 | // File found, play it |
| 37 | return file; |
| 38 | } |
| 39 | |
| 40 | file = GlobalFileSystem().openFile(os::replaceExtension(fileName, ".ogg")); |
| 41 | |
| 42 | if (file) |
| 43 | { |
| 44 | return file; |
| 45 | } |
| 46 | |
| 47 | // Try to open the file with .wav extension |
| 48 | return GlobalFileSystem().openFile(os::replaceExtension(fileName, ".wav")); |
| 49 | } |
| 50 | |
| 51 | } |
| 52 |
no test coverage detected