| 65 | } |
| 66 | |
| 67 | std::string read_file_to_string(const std::filesystem::path& filePath) { |
| 68 | // Could also use SDL_LoadFile, but that allocates into a void* and involves a copy into std::string |
| 69 | |
| 70 | std::string toRet; |
| 71 | SDL_IOStream* file = SDL_IOFromFile(filePath.string().c_str(), "rb"); |
| 72 | if(!file) |
| 73 | throw std::runtime_error("[read_file_to_string] Could not open file " + filePath.string()); |
| 74 | Sint64 fileSize = SDL_GetIOSize(file); |
| 75 | if(fileSize < 0) |
| 76 | throw std::runtime_error("[read_file_to_string] tellg failed for file " + filePath.string()); |
| 77 | toRet.resize(fileSize); |
| 78 | SDL_ReadIO(file, toRet.data(), fileSize); |
| 79 | SDL_CloseIO(file); |
| 80 | return toRet; |
| 81 | } |
| 82 | |
| 83 | bool is_valid_http_url(const std::string& str) { |
| 84 | if(str.empty()) |
no test coverage detected