Class PortFS

PortFS lets you access an FS instance that is running in a port, or the other way around.

Note that direct synchronous operations are not permitted on the PortFS, regardless of the configuration option of the remote FS.

Hierarchy

Constructors

  • Constructs a new PortFS instance that connects with the FS running on options.port.

    Parameters

    • options: Options

    Returns PortFS

Properties

_disableSync?: boolean

Whether the sync cache should be disabled. Only affects async things.

options: Options
port: Port

Methods

  • Test whether or not path exists.

    Parameters

    • path: string

    Returns Promise<boolean>

  • Test whether or not path exists.

    Parameters

    • path: string

    Returns boolean

  • Parameters

    • srcpath: string
    • dstpath: string

    Returns Promise<void>

  • Parameters

    • target: string
    • link: string

    Returns void

  • Opens the file at path with flag. The file must exist.

    Parameters

    • path: string

      The path to open.

    • flag: string

      The flag to use when opening the file.

    Returns Promise<File<FileSystem>>

  • Opens the file at path with flag. The file must exist.

    Parameters

    • path: string

      The path to open.

    • flag: string

      The flag to use when opening the file.

    Returns File<FileSystem>

  • Returns Promise<void>

  • Reads into a buffer

    Parameters

    • path: string
    • buffer: Uint8Array<ArrayBufferLike>

      The buffer to read into. You must set the byteOffset and byteLength appropriately!

    • offset: number

      The offset into the file to start reading from

    • length: number

    Returns Promise<void>

  • Parameters

    • path: string

    Returns Promise<string[]>

  • Parameters

    • path: string

    Returns string[]

  • Reads into a buffer

    Parameters

    • path: string
    • buffer: Uint8Array<ArrayBufferLike>

      The buffer to read into. You must set the byteOffset and byteLength appropriately!

    • offset: number

      The offset into the file to start reading from

    • end: number

      The position in the file to stop reading

    Returns void

  • Parameters

    • oldPath: string
    • newPath: string

    Returns Promise<void>

  • Parameters

    • oldPath: string
    • newPath: string

    Returns void

  • Parameters

    • path: string

    Returns Promise<void>

  • Parameters

    • path: string

    Returns void

  • Type Parameters

    • const T extends
          | "link"
          | "write"
          | "rename"
          | "stat"
          | "createFile"
          | "openFile"
          | "unlink"
          | "rmdir"
          | "mkdir"
          | "readdir"
          | "sync"
          | "read"
          | "ready"
          | "exists"
          | "metadata"

    Parameters

    • method: T
    • ...args: Parameters<
          ExtractProperties<
              FileSystem,
              (...args: any[]) => Promise<any> | FileSystemMetadata,
          >[T],
      >

    Returns Promise<
        Awaited<
            ReturnType<
                ExtractProperties<
                    FileSystem,
                    (...args: any[]) => Promise<any> | FileSystemMetadata,
                >[T],
            >,
        >,
    >

  • Parameters

    • path: string
    • data: undefined | Uint8Array<ArrayBufferLike>
    • stats: Readonly<InodeLike | Inode>

    Returns Promise<void>

  • Parameters

    • path: string
    • Optionaldata: Uint8Array<ArrayBufferLike>
    • Optionalstats: Readonly<Partial<StatsLike<number | bigint>>>

    Returns void

  • Parameters

    • path: string

    Returns Promise<void>

  • Parameters

    • path: string

    Returns void

  • Writes a buffer to a file

    Parameters

    • path: string
    • buffer: Uint8Array<ArrayBufferLike>

      The buffer to write. You must set the byteOffset and byteLength appropriately!

    • offset: number

      The offset in the file to start writing

    Returns Promise<void>

  • Writes a buffer to a file

    Parameters

    • path: string
    • buffer: Uint8Array<ArrayBufferLike>

      The buffer to write. You must set the byteOffset and byteLength appropriately!

    • offset: number

      The offset in the file to start writing

    Returns void