Aller au contenu principal

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.

staticisFile

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


    Parameters

    • FS: RootFS
    • path: string

      – The path to check.

    Returns boolean

    True if the path is a file, false otherwise.

staticisSymlink

  • isSymlink(FS: RootFS, path: string): boolean
  • Checks if a path is a symlink in the PHP filesystem.


    Parameters

    Returns boolean

    True if the path is a symlink, 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

      The path to rename.

    • toPath: string

      The new path.

    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.

staticreadlink

  • readlink(FS: RootFS, path: string): string
  • Reads the target of a symlink in the PHP filesystem.

    @throws

    @php-wasm/universal:ErrnoError – If the path is not a symlink.


    Parameters

    Returns string

    The target of the symlink.

staticrealpath

  • realpath(FS: RootFS, path: string): string
  • Gets the real path of a file in the PHP filesystem.


    Parameters

    Returns string

    The real path of the file.

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

staticsymlink

  • symlink(FS: RootFS, target: string, link: string): any
  • Creates a symlink in the PHP filesystem.


    Parameters

    • FS: RootFS
    • target: string
    • link: string

    Returns any

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