@@ -3,6 +3,7 @@ Group: WHATWG
3
3
H1 : File System
4
4
Shortname : fs
5
5
Text Macro : TWITTER whatfilesystem
6
+ Text Macro : LATESTRD 2022-03
6
7
Abstract : File System defines infrastructure for file systems as well as their API.
7
8
Indent : 2
8
9
Markup Shorthands : css no, markdown yes
@@ -673,9 +674,6 @@ these steps:
673
674
and |child| represents `/home/user/project/foo/bar`, this will return
674
675
`['foo', 'bar'] `.
675
676
:: Otherwise (|directory| and |child| are not related), |path| will be null.
676
-
677
- This functionality can be useful if a web application shows a directory
678
- listing to highlight a file opened through a file picker in that directory listing.
679
677
</div>
680
678
681
679
<div class=example id=filesystemdirectoryhandle-resolve-example>
@@ -684,17 +682,13 @@ these steps:
684
682
const dir_ref = current_project_dir;
685
683
if (!dir_ref) return;
686
684
687
- // Now get a file reference by showing a file picker:
688
- const file_ref = await self.showOpenFilePicker();
689
- if (!file_ref) {
690
- // User cancelled, or otherwise failed to open a file.
691
- return;
692
- }
685
+ // Now get a file reference:
686
+ const file_ref = await dir_ref.getFileHandle(filename, { create: true });
693
687
694
688
// Check if file_ref exists inside dir_ref:
695
689
const relative_path = await dir_ref.resolve(file_ref);
696
690
if (relative_path === null) {
697
- // Not inside dir_ref
691
+ // Not inside dir_ref.
698
692
} else {
699
693
// relative_path is an array of names, giving the relative path
700
694
// from dir_ref to the file that is represented by file_ref:
0 commit comments