MCPcopy Create free account
hub / github.com/antopilo/Nuake / ReadFile

Method ReadFile

Nuake/Source/Nuake/FileSystem/FileSystem.cpp:233–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233std::string FileSystem::ReadFile(const std::string& path, bool absolute)
234{
235 std::string finalPath = path;
236 if (!absolute)
237 finalPath = Root + path;
238
239 std::ifstream myReadFile(finalPath, std::ios::in | std::ios::binary);
240 std::string fileContent = "";
241 std::string allFile = "";
242
243 char bom[3];
244 myReadFile.read(bom, 3);
245
246 // Check for UTF-8 BOM (EF BB BF)
247 if (bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF)
248 {
249 myReadFile.seekg(3);
250 }
251 else
252 {
253 myReadFile.seekg(0);
254 }
255
256 // Use a while loop together with the getline() function to read the file line by line
257 while (getline(myReadFile, fileContent))
258 {
259 allFile.append(fileContent + "\n");
260 }
261
262 // Close the file
263 myReadFile.close();
264 return allFile;
265}
266
267std::ofstream FileSystem::fileWriter;
268bool FileSystem::BeginWriteFile(const std::string path, bool absolute)

Callers 3

BakeMethod · 0.80
LoadModelMethod · 0.80
LoadSkinnedModelMethod · 0.80

Calls 2

appendMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected