Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/fs.js>getDirHandle

A JavaScript extension package for building strong and modern applications.
Latest
function getDirHandle
import { getDirHandle } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/fs.js";

Obtains the directory handle of the given path.

NOTE: This function is only available in the browser.

NOTE: If the path is not provided or is empty, the root directory handle will be returned.

Examples

Example 1

// with the default storage
import { getDirHandle } from "@ayonli/jsext/fs";

const dir = await getDirHandle("/path/to/dir");

Example 2

// with a user-selected directory as root (Chromium only)
import { getDirHandle } from "@ayonli/jsext/fs";

const root = await window.showDirectoryPicker();
const dir = await getDirHandle("/path/to/dir", { root });

Example 3

// create the directory if not exist
import { getDirHandle } from "@ayonli/jsext/fs";

const dir = await getDirHandle("/path/to/dir", { create: true, recursive: true });

Example 4

// return the root directory handle
import { getDirHandle } from "@ayonli/jsext/fs";

const root = await getDirHandle();

Parameters

optional
path = [UNSUPPORTED]
optional
options = [UNSUPPORTED]