@@ -76,7 +76,7 @@ cases where a website wants to save data to disk before a user has picked a
76
76
location to save to, without forcing the website to use a completely different
77
77
storage mechanism with a different API for such files. It also makes it easier
78
78
to write automated tests for code using this API. The entry point for this is the
79
- {{getOriginPrivateDirectory ()}} method. This is similar to the temporary file
79
+ {{getPrivateDirectory ()}} method. This is similar to the temporary file
80
80
system as defined in earlier drafts of [[file-system-api|File API: Directories and System]] .
81
81
82
82
# Files and Directories # {#files-and-directories}
@@ -109,7 +109,7 @@ An [=/entry=]'s [=entry/parent=] is null if no such directory entry exists.
109
109
Note: Two different [=/entries=] can represent the same file or directory on disk, in which
110
110
case it is possible for both entries to have a different parent, or for one entry to have a
111
111
parent while the other entry does not have a parent. Typically an entry does not have a parent
112
- if it was returned by {{getOriginPrivateDirectory ()}} or one of the [=native file system handle factories=] ,
112
+ if it was returned by {{getPrivateDirectory ()}} or one of the [=native file system handle factories=] ,
113
113
and an entry will have a parent in all other cases.
114
114
115
115
[=/Entries=] can (but don't have to) be backed by files on the systems native file system,
@@ -809,7 +809,7 @@ const dir_ref = current_project_dir;
809
809
if (!dir_ref) return;
810
810
811
811
// Now get a file reference by showing a file picker:
812
- const file_ref = await self.chooseFileSystemEntries({type: 'openFile' } );
812
+ const file_ref = await FileSystem.showOpenFilePicker( );
813
813
if (!file_ref) {
814
814
// User cancelled, or otherwise failed to open a file.
815
815
return;
@@ -1136,10 +1136,13 @@ dictionary SaveFilePickerOptions : FilePickerOptions {
1136
1136
dictionary DirectoryPickerOptions {
1137
1137
};
1138
1138
1139
- [SecureContext]
1140
- partial interface Window {
1139
+ [SecureContext, Exposed=(Window,Worker)]
1140
+ namespace FileSystem {
1141
+ [Exposed=Window]
1141
1142
Promise<sequence<FileSystemFileHandle> > showOpenFilePicker(optional OpenFilePickerOptions options = {});
1143
+ [Exposed=Window]
1142
1144
Promise<FileSystemFileHandle> showSaveFilePicker(optional SaveFilePickerOptions options = {});
1145
+ [Exposed=Window]
1143
1146
Promise<FileSystemDirectoryHandle> showDirectoryPicker(optional DirectoryPickerOptions options = {});
1144
1147
};
1145
1148
</xmp>
@@ -1183,12 +1186,12 @@ To verify that an |environment| <dfn>is allowed to show a file picker</dfn>, run
1183
1186
## The {{showOpenFilePicker()}} method ## {#api-showopenfilepicker}
1184
1187
1185
1188
<div class="note domintro">
1186
- : [ |handle| ] = await window . {{showOpenFilePicker()}}
1187
- : [ |handle| ] = await window . {{showOpenFilePicker()|showOpenFilePicker}} ({ {{OpenFilePickerOptions/multiple}} : false })
1189
+ : [ |handle| ] = await {{FileSystem}} . {{showOpenFilePicker()}}
1190
+ : [ |handle| ] = await {{FileSystem}} . {{showOpenFilePicker()|showOpenFilePicker}} ({ {{OpenFilePickerOptions/multiple}} : false })
1188
1191
:: Shows a file picker that lets a user select a single existing file, returning a handle for
1189
1192
the selected file.
1190
1193
1191
- : handles = await window . {{showOpenFilePicker()|showOpenFilePicker}} ({ {{OpenFilePickerOptions/multiple}} : true })
1194
+ : handles = await {{FileSystem}} . {{showOpenFilePicker()|showOpenFilePicker}} ({ {{OpenFilePickerOptions/multiple}} : true })
1192
1195
:: Shows a file picker that lets a user select multiple existing files, returning handles for
1193
1196
the selected files.
1194
1197
@@ -1197,7 +1200,7 @@ To verify that an |environment| <dfn>is allowed to show a file picker</dfn>, run
1197
1200
</div>
1198
1201
1199
1202
<div algorithm>
1200
- The <dfn method for=Window >showOpenFilePicker(|options|)</dfn> method, when invoked, must run
1203
+ The <dfn method for=FileSystem >showOpenFilePicker(|options|)</dfn> method, when invoked, must run
1201
1204
these steps:
1202
1205
1203
1206
1. Let |accepts options| be the result of [=process accept types|processing accept types=] given |options|.
@@ -1246,10 +1249,10 @@ these steps:
1246
1249
1247
1250
</div>
1248
1251
1249
- ## The {{Window/ showSaveFilePicker()}} method ## {#api-showsavefilepicker}
1252
+ ## The {{showSaveFilePicker()}} method ## {#api-showsavefilepicker}
1250
1253
1251
1254
<div class="note domintro">
1252
- : |handle| = await window . {{showSaveFilePicker()|showSaveFilePicker}} ( |options| )
1255
+ : |handle| = await {{FileSystem}} . {{showSaveFilePicker()|showSaveFilePicker}} ( |options| )
1253
1256
:: Shows a file picker that lets a user select a single file, returning a handle for
1254
1257
the selected file. The selected file does not have to exist already. If the selected
1255
1258
file does not exist a new empty file is created before this method returns, otherwise
@@ -1260,7 +1263,7 @@ these steps:
1260
1263
</div>
1261
1264
1262
1265
<div algorithm>
1263
- The <dfn method for=Window >showSaveFilePicker(|options|)</dfn> method, when invoked, must run
1266
+ The <dfn method for=FileSystem >showSaveFilePicker(|options|)</dfn> method, when invoked, must run
1264
1267
these steps:
1265
1268
1266
1269
1. Let |accepts options| be the result of [=process accept types|processing accept types=] given |options|.
@@ -1394,7 +1397,7 @@ run these steps:
1394
1397
1. If |parsedType|'s [=MIME type/type=] is "*", return `true`.
1395
1398
1. If |parsedType|'s [=MIME type/type=] is |type|' s [=MIME type/type=] , return `true`.
1396
1399
1. |parsedType|'s [=MIME type/essence=] is |type|' s [=MIME type/essence=] , return `true`.
1397
- 1. If |extensions| is a string, set |extensions| to a [=list=] with a single
1400
+ 1. If |extensions| is a string, set |extensions| to a [=/ list=] with a single
1398
1401
element equal to |extensions|.
1399
1402
1. [=list/For each=] |extension| of |extensions|:
1400
1403
1. If |filename| ends with "." followed by |extension|, return `true`.
@@ -1417,16 +1420,16 @@ run these steps:
1417
1420
1418
1421
</div>
1419
1422
1420
- ## The {{Window/ showDirectoryPicker()}} method ## {#api-showdirectorypicker}
1423
+ ## The {{showDirectoryPicker()}} method ## {#api-showdirectorypicker}
1421
1424
1422
1425
<div class="note domintro">
1423
- : |handle| = await window . {{Window/ showDirectoryPicker()}}
1426
+ : |handle| = await {{FileSystem}} . {{showDirectoryPicker()}}
1424
1427
:: Shows a directory picker that lets the user select a single directory, returning a handle for
1425
1428
the selected directory.
1426
1429
</div>
1427
1430
1428
1431
<div algorithm>
1429
- The <dfn method for=Window >showDirectoryPicker(<var ignore>options</var>)</dfn> method, when invoked, must run
1432
+ The <dfn method for=FileSystem >showDirectoryPicker(<var ignore>options</var>)</dfn> method, when invoked, must run
1430
1433
these steps:
1431
1434
1432
1435
1. Let |environment| be <b> [=this=] </b> 's [=relevant settings object=] .
@@ -1564,22 +1567,22 @@ user accessible. Similarly there is no expectation that files or directories wit
1564
1567
matching the names of children of the [=origin private file system=] exist.
1565
1568
1566
1569
<xmp class=idl>
1567
- [SecureContext]
1568
- partial interface mixin WindowOrWorkerGlobalScope {
1569
- Promise<FileSystemDirectoryHandle> getOriginPrivateDirectory ();
1570
+ [SecureContext, Exposed=(Window,Worker) ]
1571
+ partial namespace FileSystem {
1572
+ Promise<FileSystemDirectoryHandle> getPrivateDirectory ();
1570
1573
};
1571
1574
</xmp>
1572
1575
1573
1576
Advisement: In Chrome this functionality was previously exposed as `FileSystemDirectoryHandle.getSystemDirectory({type: "sandbox"})`.
1574
1577
This new method is available as of Chrome 85.
1575
1578
1576
1579
<div class="note domintro">
1577
- : |directoryHandle| = await window . {{getOriginPrivateDirectory ()}}
1580
+ : |directoryHandle| = await {{FileSystem}} . {{getPrivateDirectory ()}}
1578
1581
:: Returns the root directory of the origin private file system.
1579
1582
</div>
1580
1583
1581
1584
<div algorithm>
1582
- The <dfn method for=WindowOrWorkerGlobalScope>getOriginPrivateDirectory ()</dfn> method, when
1585
+ The <dfn method for=FileSystem>getPrivateDirectory ()</dfn> method, when
1583
1586
invoked, must run these steps:
1584
1587
1585
1588
1. Let |environment| be the [=current settings object=] .
0 commit comments