Skip to main content

Module file

Module file 

Source
Expand description

Native file module for high-level filesystem operations.

Exports: file.read_text, file.write_text, file.read_lines, file.append

All operations go through FileSystemProvider so that sandbox/VFS modes work transparently. The default provider is RealFileSystem.

Policy gated: read ops require FsRead, write ops require FsWrite.

Phase 2c migration: ported to the typed marshal layer. file.read_bytes / file.write_bytes are deferred until the Array<number> marshal extension (FromSlot/ToSlot for typed-array heap pointers) lands. Tracked alongside the parser-module deferral list. The functions previously here read/wrote byte arrays via the deleted as_any_array().to_generic() tag_bits dispatch — strict-typed answer is Arc<TypedBuffer<f64>> typed args + ToSlot projection of ConcreteReturn::ArrayF64 to a heap-allocated TypedArray slot.

Functions§

create_file_module
Create the file module using the default real filesystem.
create_file_module_with_provider
Create a file module that uses the given filesystem provider. The default create_file_module() uses RealFileSystem; callers can substitute a PolicyEnforcedFs or VirtualFileSystem for sandboxing.