happy-opfs
    Preparing search index...

    Function copy

    • Copies a file or directory from one location to another, similar to cp -r. Both source and destination must be of the same type (both files or both directories).

      Parameters

      • srcPath: string

        The absolute source path.

      • destPath: string

        The absolute destination path.

      • Optionaloptions: CopyOptions

        Optional copy options.

        Options for copy.

        • Optionaloverwrite?: boolean

          Whether to overwrite the destination file if it already exists.

          true

      Returns AsyncVoidIOResult

      A promise that resolves to an AsyncVoidIOResult indicating success or failure.

      1.7.0

      move for moving instead of copying

      // Copy a file
      await copy('/src/file.txt', '/dest/file.txt');

      // Copy a directory
      await copy('/src/folder', '/dest/folder');

      // Copy without overwriting existing files
      await copy('/src', '/dest', { overwrite: false });