wasm-posix-host
    Preparing search index...

    Class MemoryFileSystem

    Implements

    Index

    Accessors

    • get sharedBuffer(): SharedArrayBuffer

      Return the underlying SharedArrayBuffer (for sharing with workers).

      Returns SharedArrayBuffer

    Methods

    • Parameters

      • path: string
      • mode: number
      • uid: number
      • gid: number
      • content: Uint8Array

      Returns void

    • Materialize a full lazy archive group: fetch the zip once, parse its central directory, and write every non-deleted entry into its stub. Subsequent calls are no-ops.

      Parameters

      • group: LazyArchiveGroup

      Returns Promise<void>

    • Async-materialize a lazy file or archive-backed file if the given path resolves to one. Call this before any synchronous read (e.g. in handleExec) to avoid sync XHR which deadlocks with COOP/COEP. Returns true if something was materialized, false if already concrete.

      Parameters

      • path: string

      Returns Promise<boolean>

    • Export all lazy archive groups for transfer to another instance.

      Returns SerializedLazyArchiveEntry[]

    • Import lazy archive groups from another instance. Assumes stubs already exist.

      Parameters

      • serialized: SerializedLazyArchiveEntry[]

      Returns void

    • Import lazy file entries from another instance (e.g., main thread → worker). Does not create files — assumes the files already exist in the SharedArrayBuffer.

      Parameters

      Returns void

    • Parameters

      • path: string
      • uid: number
      • gid: number

      Returns void

    • Parameters

      • path: string
      • mode: number
      • uid: number
      • gid: number

      Returns void

    • Parameters

      • handle: number
      • buffer: Uint8Array
      • offset: number | null
      • length: number

      Returns number

    • Register a lazy archive group: creates stubs in SharedFS for every file entry and records metadata so that accessing any one of them triggers a single archive fetch that materializes all files in the group.

      Parse the zip's central directory (via host/src/vfs/zip.ts) and pass the resulting ZipEntry[] in zipEntries. mountPrefix maps the zip's internal paths into the VFS (e.g. prefix "/usr/" turns "bin/vim" into "/usr/bin/vim").

      Parameters

      • url: string
      • zipEntries: ZipEntry[]
      • mountPrefix: string
      • OptionalsymlinkTargets: Map<string, string>

      Returns LazyArchiveGroup

    • Register a lazy file: creates an empty stub in SharedFS and records metadata so that read() will fetch content on demand via sync XHR. Returns the inode number (useful for forwarding to other instances).

      Parameters

      • path: string
      • url: string
      • size: number
      • mode: number = 0o755

      Returns number

    • Rewrite the URL of every registered lazy archive group. Useful when the VFS image was built with relative URLs (e.g. "vim.zip") and the runtime needs to resolve them against a deployment base URL.

      Parameters

      • transform: (url: string) => string

      Returns void

    • Rewrite the URL of every registered lazy file. Useful when a VFS image was built with placeholder URLs and the browser runtime needs to replace them with bundler-produced asset URLs.

      Parameters

      • transform: (url: string, path: string) => string

      Returns void

    • Save the current filesystem state as a portable binary image.

      With materializeAll: true, all lazy files are fetched and written into the filesystem before saving, producing a self-contained image. Otherwise, lazy file metadata (path/URL/size) is preserved in the image and restored on load.

      Parameters

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Parameters

      • target: string
      • path: string
      • uid: number
      • gid: number

      Returns void

    • Parameters

      • path: string
      • atimeSec: number
      • atimeNsec: number
      • mtimeSec: number
      • mtimeNsec: number

      Returns void

    • Parameters

      • handle: number
      • buffer: Uint8Array
      • offset: number | null
      • length: number

      Returns number

    • Validate an image's optional kernel ABI declaration. Images without a kernelAbi declaration are accepted so legacy/data-only images keep loading; callers that require an explicit declaration should check readImageMetadata(image)?.kernelAbi first.

      Parameters

      • image: Uint8Array
      • kernelAbi: number
      • label: string = "VFS image"

      Returns void

    • Restore a MemoryFileSystem from a previously saved VFS image. Allocates a new SharedArrayBuffer and populates it from the image.

      When maxByteLength is specified, creates a growable SharedArrayBuffer so the filesystem can expand beyond the image's original size, up to the maximum already recorded in the image superblock.

      Parameters

      • image: Uint8Array
      • Optionaloptions: { maxByteLength?: number }

      Returns MemoryFileSystem