MCPcopy Index your code
hub / github.com/nodejs/node / writeAll

Function writeAll

lib/internal/fs/streams.js:412–439  ·  view source on GitHub ↗
(data, size, pos, cb, retries = 0)

Source from the content-addressed store, hash-verified

410WriteStream.prototype._construct = _construct;
411
412function writeAll(data, size, pos, cb, retries = 0) {
413 this[kFs].write(this.fd, data, 0, size, pos, (er, bytesWritten, buffer) => {
414 // No data currently available and operation should be retried later.
415 if (er?.code === 'EAGAIN') {
416 er = null;
417 bytesWritten = 0;
418 }
419
420 if (this.destroyed || er) {
421 return cb(er || new ERR_STREAM_DESTROYED('write'));
422 }
423
424 this.bytesWritten += bytesWritten;
425
426 retries = bytesWritten ? 0 : retries + 1;
427 size -= bytesWritten;
428 pos += bytesWritten;
429
430 // Try writing non-zero number of bytes up to 5 times.
431 if (retries > 5) {
432 cb(new ERR_SYSTEM_ERROR('write failed'));
433 } else if (size) {
434 writeAll.call(this, buffer.slice(bytesWritten), size, pos, cb, retries);
435 } else {
436 cb();
437 }
438 });
439}
440
441function writevAll(chunks, size, pos, cb, retries = 0) {
442 this[kFs].writev(this.fd, chunks, this.pos, (er, bytesWritten, buffers) => {

Callers

nothing calls this directly

Calls 4

sliceMethod · 0.65
cbFunction · 0.50
writeMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected