Check and request permissions for browser File System API.
Returns true immediately if current permission is granted. Requests permission if not granted. Permission request must be called within a user click event.
async function verifyPermission(handle: FileSystemHandle, readWrite: boolean) { const options = {}; if (readWrite) { options.mode = 'readwrite'; }
// 1. Check current permission if ((await handle.queryPermission(options)) === 'granted') { return true; }
// 2. Request permission if not granted if ((await handle.requestPermission(options)) === 'granted') { return true; }
return false;}
hsb.horse