MCPcopy Create free account
hub / github.com/MJx0/KittyMemoryEx / writeOffsetToFile

Method writeOffsetToFile

KittyMemoryEx/KittyIOFile.cpp:196–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196bool KittyIOFile::writeOffsetToFile(uintptr_t offset, size_t len, const std::string &filePath)
197{
198 _error = 0;
199
200 KittyIOFile of(filePath, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0666);
201 if (!of.open())
202 return false;
203
204 std::vector<char> buffer(_bufferSize);
205 size_t remaining = len;
206 uintptr_t curr_off = offset;
207
208 while (remaining > 0)
209 {
210 size_t to_read = std::min(remaining, _bufferSize);
211 ssize_t nread = pread(curr_off, buffer.data(), to_read);
212 if (nread <= 0)
213 break;
214
215 if (of.write(buffer.data(), nread) != nread)
216 return false;
217
218 curr_off += nread;
219 remaining -= nread;
220 }
221
222 return remaining == 0;
223}
224
225bool KittyIOFile::writeToFd(int fd)
226{

Callers

nothing calls this directly

Calls 2

openMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected