import { getDirHandle } from "https://deno.land/x/ayonli_jsext@v0.9.72/fs.ts";
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
Example 1
// with the default storage
import { getDirHandle } from "@ayonli/jsext/fs";
const dir = await getDirHandle("/path/to/dir");
Example 2
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
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
Example 4
// return the root directory handle
import { getDirHandle } from "@ayonli/jsext/fs";
const root = await getDirHandle();
Parameters
optional
options: GetDirOptions = [UNSUPPORTED]