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

Method pwrite

KittyMemoryEx/KittyIOFile.cpp:107–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107ssize_t KittyIOFile::pwrite(uintptr_t offset, const void *buffer, size_t len)
108{
109 _error = 0;
110
111 if (_fd < 0)
112 return -1;
113
114 const char *ptr = static_cast<const char *>(buffer);
115 size_t total = 0;
116 while (total < len)
117 {
118 size_t toWrite = std::min(len - total, _bufferSize);
119#ifdef __APPLE__
120 ssize_t n = KT_EINTR_RETRY(::pwrite(_fd, ptr + total, toWrite, (off_t)(offset + total)));
121#else
122 ssize_t n = KT_EINTR_RETRY(::pwrite64(_fd, ptr + total, toWrite, (off64_t)(offset + total)));
123#endif
124 if (n <= 0)
125 {
126 _error = (n < 0) ? errno : 0;
127 return total > 0 ? total : -1;
128 }
129 total += n;
130 }
131 return total;
132}
133
134bool KittyIOFile::readToString(std::string *str)
135{

Callers 2

dumpMemELFMethod · 0.80
WriteMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected