MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / Read

Method Read

Sources/Shared/IO/Compression/ZstdStream.cpp:124–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122 }
123
124 std::int64_t ZstdStream::Read(void* destination, std::int64_t bytesToRead)
125 {
126 if (bytesToRead <= 0) {
127 return 0;
128 }
129
130 DEATH_ASSERT(destination != nullptr, "destination is null", 0);
131 std::uint8_t* typedBuffer = static_cast<std::uint8_t*>(destination);
132 std::int64_t bytesReadTotal = 0;
133
134 do {
135 // ReadInternal() can read only up to ZSTD_DStreamInSize() bytes
136 std::int32_t partialBytesToRead = (bytesToRead < INT32_MAX ? (std::int32_t)bytesToRead : INT32_MAX);
137 std::int32_t bytesRead = ReadInternal(&typedBuffer[bytesReadTotal], partialBytesToRead);
138 if DEATH_UNLIKELY(bytesRead < 0) {
139 return bytesRead;
140 } else if DEATH_UNLIKELY(bytesRead == 0) {
141 break;
142 }
143 bytesReadTotal += bytesRead;
144 bytesToRead -= bytesRead;
145 } while (bytesToRead > 0);
146
147 _outPosTotal += bytesReadTotal;
148 return bytesReadTotal;
149 }
150
151 std::int64_t ZstdStream::Write(const void* source, std::int64_t bytesToWrite)
152 {

Callers 1

ReadInternalMethod · 0.45

Calls 2

DEATH_ASSERTFunction · 0.85
DEATH_UNLIKELYFunction · 0.50

Tested by

no test coverage detected