MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / read_file_to_string

Function read_file_to_string

include/Helpers/StringHelpers.cpp:67–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67std::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
83bool is_valid_http_url(const std::string& str) {
84 if(str.empty())

Callers 12

load_palettesMethod · 0.85
load_licensesMethod · 0.85
load_configMethod · 0.85
load_icons_atMethod · 0.85
add_resource_fileMethod · 0.85
FontDataMethod · 0.85
load_from_fileMethod · 0.85
SDL_AppInitFunction · 0.85
layoutMethod · 0.85
FileSelectScreenMethod · 0.85

Calls 4

c_strMethod · 0.80
stringMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected