-------------------------------------------------------------------------
| 26 | { |
| 27 | //------------------------------------------------------------------------- |
| 28 | MappedFile::MappedFile(const std::filesystem::path& path) |
| 29 | { |
| 30 | boost::iostreams::mapped_file mappedFile(path.string(), boost::iostreams::mapped_file::readonly); |
| 31 | |
| 32 | if (!mappedFile) |
| 33 | THROW(L"Cannot create mapped file: " + path.wstring()); |
| 34 | |
| 35 | auto begin = mappedFile.const_begin(); |
| 36 | const auto end = mappedFile.const_end(); |
| 37 | for (auto it = begin; it != end; ++it) |
| 38 | { |
| 39 | if (*it == '\n') |
| 40 | { |
| 41 | const auto endOfLine = (it != begin && *(it - 1) == '\r') ? it - 1 : it; |
| 42 | lines_.push_back({ begin, endOfLine }); |
| 43 | begin = it + 1; |
| 44 | } |
| 45 | } |
| 46 | if (begin != end) |
| 47 | lines_.push_back({begin, end}); |
| 48 | } |
| 49 | |
| 50 | //------------------------------------------------------------------------- |
| 51 | const std::vector<std::string>& MappedFile::GetLines() const |
nothing calls this directly
no outgoing calls
no test coverage detected