| 20 | } |
| 21 | |
| 22 | std::string MappedFileAccessor::ReadNullTermString(size_t address, const size_t maxLength) const |
| 23 | { |
| 24 | if (address > Length()) |
| 25 | return ""; |
| 26 | // If we are not given a maxLength (i.e. -1) than we will set the max address to the length of the file. |
| 27 | const size_t maxAddr = (maxLength != -1) ? std::min(address + maxLength, Length()) : Length(); |
| 28 | // Read a null-terminated string manually to avoid errors related to string length on Linux. |
| 29 | std::string str; |
| 30 | str.reserve(140); |
| 31 | for (size_t currAddr = address; currAddr < maxAddr; ++currAddr) |
| 32 | { |
| 33 | char c = m_file._mmap[currAddr]; |
| 34 | if (c == '\0') |
| 35 | break; |
| 36 | str += c; |
| 37 | } |
| 38 | str.shrink_to_fit(); |
| 39 | return str; |
| 40 | } |
| 41 | |
| 42 | uint8_t MappedFileAccessor::ReadUInt8(size_t address) const |
| 43 | { |
no outgoing calls
no test coverage detected