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

Function load_file_to_string

src/main.cpp:177–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175} MainData;
176
177bool load_file_to_string(std::string& toRet, std::string_view fileName) {
178 // https://nullptr.org/cpp-read-file-into-string/
179 std::ifstream file(fileName.data(), std::ios::in | std::ios::binary | std::ios::ate);
180 if(!file.is_open()) {
181 std::cout << "[load_file_to_string] Could not open file " << fileName << std::endl;
182 return false;
183 }
184 size_t fileSize;
185 auto tellgResult = file.tellg();
186 if(tellgResult == -1) {
187 std::cout << "[load_file_to_string] tellg failed for file " << fileName << std::endl;
188 return false;
189 }
190
191 fileSize = static_cast<size_t>(tellgResult);
192
193 file.seekg(0, std::ios_base::beg);
194
195 toRet.resize(fileSize);
196 file.read(toRet.data(), fileSize);
197
198 file.close();
199 return true;
200}
201
202void get_refresh_rate(MainStruct& mS) {
203 mS.frameRefreshDuration = std::chrono::seconds(0);

Callers 1

initialize_sdlFunction · 0.85

Calls 4

readMethod · 0.80
closeMethod · 0.65
dataMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected