Skip to main content

FSHelpers

Index

Constructors

constructor

Methods

staticcopyRecursive

staticfileExists

  • fileExists(FS: RootFS, path: string): boolean
  • Checks if a file (or a directory) exists in the PHP filesystem.


    Parameters

    • FS: RootFS
    • path: string

      The file path to check.

    Returns boolean

    True if the file exists, false otherwise.

staticisDir

  • isDir(FS: RootFS, path: string): boolean
  • Checks if a directory exists in the PHP filesystem.


    Parameters

    • FS: RootFS
    • path: string

      – The path to check.

    Returns boolean

    True if the path is a directory, false otherwise.

staticlistFiles

  • Lists the files and directories in the given directory.


    Parameters

    Returns string[]

    The list of files and directories in the given directory.

staticmkdir

  • mkdir(FS: RootFS, path: string): void
  • Recursively creates a directory with the given path in the PHP filesystem. For example, if the path is /root/php/data, and /root already exists, it will create the directories /root/php and /root/php/data.


    Parameters

    • FS: RootFS
    • path: string

      The directory path to create.

    Returns void

staticmv

  • mv(FS: RootFS, fromPath: string, toPath: string): void
  • Moves a file or directory in the PHP filesystem to a new location.


    Parameters

    • FS: RootFS
    • fromPath: string
    • toPath: string

    Returns void

staticreadFileAsBuffer

  • readFileAsBuffer(FS: RootFS, path: string): Uint8Array
  • Reads a file from the PHP filesystem and returns it as an array buffer.

    @throws

    @php-wasm/universal:ErrnoError – If the file doesn’t exist.


    Parameters

    • FS: RootFS
    • path: string

      The file path to read.

    Returns Uint8Array

    The file contents.

staticreadFileAsText

  • readFileAsText(FS: RootFS, path: string): string
  • Reads a file from the PHP filesystem and returns it as a string.

    @throws

    @php-wasm/universal:ErrnoError – If the file doesn’t exist.


    Parameters

    • FS: RootFS
    • path: string

      The file path to read.

    Returns string

    The file contents.

staticrmdir

  • Removes a directory from the PHP filesystem.


    Parameters

    • FS: RootFS
    • path: string

      The directory path to remove.

    • options: RmDirOptions = ...

      Options for the removal.

    Returns void

staticunlink

  • unlink(FS: RootFS, path: string): void
  • Removes a file from the PHP filesystem.

    @throws

    @php-wasm/universal:ErrnoError – If the file doesn’t exist.


    Parameters

    • FS: RootFS
    • path: string

      The file path to remove.

    Returns void

staticwriteFile

  • writeFile(FS: RootFS, path: string, data: string | Uint8Array): void
  • Overwrites data in a file in the PHP filesystem. Creates a new file if one doesn’t exist yet.


    Parameters

    • FS: RootFS
    • path: string

      The file path to write to.

    • data: string | Uint8Array

      The data to write to the file.

    Returns void