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

Method write

KittyMemoryEx/KittyIOFile.cpp:57–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55 }
56 total += n;
57 }
58 return total;
59}
60
61ssize_t KittyIOFile::write(const void *buffer, size_t len)
62{
63 _error = 0;
64
65 if (_fd < 0)
66 return -1;
67
68 const char *ptr = static_cast<const char *>(buffer);
69 size_t total = 0;
70
71 while (total < len)
72 {
73 size_t toWrite = std::min(len - total, KT_IO_CHUNK_SIZE);
74 ssize_t n = KT_EINTR_RETRY(::write(_fd, ptr + total, toWrite));
75 if (n <= 0)
76 {
77 _error = (n < 0) ? errno : 0;
78 return total > 0 ? total : (_error == 0 ? 0 : -1);
79 }
80 total += n;
81 }

Callers 2

dumpMemRangeMethod · 0.80
writeOffsetToFileMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected