@eryx/vfs Module

Summary

Functions

vfs.isOpen() → boolean
vfs.entrypoint() → string?
vfs.readFile(path: string) → string
vfs.exists(path: string) → boolean
vfs.listDir(dir: string) → { string }
vfs.isFile(path: string) → boolean
vfs.isDir(path: string) → boolean
vfs.mtime(path: string) → number
vfs.build(options: BuildOptions) → boolean
vfs.isIsolated() → boolean
vfs.setIsolated(isolated: boolean) → ()

API Reference

Functions

vfs.isOpen

Returns true if a VFS bundle is currently loaded.

vfs.isOpen() → boolean

vfs.entrypoint

Returns the entrypoint path of the loaded bundle, or nil if no bundle is open.

vfs.entrypoint() → string?

vfs.readFile

Reads the entire contents of a VFS file as a string. Errors if no bundle is open or the file doesn't exist.

vfs.readFile(path: string) → string

vfs.exists

Returns true if the given path exists in the VFS bundle. Returns false if no bundle is open.

vfs.exists(path: string) → boolean

vfs.listDir

Returns an array of direct children (files and directories) in the given VFS directory. Returns an empty table if no bundle is open.

vfs.listDir(dir: string) → { string }

vfs.isFile

Returns true if the given path is a file in the VFS bundle. Returns false if no bundle is open or the path is a directory / doesn't exist.

vfs.isFile(path: string) → boolean

vfs.isDir

Returns true if the given path is a directory in the VFS bundle. A path is a directory if any file exists under it. Returns false if no bundle is open.

vfs.isDir(path: string) → boolean

vfs.mtime

Returns the modification time of a VFS file (as stored at bundle time). Errors if no bundle is open or the file doesn't exist.

vfs.mtime(path: string) → number

vfs.build

Builds a new VFS bundle by cloning an executable and appending a file archive.

vfs.build(options: BuildOptions) → boolean

vfs.isIsolated

Returns true if VFS isolation is enabled (the default). When isolated, VFS scripts cannot fall through to the real filesystem for requires or config resolution.

vfs.isIsolated() → boolean

vfs.setIsolated

Sets VFS isolation mode. When disabled, VFS scripts can fall through to the real filesystem (relative to the exe directory) for requires and config resolution.

vfs.setIsolated(isolated: boolean) → ()

Types

BuildOptions

type BuildOptions = { outputExe: PathLike, root: PathLike, entrypoint: string, files: { PathLike }, sourceExe: PathLike? }
outputExe: PathLike

Path to the output executable.

root: PathLike

Project root directory. All file paths in the bundle are relative to this.

entrypoint: string

Entrypoint script path (relative to root).

files: { PathLike }

Array of file or directory paths to include in the bundle. Directories are expanded recursively.

sourceExe: PathLike?

Source executable to clone. Defaults to the currently running executable.