(method: string, buffer: Uint8Array)
| 273 | } |
| 274 | |
| 275 | private writeChunk(method: string, buffer: Uint8Array) { |
| 276 | return Effect.suspend(() => { |
| 277 | const position = this.position |
| 278 | return Effect.map( |
| 279 | tryPromise( |
| 280 | method, |
| 281 | undefined, |
| 282 | async () => { |
| 283 | if (!this.append && this.nativePosition !== position) { |
| 284 | this.file.seekSync(position, Deno.SeekMode.Start) |
| 285 | } |
| 286 | this.nativePosition = undefined |
| 287 | return await this.file.write(buffer) |
| 288 | } |
| 289 | ), |
| 290 | (bytesWritten) => { |
| 291 | const sizeWritten = FileSystem.Size(bytesWritten) |
| 292 | if (this.append) { |
| 293 | this.nativePosition = undefined |
| 294 | } else { |
| 295 | this.position = this.nativePosition = position + sizeWritten |
| 296 | } |
| 297 | return sizeWritten |
| 298 | } |
| 299 | ) |
| 300 | }) |
| 301 | } |
| 302 | |
| 303 | write(buffer: Uint8Array) { |
| 304 | return this.writeChunk("write", buffer) |
no test coverage detected