| 363 | // rejects positioned I/O with ESPIPE (pipes, sockets, terminals), retry |
| 364 | // sequentially and stay sequential for this handle. |
| 365 | private atCursor( |
| 366 | f: (position: bigint | null) => Effect.Effect<number, Error.PlatformError> |
| 367 | ): Effect.Effect<number, Error.PlatformError> { |
| 368 | return Effect.suspend(() => { |
| 369 | if (this.sequential) { |
| 370 | return f(null) |
| 371 | } |
| 372 | const position = this.position |
| 373 | return Effect.catchIf( |
| 374 | Effect.map(f(position), (bytes) => { |
| 375 | this.position = position + BigInt(bytes) |
| 376 | return bytes |
| 377 | }), |
| 378 | isEspipe, |
| 379 | () => { |
| 380 | this.sequential = true |
| 381 | return f(null) |
| 382 | } |
| 383 | ) |
| 384 | }) |
| 385 | } |
| 386 | |
| 387 | private writeOnce(method: string, write: typeof nodeWrite, buffer: Uint8Array) { |
| 388 | return this.append ? |