Read 8 bytes (uint64_t) with endian swap if needed
| 99 | |
| 100 | // Read 8 bytes (uint64_t) with endian swap if needed |
| 101 | bool read8(uint64_t* dst) { |
| 102 | if (!dst) { |
| 103 | return false; |
| 104 | } |
| 105 | uint8_t buf[8]; |
| 106 | if (!read(8, buf)) { |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | if (needs_swap_) { |
| 111 | *dst = static_cast<uint64_t>(buf[7]) << 56 | |
| 112 | static_cast<uint64_t>(buf[6]) << 48 | |
| 113 | static_cast<uint64_t>(buf[5]) << 40 | |
| 114 | static_cast<uint64_t>(buf[4]) << 32 | |
| 115 | static_cast<uint64_t>(buf[3]) << 24 | |
| 116 | static_cast<uint64_t>(buf[2]) << 16 | |
| 117 | static_cast<uint64_t>(buf[1]) << 8 | |
| 118 | static_cast<uint64_t>(buf[0]); |
| 119 | } else { |
| 120 | std::memcpy(dst, buf, 8); |
| 121 | } |
| 122 | return true; |
| 123 | } |
| 124 | |
| 125 | // Seek to absolute position |
| 126 | // Returns false if position is out of bounds |
nothing calls this directly
no outgoing calls
no test coverage detected