| 44 | } |
| 45 | |
| 46 | async function ply_storage_resolve_root(root_path) { |
| 47 | if (!navigator.storage || !navigator.storage.getDirectory) { |
| 48 | throw new Error("OPFS is not available in this browser"); |
| 49 | } |
| 50 | |
| 51 | var handle = await navigator.storage.getDirectory(); |
| 52 | var parts = root_path.split('/').filter(function (part) { |
| 53 | return part.length > 0; |
| 54 | }); |
| 55 | |
| 56 | for (var i = 0; i < parts.length; i += 1) { |
| 57 | handle = await handle.getDirectoryHandle(parts[i], { create: true }); |
| 58 | } |
| 59 | |
| 60 | return handle; |
| 61 | } |
| 62 | |
| 63 | async function ply_storage_resolve_parent_dir(root_handle, relative_path, create_dirs) { |
| 64 | var parts = ply_storage_split_path(relative_path); |