refactor(fs): std/fs path parameters take Into<Path> #549
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/547-fs-into-path"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #547
Task
Step 2 of #68 (PATH slice 2, the boundary): every path parameter of the public
std/fssurface isInto<Path>instead ofString. Loop item torbscript/language#547, 2026-10-28.What
std/fs/src/lib.trb: all path parameters (path,to,target,inside) ofFileand of the private natives areInto<Path>; the non-native wrappers convert once at their entry (textOf, i.e.path.into().show()) and hand the/text to the unchanged private helpers (joinedPath,directoryOf,nameOf,walkInto,copiedEntry,removedEntry,metadataOf,ownerOf,temporaryEntry).IoError.path(aString, now the/text of the path passed),list,walk,absolutePath,symbolicLinkTargetand the temporary-entry results are unchanged.inside: Into<Path>? = Noneis accepted by the checker; noString?fallback needed.fileCreateTemporarykeepspath: String. Its empty text means "the system's directory for temporary files", and anInto<Path>cannot say that:Path.from("")shows as., so the call would create the entry in the working directory (checked with a probe). The publicinsideis converted to text first (inside.map({ textOf _ })) andNonestill passes"". Making itInto<Path>needs the "no directory" case as its own native (a runtime/natives-table change, out of scope here); noted in the doc comment of the native.std/fs/tests/files.test.trb, group "path parameters" (a compile error onmain):readText,writeText,rename/copywithString, literal andPathon either side;IoError.pathis the/text for a native (readText), a hand-built error (readBytes) andmetadata(a//b/./c->a/b/c); wrappers (writeBytes,writeTextAtomically,walk,move,metadata,setPermissions,removeDirectory,createTemporaryFile/Directory(inside: Path)) with aPath. A literal is tested as the failing case (relative, names nothing), so no test writes into the working directory.docs/standard-library/fs.md(declaration blocks, one paragraph),skills/regenerated,docs/design/PATH.mdheader sentence (stays "partly implemented"). No caller outsidestd/fsneeded an edit.Test
Locally only (nightly-20261027 toolchain, which has
23bfecf):torb format --checkon the touched.trbfiles (clean),torb test std/fs/tests/files.test.trb(38 passed, 0 failed, VM),torb docs declarations --check docs(up to date),torb docs skill docs skills(regenerated),tools/check-commits.sh origin/main HEAD(clean). Bootstrap, gates and conformance (.expectedfiles untouched) run in the forge CI.After merge
Nothing (no seed, no release). Step 3 (
IoError.pathaPath) and step 4 (list/walk/absolutePathansweringPath) of #68 follow.Review of
1234646- approved./text to the helpers; internal re-calls (removeDirectory, move) are idempotent. The fileCreateTemporary exception (empty text = system temp dir, Path.from("") is.) is sound and documented at the native.Non-blocking:
.(e.g.createDirectory("")becomes a no-op instead of an error). Consider one line in fs.md next to the new paragraph.ir,manifest,parse,tokens,ast,highlightandnativesparse withstd/cli(step 3 of #124) #550ir,manifest,parse,tokens,ast,highlightandnativesparse withstd/cli(step 3 of #124) #550