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 return total;
107}
108
109ssize_t KittyIOFile::pwrite(kt_off64_t offset, const void *buffer, size_t len)
110{
111 _error = 0;
112
113 if (_fd < 0)
114 return -1;
115
116 const char *ptr = static_cast<const char *>(buffer);
117 size_t total = 0;
118 while (total < len)
119 {
120 size_t toWrite = std::min(len - total, KT_IO_CHUNK_SIZE);
121 ssize_t n = KT_EINTR_RETRY(kt_pwrite64(_fd, ptr + total, toWrite, (kt_off64_t)(offset + total)));
122 if (n <= 0)
123 {
124 _error = (n < 0) ? errno : 0;
125 return total > 0 ? total : (_error == 0 ? 0 : -1);
126 }
127 total += n;
128 }
129 return total;
130}
131
132bool KittyIOFile::readToString(std::string *str)
133{
134 _error = 0;
135

Callers 2

dumpMemELFMethod · 0.80
WriteMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected