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

Function writeSyncAll

lib/internal/fs/promises.js:846–867  ·  view source on GitHub ↗
(buf, offset, length, position)

Source from the content-addressed store, hash-verified

844 // Used by writeSync for the full write, and by writevSync for
845 // completing a partial writev.
846 function writeSyncAll(buf, offset, length, position) {
847 let retries = 0;
848 while (length > 0) {
849 const ctx = {};
850 const bytesWritten = binding.writeBuffer(
851 fd, buf, offset, length, position, undefined, ctx) || 0;
852 if (ctx.errno !== undefined) {
853 handleSyncErrorFromBinding(ctx);
854 }
855 if (bytesWritten === 0) {
856 if (++retries > 5) {
857 throw new ERR_OPERATION_FAILED('write failed after retries');
858 }
859 } else {
860 retries = 0;
861 }
862 totalBytesWritten += bytesWritten;
863 offset += bytesWritten;
864 length -= bytesWritten;
865 if (position >= 0) position += bytesWritten;
866 }
867 }
868
869 async function cleanup() {
870 if (closed) return;

Callers 2

writeSyncFunction · 0.85
writevSyncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…