feat(fs): fsPromises.open + FileHandle class (#972)#1005
Merged
Conversation
Implement the promise-based file-descriptor workflow: `fsPromises.open()` resolves a `FileHandle` wrapping an open fd. The handle is a plain TS class in `stdlib/node/fs.ts` over the existing fd ops, so the interpreter and compiled modes are identical by construction (Approach B, per epic #968). Methods: fd, read/write (-> { bytesRead|bytesWritten, buffer }), readv/writev, readFile/writeFile/appendFile, stat/truncate/chmod/chown/utimes, sync/datasync (resolved no-ops -- SharpTS sync I/O is already durable), createReadStream/ createWriteStream, and an idempotent close. The core fd ops (read/write/stat/truncate/close) share the handle's descriptor exactly; the path-scoped conveniences (streams, chmod/chown/utimes, appendFile) re-derive from the path the handle was opened with -- same file, independent descriptor. `open` is wired into both the `fs.promises` object and the `fs/promises` module (routed through __fsp.open). Additive TS facade only -- no runtime/emitter changes, standalone preserved. Tests: dual-mode open->write->read->stat->truncate->close round-trip and createReadStream-from-handle + ENOENT-on-missing-open. Full suite 14462/0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #972 (part of epic #968).
fsPromises.open()now resolves aFileHandle— a plain TS class instdlib/node/fs.tsover the existing fd ops (Approach B), so interpreter and compiled modes are identical by construction. Zero C# runtime/emitter change; standalone preserved.Methods:
fd,read/write(→{bytesRead|bytesWritten, buffer}),readv/writev,readFile/writeFile/appendFile,stat/truncate/chmod/chown/utimes,sync/datasync,createReadStream/createWriteStream, idempotentclose. Core fd ops share the handle's descriptor; path-scoped conveniences re-derive from the open path (documented divergence).openwired into bothfs.promisesand thefs/promisesmodule.Tests: 2 dual-mode (open→write→read→stat→truncate→close; createReadStream-from-handle + ENOENT-on-missing-open). Full suite 14462/0.
Stacked: merge this first; #976 is stacked on top.