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

Method writeToFd

KittyMemoryEx/KittyIOFile.cpp:225–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223
224 while (true)
225 {
226 ssize_t nr = pread(offset, buffer.data(), buffer.size());
227 if (nr < 0)
228 return false;
229
230 if (nr == 0)
231 break;
232
233 ssize_t total_nw = 0;
234 while (total_nw < nr)
235 {
236 ssize_t nw = KT_EINTR_RETRY(::write(fd, buffer.data() + total_nw, nr - total_nw));
237 if (nw <= 0)
238 {
239 _error = (nw < 0) ? errno : 0;
240 return false;
241 }
242 total_nw += nw;
243 }
244
245 offset += nr;
246 }
247
248 return true;
249}
250
251bool KittyIOFile::listFilesCallback(const std::string &dirPath, std::function<bool(const std::string &)> cb)
252{
253 DIR *dir = opendir(dirPath.c_str());
254 if (!dir)
255 return false;
256
257 std::string base = dirPath;
258 if (!base.empty() && base.back() != '/')
259 base += '/';
260
261 while (struct dirent *f = readdir(dir))
262 {
263 if (f->d_name[0] == '.')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected