| 231 | } |
| 232 | |
| 233 | std::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 | |
| 267 | std::ofstream FileSystem::fileWriter; |
| 268 | bool FileSystem::BeginWriteFile(const std::string path, bool absolute) |
no test coverage detected