(method: string, buffer: Uint8Array)
| 307 | } |
| 308 | |
| 309 | private writeChunk(method: string, buffer: Uint8Array) { |
| 310 | return Effect.suspend(() => { |
| 311 | const position = this.position |
| 312 | return Effect.map( |
| 313 | tryPromise( |
| 314 | method, |
| 315 | undefined, |
| 316 | (signal) => |
| 317 | this.native(signal, async () => { |
| 318 | if (!this.append && this.nativePosition !== position) { |
| 319 | this.file.seekSync(position, Deno.SeekMode.Start) |
| 320 | } |
| 321 | this.nativePosition = undefined |
| 322 | const bytesWritten = await this.file.write(buffer) |
| 323 | if (!this.append) { |
| 324 | this.nativePosition = position + BigInt(bytesWritten) |
| 325 | } |
| 326 | return bytesWritten |
| 327 | }) |
| 328 | ), |
| 329 | (bytesWritten) => { |
| 330 | if (!this.append) { |
| 331 | this.position = position + BigInt(bytesWritten) |
| 332 | } |
| 333 | return bytesWritten |
| 334 | } |
| 335 | ) |
| 336 | }) |
| 337 | } |
| 338 | |
| 339 | write(buffer: Uint8Array) { |
| 340 | return this.writeChunk("write", buffer) |
no test coverage detected