Skip to content

feat(fs): fsPromises.open + FileHandle class (#972)#1005

Merged
nickna merged 1 commit into
mainfrom
wrk/issue-972-filehandle
Jun 29, 2026
Merged

feat(fs): fsPromises.open + FileHandle class (#972)#1005
nickna merged 1 commit into
mainfrom
wrk/issue-972-filehandle

Conversation

@nickna

@nickna nickna commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Closes #972 (part of epic #968).

fsPromises.open() now resolves a FileHandle — a plain TS class in stdlib/node/fs.ts over 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, idempotent close. Core fd ops share the handle's descriptor; path-scoped conveniences re-derive from the open path (documented divergence). open wired into both fs.promises and the fs/promises module.

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs/promises: open + FileHandle class

1 participant