@@ -61,54 +61,6 @@ different storage mechanism with a different API for such files. The entry point
61
61
62
62
A <dfn export id="entry">file system entry</dfn> is either a [=file entry=] or a [=directory entry=] .
63
63
64
- Each [=/file system entry=] has an associated
65
- <dfn for="file system entry" id=entry-query-access>query access</dfn>
66
- algorithm, which takes "`read`" or "`readwrite`" <var ignore> mode</var> and
67
- returns a [=/file system access result=] .
68
- Unless specified otherwise it returns a [=/file system access result=] with a
69
- [=file system access result/permission state=] of "{{PermissionState/denied}} "
70
- and with an [=file system access result/error name=] of the empty string.
71
-
72
- Each [=/file system entry=] has an associated
73
- <dfn for="file system entry" id=entry-request-access>request access</dfn>
74
- algorithm, which takes "`read`" or "`readwrite`" <var ignore> mode</var> and
75
- returns a [=/file system access result=] .
76
- Unless specified otherwise it returns a [=/file system access result=] with a
77
- [=file system access result/permission state=] of "{{PermissionState/denied}} "
78
- and with an [=file system access result/error name=] of the empty string.
79
-
80
- A <dfn export>file system access result</dfn> is a [=struct=] encapsulating the
81
- result of [=file system entry/query access|querying=] or
82
- [=file system entry/request access|requesting=] access to the file system.
83
- It has the following [=struct/items=] :
84
-
85
- : <dfn for="file system access result">permission state</dfn>
86
- :: A {{PermissionState}}
87
- : <dfn for="file system access result">error name</dfn>
88
- :: A [=string=] which must be the empty string if
89
- [=file system access result/permission state=] is
90
- "{{PermissionState/granted}} "; otherwise an
91
- [=DOMException/name=] listed in the [=`DOMException` names table=] .
92
- It is expected that in most cases when
93
- [=file system access result/permission state=] is not
94
- "{{PermissionState/granted}} ", this should be "{{NotAllowedError}} ".
95
-
96
- <p class=warning> Dependent specifications may consider this API a
97
- [=powerful feature=] . However, unlike other [=powerful features=] whose
98
- [=permission request algorithm=] may throw, [=/file system entry=] 's
99
- [=file system entry/query access=] and [=file system entry/request access=]
100
- algorithms must run [=in parallel=] on the [=file system queue=] and are
101
- therefore not allowed to throw. Instead, the caller is expected to
102
- [=queue a storage task=] to [=/reject=] , as appropriate,
103
- should these algorithms return an [=file system access result/error name=]
104
- other than the empty string.
105
-
106
- Note: Implementations that only implement this specification and not dependent
107
- specifications do not need to bother implementing [=/file system entry=] 's
108
- [=file system entry/query access=] and [=file system entry/request access=] .
109
-
110
- Issue(101): Make access check algorithms associated with a FileSystemHandle.
111
-
112
64
Each [=/file system entry=] has an associated <dfn for="file system entry" id=entry-name>name</dfn> (a [=string=] ).
113
65
114
66
A <dfn>valid file name</dfn> is a [=string=] that is not an empty string, is not equal to "." or "..",
@@ -355,6 +307,52 @@ All other [=list/item=]s of a [=file system locator/path=] will be a
355
307
Issue(109): Consider improving this situation by giving each locator a
356
308
[=storage bucket=] .
357
309
310
+ Each {{FileSystemHandle}} has an associated
311
+ <dfn for=FileSystemHandle export>query access</dfn>
312
+ algorithm, which takes "`read`" or "`readwrite`" <var ignore> mode</var> and
313
+ returns a [=/file system access result=] .
314
+ Unless specified otherwise it returns a [=/file system access result=] with a
315
+ [=file system access result/permission state=] of "{{PermissionState/denied}} "
316
+ and with an [=file system access result/error name=] of the empty string.
317
+
318
+ Each {{FileSystemHandle}} has an associated
319
+ <dfn for=FileSystemHandle export>request access</dfn>
320
+ algorithm, which takes "`read`" or "`readwrite`" <var ignore> mode</var> and
321
+ returns a [=/file system access result=] .
322
+ Unless specified otherwise it returns a [=/file system access result=] with a
323
+ [=file system access result/permission state=] of "{{PermissionState/denied}} "
324
+ and with an [=file system access result/error name=] of the empty string.
325
+
326
+ A <dfn export>file system access result</dfn> is a [=struct=] encapsulating the
327
+ result of [=FileSystemHandle/query access|querying=] or
328
+ [=FileSystemHandle/request access|requesting=] access to the file system.
329
+ It has the following [=struct/items=] :
330
+
331
+ : <dfn for="file system access result">permission state</dfn>
332
+ :: A {{PermissionState}}
333
+ : <dfn for="file system access result">error name</dfn>
334
+ :: A [=string=] which must be the empty string if
335
+ [=file system access result/permission state=] is
336
+ "{{PermissionState/granted}} "; otherwise an
337
+ [=DOMException/name=] listed in the [=`DOMException` names table=] .
338
+ It is expected that in most cases when
339
+ [=file system access result/permission state=] is not
340
+ "{{PermissionState/granted}} ", this should be "{{NotAllowedError}} ".
341
+
342
+ <p class=warning> Dependent specifications may consider this API a
343
+ [=powerful feature=] . However, unlike other [=powerful features=] whose
344
+ [=permission request algorithm=] may throw, {{FileSystemHandle}} 's
345
+ [=FileSystemHandle/query access=] and [=FileSystemHandle/request access=]
346
+ algorithms must run [=in parallel=] on the [=file system queue=] and are
347
+ therefore not allowed to throw. Instead, the caller is expected to
348
+ [=queue a storage task=] to [=/reject=] , as appropriate,
349
+ should these algorithms return an [=file system access result/error name=]
350
+ other than the empty string.
351
+
352
+ Note: Implementations that only implement this specification and not dependent
353
+ specifications do not need to bother implementing {{FileSystemHandle}} 's
354
+ [=FileSystemHandle/query access=] and [=FileSystemHandle/request access=] .
355
+
358
356
<div algorithm="serialization steps">
359
357
{{FileSystemHandle}} objects are [=serializable objects=] .
360
358
@@ -488,9 +486,9 @@ The <dfn method for=FileSystemFileHandle>getFile()</dfn> method steps are:
488
486
1. Let |locator| be [=this=] 's [=FileSystemHandle/locator=] .
489
487
1. Let |global| be [=this=] 's [=relevant global object=] .
490
488
1. [=Enqueue the following steps=] to the [=file system queue=] :
489
+ 1. Let |accessResult| be the result of running |global|'s
490
+ [=FileSystemHandle/query access=] given "`read`".
491
491
1. Let |entry| be the result of [=locating an entry=] given |locator|.
492
- 1. Let |accessResult| be the result of running |entry|'s
493
- [=file system entry/query access=] given "`read`".
494
492
495
493
1. [=Queue a storage task=] with |global| to run these steps:
496
494
1. If |accessResult|'s [=file system access result/permission state=]
@@ -560,15 +558,15 @@ The <dfn method for=FileSystemFileHandle>createWritable(|options|)</dfn> method
560
558
1. Let |realm| be [=this=] 's [=relevant Realm=] .
561
559
1. Let |global| be [=this=] 's [=relevant global object=] .
562
560
1. [=Enqueue the following steps=] to the [=file system queue=] :
563
- 1. Let |entry| be the result of [=locating an entry=] given |locator|.
564
- 1. Let |accessResult| be the result of running |entry|'s
565
- [=file system entry/request access=] given "`readwrite`".
561
+ 1. Let |accessResult| be the result of running |global|'s
562
+ [=FileSystemHandle/request access=] given "`readwrite`".
566
563
1. If |accessResult|'s [=file system access result/permission state=]
567
564
is not "{{PermissionState/granted}} ", [=queue a storage task=] with
568
565
|global| to [=/reject=] |result| with a {{DOMException}} of
569
566
|accessResult|'s [=file system access result/error name=] and
570
567
abort these steps.
571
568
569
+ 1. Let |entry| be the result of [=locating an entry=] given |locator|.
572
570
1. If |entry| is `null`, [=queue a storage task=] with |global| to [=/reject=]
573
571
|result| with a "{{NotFoundError}} " {{DOMException}} and abort these steps.
574
572
1. [=Assert=] : |entry| is a [=file entry=] .
@@ -581,7 +579,7 @@ The <dfn method for=FileSystemFileHandle>createWritable(|options|)</dfn> method
581
579
"{{NoModificationAllowedError}} " {{DOMException}} and abort these steps.
582
580
583
581
1. Let |stream| be the result of <a>creating a new `FileSystemWritableFileStream`</a>
584
- for |entry| in |realm|.
582
+ given |global| and |entry| in |realm|.
585
583
1. If |options|'s {{FileSystemCreateWritableOptions/keepExistingData}} is true:
586
584
1. Set |stream|'s [=[[buffer]]=] to a copy of |entry|' s [=file entry/binary data=] .
587
585
1. [=/Resolve=] |result| with |stream|.
@@ -623,9 +621,8 @@ The <dfn method for=FileSystemFileHandle>createSyncAccessHandle()</dfn> method s
623
621
[=this=] [=FileSystemHandle/is in an origin private file system=] ;
624
622
otherwise false.
625
623
1. [=Enqueue the following steps=] to the [=file system queue=] :
626
- 1. Let |entry| be the result of [=locating an entry=] given |locator|.
627
- 1. Let |accessResult| be the result of running |entry|'s
628
- [=file system entry/request access=] given "`readwrite`".
624
+ 1. Let |accessResult| be the result of running |global|'s
625
+ [=FileSystemHandle/request access=] given "`readwrite`".
629
626
1. If |accessResult|'s [=file system access result/permission state=]
630
627
is not "{{PermissionState/granted}} ", [=queue a storage task=] with
631
628
|global| to [=/reject=] |result| with a {{DOMException}} of
@@ -637,6 +634,7 @@ The <dfn method for=FileSystemFileHandle>createSyncAccessHandle()</dfn> method s
637
634
[=/reject=] |result| with an "{{InvalidStateError}} " {{DOMException}} and
638
635
abort these steps.
639
636
637
+ 1. Let |entry| be the result of [=locating an entry=] given |locator|.
640
638
1. If |entry| is `null`, [=queue a storage task=] with |global| to [=/reject=]
641
639
|result| with a "{{NotFoundError}} " {{DOMException}} and abort these steps.
642
640
1. [=Assert=] : |entry| is a [=file entry=] .
@@ -754,17 +752,17 @@ and its async iterator |iterator|:
754
752
755
753
1. Let |promise| be [=a new promise=] .
756
754
1. [=Enqueue the following steps=] to the [=file system queue=] :
755
+ 1. Let |accessResult| be the result of running |handle|'s
756
+ [=FileSystemHandle/query access=] given "`read`".
757
757
1. Let |directory| be the result of [=locating an entry=]
758
758
given |handle|'s [=FileSystemHandle/locator=] .
759
- 1. Let |accessResult| be the result of running |directory|'s
760
- [=file system entry/query access=] given "`read`".
761
759
762
760
1. [=Queue a storage task=] with |handle|'s [=relevant global object=] to
763
761
run these steps:
764
762
1. If |accessResult|'s [=file system access result/permission state=]
765
763
is not "{{PermissionState/granted}} ", [=/reject=] |promise| with a
766
764
{{DOMException}} of |accessResult|'s
767
- [=file system access result/error name=] and abort these steps.:
765
+ [=file system access result/error name=] and abort these steps.
768
766
769
767
1. If |directory| is `null`, [=/reject=] |result| with a
770
768
"{{NotFoundError}} " {{DOMException}} and abort these steps.
@@ -838,13 +836,14 @@ The <dfn method for=FileSystemDirectoryHandle>getFileHandle(|name|, |options|)</
838
836
|global| to [=/reject=] |result| with a {{TypeError}} and
839
837
abort these steps.
840
838
841
- 1. Let |entry| be the result of [=locating an entry=] given |locator|.
842
839
1. If |options|.{{FileSystemGetFileOptions/create}} is true:
843
- 1. Let |accessResult| be the result of running |entry |'s
844
- [=file system entry /request access=] given "`readwrite`".
840
+ 1. Let |accessResult| be the result of running |global |'s
841
+ [=FileSystemHandle /request access=] given "`readwrite`".
845
842
1. Otherwise:
846
- 1. Let |accessResult| be the result of running |entry|'s
847
- [=file system entry/query access=] given "`read`".
843
+ 1. Let |accessResult| be the result of running |global|'s
844
+ [=FileSystemHandle/query access=] given "`read`".
845
+
846
+ 1. Let |entry| be the result of [=locating an entry=] given |locator|.
848
847
849
848
1. [=Queue a storage task=] with |global| to run these steps:
850
849
1. If |accessResult|'s [=file system access result/permission state=]
@@ -920,13 +919,14 @@ The <dfn method for=FileSystemDirectoryHandle>getDirectoryHandle(|name|, |option
920
919
|global| to [=/reject=] |result| with a {{TypeError}} and
921
920
abort these steps.
922
921
923
- 1. Let |entry| be the result of [=locating an entry=] given |locator|.
924
922
1. If |options|.{{FileSystemGetDirectoryOptions/create}} is true:
925
- 1. Let |accessResult| be the result of running |entry |'s
926
- [=file system entry /request access=] given "`readwrite`".
923
+ 1. Let |accessResult| be the result of running |global |'s
924
+ [=FileSystemHandle /request access=] given "`readwrite`".
927
925
1. Otherwise:
928
- 1. Let |accessResult| be the result of running |entry|'s
929
- [=file system entry/query access=] given "`read`".
926
+ 1. Let |accessResult| be the result of running |global|'s
927
+ [=FileSystemHandle/query access=] given "`read`".
928
+
929
+ 1. Let |entry| be the result of [=locating an entry=] given |locator|.
930
930
931
931
1. [=Queue a storage task=] with |global| to run these steps:
932
932
1. If |accessResult|'s [=file system access result/permission state=]
@@ -997,9 +997,9 @@ The <dfn method for=FileSystemDirectoryHandle>removeEntry(|name|, |options|)</df
997
997
|global| to [=/reject=] |result| with a {{TypeError}} and
998
998
abort these steps.
999
999
1000
+ 1. Let |accessResult| be the result of running |global|'s
1001
+ [=FileSystemHandle/request access=] given "`readwrite`".
1000
1002
1. Let |entry| be the result of [=locating an entry=] given |locator|.
1001
- 1. Let |accessResult| be the result of running |entry|'s
1002
- [=file system entry/request access=] given "`readwrite`".
1003
1003
1004
1004
1. [=Queue a storage task=] with |global| to run these steps:
1005
1005
1. If |accessResult|'s [=file system access result/permission state=]
@@ -1147,19 +1147,24 @@ Similarly, when piping a {{ReadableStream}} into a {{FileSystemWritableFileStrea
1147
1147
<div algorithm>
1148
1148
To
1149
1149
<dfn local-lt="creating a new FileSystemWritableFileStream">create a new `FileSystemWritableFileStream`</dfn>
1150
- given a [=file entry=] |file| in a [=/Realm=] |realm|:
1150
+ given a {{FileSystemFileHandle}} |fileHandle| and a [=file entry=] |fileEntry|
1151
+ in a [=/Realm=] |realm|:
1151
1152
1152
1153
1. Let |stream| be a [=new=] {{FileSystemWritableFileStream}} in |realm|.
1153
- 1. Set |stream|'s [=FileSystemWritableFileStream/[[file]]=] to |file |.
1154
+ 1. Set |stream|'s [=FileSystemWritableFileStream/[[file]]=] to |fileEntry |.
1154
1155
1. Let |writeAlgorithm| be an algorithm which takes a |chunk| argument
1155
- and returns the result of running the [=write a chunk=] algorithm with |stream| and |chunk|.
1156
+ and returns the result of running the [=write a chunk=] algorithm with
1157
+ |fileHandle|, |stream|, and |chunk|.
1156
1158
1. Let |closeAlgorithm| be these steps:
1157
1159
1. Let |closeResult| be [=a new promise=] .
1158
1160
1. [=Enqueue the following steps=] to the [=file system queue=] :
1159
- 1. Let |accessResult| be the result of running |file|'s
1160
- [=file system entry/query access=] given "`readwrite`".
1161
+ 1. [=Assert=] : [=locating an entry=] given |fileHandle|'s
1162
+ [=FileSystemHandle/locator=] returns a [=file entry=] that is
1163
+ [=the same entry as=] |fileEntry|.
1164
+ 1. Let |accessResult| be the result of running |fileHandle|'s
1165
+ [=FileSystemHandle/query access=] given "`readwrite`".
1161
1166
1162
- 1. [=Queue a storage task=] with |file |'s [=relevant global object=]
1167
+ 1. [=Queue a storage task=] with |fileEntry |'s [=relevant global object=]
1163
1168
to run these steps:
1164
1169
1. If |accessResult|'s [=file system access result/permission state=]
1165
1170
is not "{{PermissionState/granted}} ", [=/reject=] |closeResult|
@@ -1179,8 +1184,9 @@ given a [=file entry=] |file| in a [=/Realm=] |realm|:
1179
1184
1. [=Enqueue the following steps=] to the [=file system queue=] :
1180
1185
1. [=file entry/lock/release|Release the lock=] on
1181
1186
|stream|'s [=FileSystemWritableFileStream/[[file]]=] .
1182
- 1. [=Queue a storage task=] with |file|'s [=relevant global object=]
1183
- to [=/resolve=] |closeResult| with `undefined`.
1187
+ 1. [=Queue a storage task=] with
1188
+ |fileEntry|'s [=relevant global object=] to
1189
+ [=/resolve=] |closeResult| with `undefined`.
1184
1190
1185
1191
1. Return |closeResult|.
1186
1192
1. Let |abortAlgorithm| be these steps:
@@ -1200,17 +1206,18 @@ given a [=file entry=] |file| in a [=/Realm=] |realm|:
1200
1206
</div>
1201
1207
1202
1208
<div algorithm>
1203
- The <dfn>write a chunk</dfn> algorithm,
1204
- given a {{FileSystemWritableFileStream}} |stream| and |chunk|,
1209
+ The <dfn>write a chunk</dfn> algorithm, given
1210
+ a {{FileSystemFileHandle}} |fileHandle|,
1211
+ a {{FileSystemWritableFileStream}} |stream|,
1212
+ and a |chunk|,
1205
1213
runs these steps:
1206
1214
1207
1215
1. Let |input| be the result of [=converted to an IDL value|converting=] |chunk| to a {{FileSystemWriteChunkType}} .
1208
1216
If this throws an exception, then return [=a promise rejected with=] that exception.
1209
1217
1. Let |p| be [=a new promise=] .
1210
1218
1. [=Enqueue the following steps=] to the [=file system queue=] :
1211
- 1. Let |accessResult| be the result of running
1212
- |stream|'s [=FileSystemWritableFileStream/[[file]]=]' s
1213
- [=file system entry/query access=] given "`readwrite`".
1219
+ 1. Let |accessResult| be the result of running |fileHandle|'s
1220
+ [=FileSystemHandle/query access=] given "`readwrite`".
1214
1221
1215
1222
1. [=Queue a storage task=] with |stream|'s [=relevant global object=] to
1216
1223
run these steps:
0 commit comments