Baseline 2023
Newly available
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
The resolve()
method of the FileSystemDirectoryHandle
interface returns an Array
of directory names from the parent handle to the specified child entry, with the name of the child entry as the last array item.
resolve(possibleDescendant)
Parameters
possibleDescendant
The FileSystemHandle
from which to return the relative path.
A Promise
which resolves with an Array
of strings, or null
if possibleDescendant
is not a descendant of this FileSystemDirectoryHandle
.
No exceptions are thrown.
ExamplesThe following asynchronous function uses resolve()
to find the path to a chosen file, relative to a specified directory handle.
async function returnPathDirectories(directoryHandle) {
// Get a file handle by showing a file picker:
const [handle] = await self.showOpenFilePicker();
if (!handle) {
// User cancelled, or otherwise failed to open a file.
return;
}
// Check if handle exists inside our directory handle
const relativePaths = await directoryHandle.resolve(handle);
if (relativePaths === null) {
// Not inside directory handle
} else {
// relativePath is an array of names, giving the relative path
for (const name of relativePaths) {
// log each entry
console.log(name);
}
}
}
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4