@opfs.js/core
    Preparing search index...

    Class OPDir

    Represents a directory in the OPFS (Origin Private File System). Provides methods to create, query, enumerate, copy, move, and remove directories.

    import { dir } from "@opfs.js/core";

    const myDir = dir("/documents");
    await myDir.create();

    // List children
    const children = await myDir.children();
    children.forEach(child => console.log(child.fullPath));

    // Copy directory
    const destDirHandle = await navigator.storage.getDirectory();
    await myDir.copyTo(destDirHandle);

    // Remove directory
    await myDir.remove();

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    fullPath: string

    Full path of the file system object

    kind: "directory"

    Directory kind: always "directory"

    name: string

    Name of the file or directory

    parents: string[]

    Parent directories as an array of strings

    Methods

    • Lists the immediate children of this directory.

      Returns Promise<(OPFile | OPDir)[]>

      An array of OPFile and OPDir instances representing the children.

    • Copy this directory and its contents to a destination directory.

      Parameters

      • dest: FileSystemDirectoryHandle | OPDir

        Destination directory handle or OPDir instance.

      Returns Promise<void>

    • Create the directory in OPFS. If it already exists, does nothing.

      Returns Promise<FileSystemDirectoryHandle>

      The underlying FileSystemDirectoryHandle.

    • Checks if the directory exists.

      Returns Promise<boolean>

      true if the directory exists, false otherwise.

    • Move this directory to a destination.

      Parameters

      • dest: FileSystemDirectoryHandle | OPDir

        Destination directory handle or OPDir instance.

      Returns Promise<void>

    • Remove the directory.

      • If this is the root directory (no name), all its entries will be removed.
      • Otherwise, removes this directory from its parent.

      Returns Promise<void>

      Uses a concurrency pool to efficiently delete multiple entries.