MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / ReadFromFile

Method ReadFromFile

Source/TextExporter.cpp:422–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
443public:
444 int line = 1;

Callers

nothing calls this directly

Calls 9

sizeFunction · 0.85
to_utf8Function · 0.85
GetPositionMethod · 0.80
ReplaceMethod · 0.80
GetErrorMessageMethod · 0.80
OpenMethod · 0.45
GetLengthMethod · 0.45
ReadMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected