| 248 | } |
| 249 | |
| 250 | readAlloc(size: FileSystem.SizeInput) { |
| 251 | const sizeNumber = Number(size) |
| 252 | return Effect.suspend(() => { |
| 253 | const buffer = new Uint8Array(sizeNumber) |
| 254 | return Effect.map(this.readChunk("readAlloc", buffer), (bytesRead) => { |
| 255 | if (bytesRead === BigInt(0)) { |
| 256 | return Option.none() |
| 257 | } |
| 258 | return Option.some(bytesRead === BigInt(sizeNumber) ? buffer : buffer.subarray(0, Number(bytesRead))) |
| 259 | }) |
| 260 | }) |
| 261 | } |
| 262 | |
| 263 | truncate(length?: FileSystem.SizeInput) { |
| 264 | const size = FileSystem.Size(length ?? 0) |