MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / writeall

Function writeall

tools/comdb2ar/util.cpp:157–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155
156
157ssize_t writeall(int fd, const void *buf, size_t nbytes)
158// Write all the bytes to the given fd. Return the number of bytes written,
159// or -1 if we hit an error or 0 if we can't write (in which case it is
160// possible that some bytes were written successfully; we just don't say how
161// many to the caller). Returns nbytes on success.
162{
163 const char *cbuf = static_cast<const char *>(buf);
164 size_t total = 0;
165
166 while(nbytes > 0) {
167 ssize_t byteswritten = write(fd, cbuf, nbytes);
168 if(byteswritten <= 0) {
169 return byteswritten;
170 }
171
172 cbuf += byteswritten;
173 nbytes -= byteswritten;
174 total += byteswritten;
175 }
176
177 return total;
178}
179
180
181ssize_t readall(int fd, void *buf, size_t nbytes)

Callers 7

serialise_incr_fileFunction · 0.85
writepaddingFunction · 0.85
serialise_stringFunction · 0.85
serialise_fileFunction · 0.85
serialise_databaseFunction · 0.85
write_incremental_fileFunction · 0.85
xsputnMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected