File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -604,9 +604,6 @@ these steps:
604
604
and |child| represents `/home/user/project/foo/bar`, this will return
605
605
`['foo', 'bar'] `.
606
606
:: Otherwise (|directory| and |child| are not related), |path| will be null.
607
-
608
- This functionality can be useful if a web application shows a directory
609
- listing to highlight a file opened through a file picker in that directory listing.
610
607
</div>
611
608
612
609
<div class=example id=filesystemdirectoryhandle-resolve-example>
@@ -615,17 +612,13 @@ these steps:
615
612
const dir_ref = current_project_dir;
616
613
if (!dir_ref) return;
617
614
618
- // Now get a file reference by showing a file picker:
619
- const file_ref = await self.showOpenFilePicker();
620
- if (!file_ref) {
621
- // User cancelled, or otherwise failed to open a file.
622
- return;
623
- }
615
+ // Now get a file reference:
616
+ const file_ref = await dir_ref.getFileHandle(filename, { create: true });
624
617
625
618
// Check if file_ref exists inside dir_ref:
626
619
const relative_path = await dir_ref.resolve(file_ref);
627
620
if (relative_path === null) {
628
- // Not inside dir_ref
621
+ // Not inside dir_ref.
629
622
} else {
630
623
// relative_path is an array of names, giving the relative path
631
624
// from dir_ref to the file that is represented by file_ref:
You can’t perform that action at this time.
0 commit comments