(chunk)
| 943 | }, |
| 944 | |
| 945 | writeSync(chunk) { |
| 946 | if (error || closed || asyncPending) return false; |
| 947 | chunk = newStreamsToUint8Array(chunk); |
| 948 | const length = chunk.byteLength; |
| 949 | if (length > syncWriteThreshold) return false; |
| 950 | if (length === 0) return true; |
| 951 | if (bytesRemaining >= 0 && length > bytesRemaining) return false; |
| 952 | const position = pos; |
| 953 | // First attempt - if this fails with zero bytes written, |
| 954 | // return false so pipeTo can fall back to async write(). |
| 955 | const ctx = {}; |
| 956 | const bytesWritten = binding.writeBuffer( |
| 957 | fd, chunk, 0, length, position, undefined, ctx) || 0; |
| 958 | if (ctx.errno !== undefined) return false; |
| 959 | totalBytesWritten += bytesWritten; |
| 960 | if (position >= 0) { |
| 961 | pos = position + bytesWritten; |
| 962 | } |
| 963 | if (bytesWritten === length) { |
| 964 | if (bytesRemaining > 0) bytesRemaining -= length; |
| 965 | return true; |
| 966 | } |
| 967 | // Partial write - bytes are on disk. Must complete or throw. |
| 968 | // Cannot return false here because pipeTo would re-send the |
| 969 | // full chunk, causing duplicate data on disk. |
| 970 | writeSyncAll(chunk, bytesWritten, length - bytesWritten, |
| 971 | position >= 0 ? position + bytesWritten : -1); |
| 972 | if (bytesRemaining > 0) bytesRemaining -= length; |
| 973 | return true; |
| 974 | }, |
| 975 | |
| 976 | writevSync(chunks) { |
| 977 | if (error || closed || asyncPending) return false; |
no test coverage detected
searching dependent graphs…