| 420 | } |
| 421 | |
| 422 | CStringA ReadFromFile(const fs::path &FileName) { |
| 423 | CFileException oFileException; |
| 424 | if (CStdioFile f; f.Open(FileName.c_str(), CFile::modeRead | CFile::typeBinary, &oFileException)) { |
| 425 | CStringA str; |
| 426 | while (f.GetPosition() < f.GetLength()) { |
| 427 | char buf[1024] = { }; |
| 428 | ULONGLONG sz = std::min(f.GetLength() - f.GetPosition(), (ULONGLONG)std::size(buf)); |
| 429 | f.Read(buf, (UINT)sz); |
| 430 | CStringA part(buf, (int)sz); |
| 431 | part.Replace("\r", ""); |
| 432 | str += part; |
| 433 | } |
| 434 | f.Close(); |
| 435 | return str; |
| 436 | } |
| 437 | |
| 438 | WCHAR szError[256]; |
| 439 | oFileException.GetErrorMessage(szError, std::size(szError)); |
| 440 | throw std::runtime_error {"Unable to open file:\n" + conv::to_utf8(szError)}; |
| 441 | } |
| 442 | |
| 443 | public: |
| 444 | int line = 1; |
nothing calls this directly
no test coverage detected