-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.bs
1779 lines (1430 loc) · 83.4 KB
/
index.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<pre class=metadata>
Group: WHATWG
H1: File System
Shortname: fs
Text Macro: TWITTER whatfilesystem
Text Macro: LATESTRD 2023-09
Abstract: File System defines infrastructure for file systems as well as their API.
Translation: ja https://triple-underscore.github.io/fs-ja.html
Indent: 2
Markup Shorthands: css no, markdown yes
</pre>
<pre class=link-defaults>
spec:webidl; type:dfn; text:resolve
</pre>
<pre class=anchors>
urlPrefix: https://tc39.es/ecma262/; spec: ECMA-262
type: dfn; text: current realm; url: current-realm
type: dfn; text: realm; url: realm
urlPrefix: https://storage.spec.whatwg.org/; spec: storage
type: dfn; text: storage; url: site-storage
type: dfn; text: storage bucket; url: storage-bucket
</pre>
<style>
.domintro dt {
font-family: Menlo, Consolas, "DejaVu Sans Mono", Monaco, monospace;
padding-top: 0.5em;
padding-bottom: 1em;
}
.domintro dt a {
color: inherit; border-bottom-style: none;
}
.domintro dt code {
font-size: inherit;
}
.domintro::before {
content: 'For web developers (non-normative)';
text-transform: initial;
}
</style>
# Introduction # {#introduction}
*This section is non-normative.*
This document defines fundamental infrastructure for file system APIs. In addition, it defines an
API that makes it possible for websites to get access to a file system directory without having to
first prompt the user for access. This enables use cases where a website wants to save data to disk
before a user has picked a location to save to, without forcing the website to use a completely
different storage mechanism with a different API for such files. The entry point for this is the
{{StorageManager/getDirectory()|navigator.storage.getDirectory()}} method.
# Files and Directories # {#files-and-directories}
## Concepts ## {#concepts}
A <dfn export id="entry">file system entry</dfn> is either a [=file entry=] or a [=directory entry=].
Each [=/file system entry=] has an associated
<dfn for="file system entry" id=entry-query-access>query access</dfn>
algorithm, which takes "`read`" or "`readwrite`" <var ignore>mode</var> and
returns a [=/file system access result=].
Unless specified otherwise it returns a [=/file system access result=] with a
[=file system access result/permission state=] of "{{PermissionState/denied}}"
and with an [=file system access result/error name=] of the empty string.
Each [=/file system entry=] has an associated
<dfn for="file system entry" id=entry-request-access>request access</dfn>
algorithm, which takes "`read`" or "`readwrite`" <var ignore>mode</var> and
returns a [=/file system access result=].
Unless specified otherwise it returns a [=/file system access result=] with a
[=file system access result/permission state=] of "{{PermissionState/denied}}"
and with an [=file system access result/error name=] of the empty string.
A <dfn export>file system access result</dfn> is a [=struct=] encapsulating the
result of [=file system entry/query access|querying=] or
[=file system entry/request access|requesting=] access to the file system.
It has the following [=struct/items=]:
: <dfn for="file system access result">permission state</dfn>
:: A {{PermissionState}}
: <dfn for="file system access result">error name</dfn>
:: A [=string=] which must be the empty string if
[=file system access result/permission state=] is
"{{PermissionState/granted}}"; otherwise an
[=DOMException/name=] listed in the <a>`DOMException` names table</a>.
It is expected that in most cases when
[=file system access result/permission state=] is not
"{{PermissionState/granted}}", this should be "{{NotAllowedError}}".
<p class=warning> Dependent specifications may consider this API a
[=powerful feature=]. However, unlike other [=powerful features=] whose
[=permission request algorithm=] may throw, [=/file system entry=]'s
[=file system entry/query access=] and [=file system entry/request access=]
algorithms must run [=in parallel=] on the [=file system queue=] and are
therefore not allowed to throw. Instead, the caller is expected to
[=queue a storage task=] to [=/reject=], as appropriate,
should these algorithms return an [=file system access result/error name=]
other than the empty string.
Note: Implementations that only implement this specification and not dependent
specifications do not need to bother implementing [=/file system entry=]'s
[=file system entry/query access=] and [=file system entry/request access=].
Issue(101): Make access check algorithms associated with a FileSystemHandle.
Each [=/file system entry=] has an associated <dfn for="file system entry" id=entry-name>name</dfn> (a [=string=]).
A <dfn>valid file name</dfn> is a [=string=] that is not an empty string, is not equal to "." or "..",
and does not contain '/' or any other character used as path separator on the underlying platform.
Note: This means that '\' is not allowed in names on Windows, but might be allowed on
other operating systems. Additionally underlying file systems might have further restrictions
on what names are or aren't allowed, so a string merely being a [=valid file name=] is not
a guarantee that creating a file or directory with that name will succeed.
Issue: We should consider having further normative restrictions on file names that will
never be allowed using this API, rather than leaving it entirely up to underlying file
systems.
A <dfn export id=file>file entry</dfn> additionally consists of
<dfn for="file entry" export>binary data</dfn> (a [=byte sequence=]), a
<dfn for="file entry">modification timestamp</dfn> (a number representing the number of milliseconds since the <a spec=FileAPI>Unix Epoch</a>),
a <dfn for="file entry">lock</dfn> (a string that may exclusively be "`open`", "`taken-exclusive`" or "`taken-shared`")
and a <dfn for="file entry">shared lock count</dfn> (a number representing the number shared locks that are taken at a given point in time).
A user agent has an associated <dfn>file system queue</dfn> which is the
result of [=starting a new parallel queue=]. This queue is to be used for all
file system operations.
<div algorithm>
To <dfn for="file entry/lock">take</dfn> a [=file entry/lock=] with a |value| of
"`exclusive`" or "`shared`" on a given [=file entry=] |file|:
1. Let |lock| be the |file|'s [=file entry/lock=].
1. Let |count| be the |file|'s [=file entry/shared lock count=].
1. If |value| is "`exclusive`":
1. If |lock| is "`open`":
1. Set lock to "`taken-exclusive`".
1. Return "`success`".
1. If |value| is "`shared`":
1. If |lock| is "`open`":
1. Set |lock| to "`taken-shared`".
1. Set |count| to 1.
1. Return "`success`".
1. Otherwise, if |lock| is "`taken-shared`":
1. Increase |count| by 1.
1. Return "`success`".
1. Return "`failure`".
Note: These steps have to be run on the [=file system queue=].
</div>
<div algorithm>
To <dfn for="file entry/lock">release</dfn> a [=file entry/lock=] on a given
[=file entry=] |file|:
1. Let |lock| be the |file|'s associated [=file entry/lock=].
1. Let |count| be the |file|'s [=file entry/shared lock count=].
1. If |lock| is "`taken-shared`":
1. Decrease |count| by 1.
1. If |count| is 0, set |lock| to "`open`".
1. Otherwise, set |lock| to "`open`".
Note: These steps have to be run on the [=file system queue=].
</div>
Note: Locks help prevent concurrent modifications to a file. A {{FileSystemWritableFileStream}}
requires a shared lock, while a {{FileSystemSyncAccessHandle}} requires an exclusive one.
A <dfn export id=directory>directory entry</dfn> additionally consists of a [=/set=] of
<dfn for="directory entry">children</dfn>, which are themselves [=/file system entries=].
Each member is either a [=/file entry=] or a [=/directory entry=].
A [=/file system entry=] |entry| should be [=list/contained=] in the [=directory entry/children=] of at most one
[=directory entry=], and that directory entry is also known as |entry|'s
<dfn export for="file system entry" id=entry-parent>parent</dfn>.
A [=/file system entry=]'s [=file system entry/parent=] is null if no such directory entry exists.
Note: Two different [=/file system entries=] can represent the same file or directory on disk, in which
case it is possible for both entries to have a different parent, or for one entry to have a
parent while the other entry does not have a parent.
[=/File system entries=] can (but don't have to) be backed by files on the host operating system's local file system,
so it is possible for the [=binary data=], [=modification timestamp=],
and [=directory entry/children=] of entries to be modified by applications outside of this specification.
Exactly how external changes are reflected in the data structures defined by this specification,
as well as how changes made to the data structures defined here are reflected externally
is left up to individual user-agent implementations.
A [=/file system entry=] |a| is <dfn for="file system entry">the same entry as</dfn>
a [=/file system entry=] |b| if |a| is equal to |b|, or
if |a| and |b| are backed by the same file or directory on the local file system.
<div algorithm>
To <dfn for="file system locator" id=locator-resolve>resolve</dfn> a
[=/file system locator=] |child| relative to a [=directory locator=] |root|:
1. Let |result| be [=a new promise=].
1. [=Enqueue the following steps=] to the [=file system queue=]:
1. If |child|'s [=FileSystemHandle/locator=]'s [=file system locator/root=]
is not |root|'s [=FileSystemHandle/locator=]'s [=file system locator/root=],
[=/resolve=] |result| with null, and abort these steps.
1. Let |childPath| be |child|'s [=FileSystemHandle/locator=]'s [=file system locator/path=].
1. Let |rootPath| be |root|'s [=FileSystemHandle/locator=]'s [=file system locator/path=].
1. If |childPath| is [=the same path as=] |rootPath|,
[=/resolve=] |result| with « », and abort these steps.
1. If |rootPath|'s [=list/size=] is greater than |childPath|'s [=list/size=],
[=/resolve=] |result| with null, and abort these steps.
1. [=list/For each=] |index| of |rootPath|'s [=list/indices=]:
1. If |rootPath|.\[[|index|]] is not |childPath|.\[[|index|]], then
[=/resolve=] |result| with null, and abort these steps.
1. Let |relativePath| be « ».
1. [=list/For each=] |index| of [=the range=] from |rootPath|'s [=list/size=]
to |rootPath|'s [=list/size=], exclusive,
[=list/append=] |childPath|.\[[|index|]] to |relativePath|.
1. [=/Resolve=] |result| with |relativePath|.
1. Return |result|.
</div>
A <dfn export>file system locator</dfn> represents a potential location of a
[=/file system entry=]. A [=/file system locator=] is either a [=file locator=]
or a [=directory locator=].
Each [=/file system locator=] has an associated <dfn export for="file system locator" id=locator-path>path</dfn> (a [=/file system path=]),
a <dfn export for="file system locator" id=locator-kind>kind</dfn> (a {{FileSystemHandleKind}}), and
a <dfn export for="file system locator" id=locator-root>root</dfn> (a [=file system root=]).
Issue(109): Consider giving each locator a [=storage bucket=].
A <dfn export>file locator</dfn> is a [=/file system locator=] whose
[=file system locator/kind=] is "{{FileSystemHandleKind/file}}".
A <dfn export>directory locator</dfn> is a [=/file system locator=] whose
[=file system locator/kind=] is "{{FileSystemHandleKind/directory}}".
A <dfn export>file system root</dfn> is an opaque [=string=] whose value is
[=implementation-defined=].
<p class=example id=example-locator>For a [=/file system locator=] |locator|
whichs [=locate an entry|locates to=] a [=file entry=] |entry| that conceptually
exists at the path `data/drafts/example.txt` relative to the root directory of
a [=/bucket file system=],
|locator|'s [=file system locator/kind=] has to be "{{FileSystemHandleKind/file}}",
|locator|'s [=file system locator/path=] has to be « "`data`", "`drafts`", "`example.txt`" », and
|locator|'s [=file system locator/root=] might include relevant identifying
information such as the [=storage bucket=] and the disk drive.
A [=/file system locator=] |a| is <dfn for="file system locator">the same locator as</dfn>
a [=/file system locator=] |b| if
|a|'s [=file system locator/kind=] is |b|'s [=file system locator/kind=],
|a|'s [=file system locator/root=] is |b|'s [=file system locator/root=], and
|a|'s [=file system locator/path=] is [=the same path as=] |b|'s [=file system locator/path=].
<div algorithm>
The <dfn export data-lt="locating an entry">locate an entry</dfn> algorithm given a
[=/file system locator=] |locator| runs an [=implementation-defined=] series of steps adhering to
these constraints:
- If |locator| is a [=file locator=], they return a [=file entry=] or null.
- If |locator| is a [=directory locator=], they return a [=directory entry=] or null.
- If these steps return a non-null |entry|, then:
- [=Getting the locator=] with |entry| returns |locator|,
provided no intermediate file system operations were run.
- |entry|'s [=file system entry/name=] is the last [=list/item=] of |locator|'s
[=file system locator/path=].
</div>
<div algorithm>
The <dfn export data-lt="getting the locator">get the locator</dfn> algorithm given
[=/file system entry=] |entry| runs an [=implementation-defined=] series of steps adhering to these
constraints:
- If |entry| is a [=file entry=], they return a [=file locator=].
- If |entry| is a [=directory entry=], they return a [=directory locator=].
- If these steps return |locator|, then:
- [=Locating an entry=] with |locator| returns |entry|,
provided no intermediate file system operations were run.
- |entry|'s [=file system entry/name=] is the last [=list/item=] of |locator|'s
[=file system locator/path=].
</div>
A <dfn export>file system path</dfn> is a [=/list=] of one or more [=strings=].
This may be a virtual path that is mapped to real location on disk or in memory,
may correspond directly to a path on the local file system, or may not
correspond to any file on disk at all. The actual physical location of the
corresponding [=/file system entry=] is [=implementation-defined=].
<p class=example id=example-path>Let |path| be the [=/list=]
« "`data`", "`drafts`", "`example.txt`" ».
There is no expectation that a file named `example.txt` exists anywhere on disk.
A [=/file system path=] |a| is <dfn for="file system path">the same path as</dfn>
a [=/file system path=] |b| if
|a|'s [=list/size=] is the same as |b|'s [=list/size=] and
[=list/for each=] |index| of |a|'s [=list/indices=]
|a|.\[[|index|]] is |b|.\[[|index|]].
<p class=warning> The contents of a [=/file system locator=], including its
[=file system locator/path=], are not expected to be shared in their entirety
with the website process. The [=/file system path=] might contain components
which are not known to the website unless the [=/file system locator=] is later
[=file system locator/resolved=] relative to a parent [=directory locator=].
## The {{FileSystemHandle}} interface ## {#api-filesystemhandle}
<xmp class=idl>
enum FileSystemHandleKind {
"file",
"directory",
};
[Exposed=(Window,Worker), SecureContext, Serializable]
interface FileSystemHandle {
readonly attribute FileSystemHandleKind kind;
readonly attribute USVString name;
Promise<boolean> isSameEntry(FileSystemHandle other);
};
</xmp>
A {{FileSystemHandle}} object is associated with a <dfn for=FileSystemHandle export>locator</dfn> (a
[=/file system locator=]).
Note: Multiple {{FileSystemHandle}} objects can have
[=the same locator as|the same=] [=/file system locator=].
A {{FileSystemHandle}}
<dfn for=FileSystemHandle export>is in a bucket file system</dfn>
if the first [=list/item=] of its [=FileSystemHandle/locator=]'s
[=file system locator/path=] is the empty string.
Note: This is a bit magical, but it works since only the root directory of a
[=/bucket file system=] can have a [=file system locator/path=] which
[=list/contains=] an empty string. See {{StorageManager/getDirectory()}}.
All other [=list/item=]s of a [=file system locator/path=] will be a
[=valid file name=].
Issue(109): Consider improving this situation by giving each locator a
[=storage bucket=].
<div algorithm="serialization steps">
{{FileSystemHandle}} objects are [=serializable objects=].
Their [=serialization steps=], given |value|, |serialized| and <var ignore>forStorage</var> are:
1. Set |serialized|.\[[Origin]] to |value|'s [=relevant settings object=]'s [=environment settings object/origin=].
1. Set |serialized|.\[[Locator]] to |value|'s [=FileSystemHandle/locator=].
</div>
<div algorithm="deserialization steps">
Their [=deserialization steps=], given |serialized| and |value| are:
1. If |serialized|.\[[Origin]] is not [=same origin=] with
|value|'s [=relevant settings object=]'s [=environment settings object/origin=],
then [=throw=] a "{{DataCloneError}}" {{DOMException}}.
1. Set |value|'s [=FileSystemHandle/locator=] to |serialized|.\[[Locator]].
</div>
<div class="note domintro">
: |handle| . {{FileSystemHandle/kind}}
:: Returns "{{FileSystemHandleKind/file}}" if |handle| is a {{FileSystemFileHandle}},
or "{{FileSystemHandleKind/directory}}" if |handle| is a {{FileSystemDirectoryHandle}}.
This can be used to distinguish files from directories when iterating over the contents
of a directory.
: |handle| . {{FileSystemHandle/name}}
:: Returns the last path component of |handle|'s
[=FileSystemHandle/locator=]'s [=file system locator/path=].
</div>
The <dfn attribute for=FileSystemHandle>kind</dfn> getter steps are to return
[=this=]'s [=FileSystemHandle/locator=]'s [=file system locator/kind=].
The <dfn attribute for=FileSystemHandle>name</dfn> getter steps are to return
the last [=list/item=] (a [=string=]) of
[=this=]'s [=FileSystemHandle/locator=]'s [=file system locator/path=].
### The {{FileSystemHandle/isSameEntry()}} method ### {#api-filesystemhandle-issameentry}
<div class="note domintro">
: <var ignore>same</var> = await |handle1| . {{FileSystemHandle/isSameEntry()|isSameEntry}}( |handle2| )
:: Returns true if |handle1| and |handle2| represent the same file or directory.
</div>
<div algorithm>
The <dfn method for=FileSystemHandle>isSameEntry(|other|)</dfn> method steps are:
1. Let |realm| be [=this=]'s [=relevant Realm=].
1. Let |p| be [=a new promise=] in |realm|.
1. [=Enqueue the following steps=] to the [=file system queue=]:
1. If [=this=]'s [=FileSystemHandle/locator=] is
[=the same locator as=] |other|'s [=FileSystemHandle/locator=],
[=/resolve=] |p| with true.
1. Otherwise [=/resolve=] |p| with false.
1. Return |p|.
</div>
## The {{FileSystemFileHandle}} interface ## {#api-filesystemfilehandle}
<xmp class=idl>
dictionary FileSystemCreateWritableOptions {
boolean keepExistingData = false;
};
[Exposed=(Window,Worker), SecureContext, Serializable]
interface FileSystemFileHandle : FileSystemHandle {
Promise<File> getFile();
Promise<FileSystemWritableFileStream> createWritable(optional FileSystemCreateWritableOptions options = {});
[Exposed=DedicatedWorker]
Promise<FileSystemSyncAccessHandle> createSyncAccessHandle();
};
</xmp>
Note: A {{FileSystemFileHandle}}'s associated [=FileSystemHandle/locator=]'s
[=file system locator/kind=] is "{{FileSystemHandleKind/file}}".
<div algorithm>
To
<dfn data-lt="creating a child FileSystemFileHandle">create a child `FileSystemFileHandle`</code></dfn>
given a [=directory locator=] |parentLocator| and a string |name| in a [=/Realm=] |realm|:
1. Let |handle| be a [=new=] {{FileSystemFileHandle}} in |realm|.
1. Let |childType| be "{{FileSystemHandleKind/file}}".
1. Let |childRoot| be a copy of |parentLocator|'s [=file system locator/root=].
1. Let |childPath| be the result of [=list/clone|cloning=] |parentLocator|'s
[=file system locator/path=] and [=list/append|appending=] |name|.
1. Set |handle|'s [=FileSystemHandle/locator=] to a [=/file system locator=] whose
[=file system locator/kind=] is |childType|,
[=file system locator/root=] is |childRoot|, and
[=file system locator/path=] is |childPath|.
1. Return |handle|.
</div>
<div algorithm>
To
<dfn export data-lt="creating a new FileSystemFileHandle">create a new `FileSystemFileHandle`</dfn>
given a [=/file system root=] |root| and a [=/file system path=] |path|
in a [=/Realm=] |realm|:
1. Let |handle| be a [=new=] {{FileSystemFileHandle}} in |realm|.
1. Set |handle|'s [=FileSystemHandle/locator=] to a [=/file system locator=] whose
[=file system locator/kind=] is "{{FileSystemHandleKind/file}}",
[=file system locator/root=] is |root|, and
[=file system locator/path=] is |path|.
1. Return |handle|.
</div>
{{FileSystemFileHandle}} objects are [=serializable objects=]. Their [=serialization steps=] and
[=deserialization steps=] are the same as those for {{FileSystemHandle}}.
### The {{FileSystemFileHandle/getFile()}} method ### {#api-filesystemfilehandle-getfile}
<div class="note domintro">
: <var ignore>file</var> = await |fileHandle| . {{FileSystemFileHandle/getFile()}}
:: Returns a {{File}} representing the state on disk of the [=file entry=]
[=locate an entry|locatable=] by |handle|'s [=FileSystemHandle/locator=].
If the file on disk changes or is removed after this method is called, the returned
{{File}} object will likely be no longer readable.
</div>
<div algorithm>
The <dfn method for=FileSystemFileHandle>getFile()</dfn> method steps are:
1. Let |result| be [=a new promise=].
1. Let |locator| be [=this=]'s [=FileSystemHandle/locator=].
1. Let |global| be [=this=]'s [=relevant global object=].
1. [=Enqueue the following steps=] to the [=file system queue=]:
1. Let |entry| be the result of [=locating an entry=] given |locator|.
1. Let |accessResult| be the result of running |entry|'s
[=file system entry/query access=] given "`read`".
1. [=Queue a storage task=] with |global| to run these steps:
1. If |accessResult|'s [=file system access result/permission state=]
is not "{{PermissionState/granted}}", [=/reject=] |result| with a
{{DOMException}} of |accessResult|'s
[=file system access result/error name=] and abort these steps.
1. If |entry| is null, [=/reject=] |result| with a
"{{NotFoundError}}" {{DOMException}} and abort these steps.
1. [=Assert=]: |entry| is a [=file entry=].
1. Let |f| be a new {{File}}.
1. Set |f|'s <a spec=FileAPI>snapshot state</a> to the current state of |entry|.
1. Set |f|'s underlying byte sequence to a copy of |entry|'s [=binary data=].
1. Set |f|'s {{File/name}} to |entry|'s [=file system entry/name=].
1. Set |f|'s {{File/lastModified}} to |entry|'s [=file entry/modification timestamp=].
1. Set |f|'s {{Blob/type}} to an [=implementation-defined=] value, based on
for example |entry|'s [=file system entry/name=] or its file extension.
Issue: The reading and snapshotting behavior needs to be better specified in the [[FILE-API]] spec,
for now this is kind of hand-wavy.
1. [=/Resolve=] |result| with |f|.
1. Return |result|.
</div>
### The {{FileSystemFileHandle/createWritable()}} method ### {#api-filesystemfilehandle-createwritable}
<div class="note domintro">
: |stream| = await |fileHandle| . {{FileSystemFileHandle/createWritable()}}
: |stream| = await |fileHandle| . {{FileSystemFileHandle/createWritable()|createWritable}}({ {{FileSystemCreateWritableOptions/keepExistingData}}: true/false })
:: Returns a {{FileSystemWritableFileStream}} that can be used to write to the file. Any changes made through
|stream| won't be reflected in the [=file entry=] [=locate an entry|locatable=] by
|fileHandle|'s [=FileSystemHandle/locator=] until the stream has been closed.
User agents try to ensure that no partial writes happen, i.e. the file
will either contain its old contents or it will contain whatever data was written
through |stream| up until the stream has been closed.
This is typically implemented by writing data to a temporary file, and only replacing the
[=file entry=] [=locate an entry|locatable=] by |fileHandle|'s [=FileSystemHandle/locator=]
with the temporary file when the writable filestream is closed.
If {{FileSystemCreateWritableOptions/keepExistingData}} is false or not specified,
the temporary file starts out empty,
otherwise the existing file is first copied to this temporary file.
Creating a {{FileSystemWritableFileStream}} [=file entry/lock/take|takes a shared lock=] on the
[=file entry=] [=locate an entry|locatable=] with |fileHandle|'s [=FileSystemHandle/locator=].
This prevents the creation of {{FileSystemSyncAccessHandle|FileSystemSyncAccessHandles}}
for the entry, until the stream is closed.
</div>
<p class=XXX>See <a href=https://github.com/WICG/file-system-access/issues/67>WICG/file-system-access issue #67</a>
for discussion around and desire for a "inPlace" mode for createWritable (where
changes will be written to the actual underlying file as they are written to the
writer, for example to support in-place modification of large files or things
like databases). This is not currently implemented in Chrome. Implementing this
is currently blocked on figuring out how to combine the desire to run malware
checks with the desire to let websites make fast in-place modifications to
existing large files. In-place writes are available for files in a
[=/bucket file system=] via the {{FileSystemSyncAccessHandle}} interface.
<div algorithm>
The <dfn method for=FileSystemFileHandle>createWritable(|options|)</dfn> method steps are:
1. Let |result| be [=a new promise=].
1. Let |locator| be [=this=]'s [=FileSystemHandle/locator=].
1. Let |realm| be [=this=]'s [=relevant Realm=].
1. Let |global| be [=this=]'s [=relevant global object=].
1. [=Enqueue the following steps=] to the [=file system queue=]:
1. Let |entry| be the result of [=locating an entry=] given |locator|.
1. Let |accessResult| be the result of running |entry|'s
[=file system entry/request access=] given "`readwrite`".
1. If |accessResult|'s [=file system access result/permission state=]
is not "{{PermissionState/granted}}", [=queue a storage task=] with
|global| to [=/reject=] |result| with a {{DOMException}} of
|accessResult|'s [=file system access result/error name=] and
abort these steps.
1. If |entry| is `null`, [=queue a storage task=] with |global| to [=/reject=]
|result| with a "{{NotFoundError}}" {{DOMException}} and abort these steps.
1. [=Assert=]: |entry| is a [=file entry=].
1. Let |lockResult| be the result of [=file entry/lock/take|taking a lock=]
with "`shared`" on |entry|.
1. [=Queue a storage task=] with |global| to run these steps:
1. If |lockResult| is "`failure`", [=/reject=] |result| with a
"{{NoModificationAllowedError}}" {{DOMException}} and abort these steps.
1. Let |stream| be the result of <a>creating a new `FileSystemWritableFileStream`</a>
for |entry| in |realm|.
1. If |options|["{{FileSystemCreateWritableOptions/keepExistingData}}"]
is true:
1. Set |stream|'s [=[[buffer]]=] to a copy of |entry|'s
[=file entry/binary data=].
1. [=/Resolve=] |result| with |stream|.
1. Return |result|.
</div>
### The {{FileSystemFileHandle/createSyncAccessHandle()}} method ### {#api-filesystemfilehandle-createsyncaccesshandle}
<div class="note domintro">
: |handle| = await |fileHandle| . {{FileSystemFileHandle/createSyncAccessHandle()|createSyncAccessHandle}}()
:: Returns a {{FileSystemSyncAccessHandle}} that can be used to read from/write to the file.
Changes made through |handle| might be immediately reflected in the
[=file entry=] [=locate an entry|locatable=] by |fileHandle|'s [=FileSystemHandle/locator=].
To ensure the changes are reflected in this file, the handle can be flushed.
Creating a {{FileSystemSyncAccessHandle}} [=file entry/lock/take|takes an exclusive lock=] on the
[=file entry=] [=locate an entry|locatable=] with |fileHandle|'s [=FileSystemHandle/locator=].
This prevents the creation of further {{FileSystemSyncAccessHandle|FileSystemSyncAccessHandles}}
or {{FileSystemWritableFileStream|FileSystemWritableFileStreams}}
for the entry, until the access handle is closed.
The returned {{FileSystemSyncAccessHandle}} offers synchronous methods. This allows for higher performance
on contexts where asynchronous operations come with high overhead, e.g., WebAssembly.
For the time being, this method will only succeed when the |fileHandle|
[=FileSystemHandle/is in a bucket file system=].
</div>
<div algorithm>
The <dfn method for=FileSystemFileHandle>createSyncAccessHandle()</dfn> method steps are:
1. Let |result| be [=a new promise=].
1. Let |locator| be [=this=]'s [=FileSystemHandle/locator=].
1. Let |realm| be [=this=]'s [=relevant Realm=].
1. Let |global| be [=this=]'s [=relevant global object=].
1. Let |isInABucketFileSystem| be true if
[=this=] [=FileSystemHandle/is in a bucket file system=];
otherwise false.
1. [=Enqueue the following steps=] to the [=file system queue=]:
1. Let |entry| be the result of [=locating an entry=] given |locator|.
1. Let |accessResult| be the result of running |entry|'s
[=file system entry/request access=] given "`readwrite`".
1. If |accessResult|'s [=file system access result/permission state=]
is not "{{PermissionState/granted}}", [=queue a storage task=] with
|global| to [=/reject=] |result| with a {{DOMException}} of
|accessResult|'s [=file system access result/error name=] and
abort these steps.
1. If |isInABucketFileSystem| is false,
[=queue a storage task=] with |global| to
[=/reject=] |result| with an "{{InvalidStateError}}" {{DOMException}} and
abort these steps.
1. If |entry| is `null`, [=queue a storage task=] with |global| to [=/reject=]
|result| with a "{{NotFoundError}}" {{DOMException}} and abort these steps.
1. [=Assert=]: |entry| is a [=file entry=].
1. Let |lockResult| be the result of [=file entry/lock/take|taking a lock=]
with "`exclusive`" on |entry|.
1. [=Queue a storage task=] with |global| to run these steps:
1. If |lockResult| is "`failure`", [=/reject=] |result| with a
"{{NoModificationAllowedError}}" {{DOMException}} and abort these steps.
1. Let |handle| be the result of <a>creating a new `FileSystemSyncAccessHandle`</a>
for |entry| in |realm|.
1. [=/Resolve=] |result| with |handle|.
1. Return |result|.
</div>
## The {{FileSystemDirectoryHandle}} interface ## {#api-filesystemdirectoryhandle}
<xmp class=idl>
dictionary FileSystemGetFileOptions {
boolean create = false;
};
dictionary FileSystemGetDirectoryOptions {
boolean create = false;
};
dictionary FileSystemRemoveOptions {
boolean recursive = false;
};
[Exposed=(Window,Worker), SecureContext, Serializable]
interface FileSystemDirectoryHandle : FileSystemHandle {
async iterable<USVString, FileSystemHandle>;
Promise<FileSystemFileHandle> getFileHandle(USVString name, optional FileSystemGetFileOptions options = {});
Promise<FileSystemDirectoryHandle> getDirectoryHandle(USVString name, optional FileSystemGetDirectoryOptions options = {});
Promise<undefined> removeEntry(USVString name, optional FileSystemRemoveOptions options = {});
Promise<sequence<USVString>?> resolve(FileSystemHandle possibleDescendant);
};
</xmp>
Note: A {{FileSystemDirectoryHandle}}'s associated [=FileSystemHandle/locator=]'s
[=file system locator/kind=] is "{{FileSystemHandleKind/directory}}".
<div algorithm>
To
<dfn data-lt="creating a child FileSystemDirectoryHandle">create a child `FileSystemDirectoryHandle`</dfn>
given a [=directory locator=] |parentLocator| and a string |name| in a [=/Realm=] |realm|:
1. Let |handle| be a [=new=] {{FileSystemDirectoryHandle}} in |realm|.
1. Let |childType| be "{{FileSystemHandleKind/directory}}".
1. Let |childRoot| be a copy of |parentLocator|'s [=file system locator/root=].
1. Let |childPath| be the result of [=list/clone|cloning=] |parentLocator|'s
[=file system locator/path=] and [=list/append|appending=] |name|.
1. Set |handle|'s [=FileSystemHandle/locator=] to a [=/file system locator=] whose
[=file system locator/kind=] is |childType|,
[=file system locator/root=] is |childRoot|, and
[=file system locator/path=] is |childPath|.
1. Return |handle|.
</div>
<div algorithm>
To
<dfn export data-lt="creating a new FileSystemDirectoryHandle">create a new `FileSystemDirectoryHandle`</dfn>
given a [=/file system root=] |root| and a [=/file system path=] |path|
in a [=/Realm=] |realm|:
1. Let |handle| be a [=new=] {{FileSystemDirectoryHandle}} in |realm|.
1. Set |handle|'s [=FileSystemHandle/locator=] to a [=/file system locator=] whose
[=file system locator/kind=] is "{{FileSystemHandleKind/directory}}",
[=file system locator/root=] is |root|, and
[=file system locator/path=] is |path|.
1. Return |handle|.
</div>
{{FileSystemDirectoryHandle}} objects are [=serializable objects=]. Their [=serialization steps=] and
[=deserialization steps=] are the same as those for {{FileSystemHandle}}.
### Directory iteration ### {#api-filesystemdirectoryhandle-asynciterable}
<div class="note domintro">
: for await (let [|name|, |handle|] of |directoryHandle|) {}
: for await (let [|name|, |handle|] of |directoryHandle| . entries()) {}
: for await (let |handle| of |directoryHandle| . values()) {}
: for await (let |name| of |directoryHandle| . keys()) {}
:: Iterates over all entries whose parent is the [=directory entry=]
[=locate an entry|locatable=] by |directoryHandle|'s [=FileSystemHandle/locator=].
Entries that are created or deleted while the iteration is in progress
might or might not be included. No guarantees are given either way.
</div>
Issue(15): In the future we might want to add arguments to the async iterable declaration to
support for example recursive iteration.
<div algorithm="iterator initialization">
The [=asynchronous iterator initialization steps=] for a
{{FileSystemDirectoryHandle}} <var ignore>handle</var>
and its async iterator |iterator| are:
1. Set |iterator|'s <dfn for="FileSystemDirectoryHandle-iterator">past results</dfn> to an empty [=/set=].
</div>
<div algorithm="next iteration result">
To [=get the next iteration result=] for a {{FileSystemDirectoryHandle}} |handle|
and its async iterator |iterator|:
1. Let |promise| be [=a new promise=].
1. [=Enqueue the following steps=] to the [=file system queue=]:
1. Let |directory| be the result of [=locating an entry=]
given |handle|'s [=FileSystemHandle/locator=].
1. Let |accessResult| be the result of running |directory|'s
[=file system entry/query access=] given "`read`".
1. [=Queue a storage task=] with |handle|'s [=relevant global object=] to
run these steps:
1. If |accessResult|'s [=file system access result/permission state=]
is not "{{PermissionState/granted}}", [=/reject=] |promise| with a
{{DOMException}} of |accessResult|'s
[=file system access result/error name=] and abort these steps.:
1. If |directory| is `null`, [=/reject=] |result| with a
"{{NotFoundError}}" {{DOMException}} and abort these steps.
1. [=Assert=]: |directory| is a [=directory entry=].
1. Let |child| be a [=/file system entry=] in
|directory|'s [=directory entry/children=], such that
|child|'s [=file system entry/name=] is not contained in
|iterator|'s [=past results=], or `null` if no such entry exists.
Note: This is intentionally very vague about the iteration order.
Different platforms and file systems provide different guarantees about
iteration order, and we want it to be possible to efficiently implement
this on all platforms. As such no guarantees are given about the exact
order in which elements are returned.
1. If |child| is `null`, [=/resolve=] |promise| with `undefined` and
abort these steps.
1. [=set/Append=] |child|'s [=file system entry/name=] to
|iterator|'s [=past results=].
1. If |child| is a [=file entry=]:
1. Let |result| be the result of
<a>creating a child `FileSystemFileHandle`</a> with
|handle|'s [=FileSystemHandle/locator=] and
|child|'s [=file system entry/name=] in |handle|'s [=relevant Realm=].
1. Otherwise:
1. Let |result| be the result of
<a>creating a child `FileSystemDirectoryHandle`</a> with
|handle|'s [=FileSystemHandle/locator=] and
|child|'s [=file system entry/name=] in |handle|'s [=relevant Realm=].
1. [=/Resolve=] |promise| with
(|child|'s [=file system entry/name=], |result|).
1. Return |promise|.
</div>
### The {{FileSystemDirectoryHandle/getFileHandle()}} method ### {#api-filesystemdirectoryhandle-getfilehandle}
<div class="note domintro">
: |fileHandle| = await |directoryHandle| . {{FileSystemDirectoryHandle/getFileHandle()|getFileHandle}}(|name|)
: |fileHandle| = await |directoryHandle| . {{FileSystemDirectoryHandle/getFileHandle()|getFileHandle}}(|name|, { {{FileSystemGetFileOptions/create}}: false })
:: Returns a handle for a file named |name| in the [=directory entry=]
[=locate an entry|locatable=] by |directoryHandle|'s [=FileSystemHandle/locator=].
If no such file exists, this rejects.
: |fileHandle| = await |directoryHandle| . {{FileSystemDirectoryHandle/getFileHandle()|getFileHandle}}(|name|, { {{FileSystemGetFileOptions/create}}: true })
:: Returns a handle for a file named |name| in the [=directory entry=]
[=locate an entry|locatable=] by |directoryHandle|'s [=FileSystemHandle/locator=].
If no such file exists, this creates a new file. If no file with named |name| can be created this
rejects. Creation can fail because there already is a directory with the same name, because the
name uses characters that aren't supported in file names on the underlying file system, or
because the user agent for security reasons decided not to allow creation of the file.
This operation requires write permission, even if the file being returned already exists. If
this handle doesn't already have write permission, this could result in a prompt being shown to
the user. To get an existing file without needing write permission, call this method
with <code>{ {{FileSystemGetFileOptions/create}}: false }</code>.
</div>
<div algorithm>
The <dfn method for=FileSystemDirectoryHandle>getFileHandle(|name|, |options|)</dfn> method steps are:
1. Let |result| be [=a new promise=].
1. Let |realm| be [=this=]'s [=relevant Realm=].
1. Let |locator| be [=this=]'s [=FileSystemHandle/locator=].
1. Let |global| be [=this=]'s [=relevant global object=].
1. [=Enqueue the following steps=] to the [=file system queue=]:
1. If |name| is not a [=valid file name=], [=queue a storage task=] with
|global| to [=/reject=] |result| with a {{TypeError}} and
abort these steps.
1. Let |entry| be the result of [=locating an entry=] given |locator|.
1. If |options|["{{FileSystemGetFileOptions/create}}"] is true:
1. Let |accessResult| be the result of running |entry|'s
[=file system entry/request access=] given "`readwrite`".
1. Otherwise:
1. Let |accessResult| be the result of running |entry|'s
[=file system entry/query access=] given "`read`".
1. [=Queue a storage task=] with |global| to run these steps:
1. If |accessResult|'s [=file system access result/permission state=]
is not "{{PermissionState/granted}}", [=/reject=] |result| with a
{{DOMException}} of |accessResult|'s
[=file system access result/error name=] and abort these steps.
1. If |entry| is `null`, [=/reject=] |result| with a
"{{NotFoundError}}" {{DOMException}} and abort these steps.
1. [=Assert=]: |entry| is a [=directory entry=].
1. [=set/For each=] |child| of |entry|'s [=directory entry/children=]:
1. If |child|'s [=file system entry/name=] equals |name|:
1. If |child| is a [=directory entry=]:
1. [=/Reject=] |result| with a
"{{TypeMismatchError}}" {{DOMException}} and abort these steps.
1. [=/Resolve=] |result| with the result of
<a>creating a child `FileSystemFileHandle`</a> with |locator| and
|child|'s [=file system entry/name=] in |realm| and
abort these steps.
1. If |options|["{{FileSystemGetFileOptions/create}}"] is false:
1. [=/Reject=] |result| with a "{{NotFoundError}}" {{DOMException}} and
abort these steps.
1. Let |child| be a new [=file entry=] whose [=query access=] and
[=request access=] algorithms are those of |entry|.
1. Set |child|'s [=file system entry/name=] to |name|.
1. Set |child|'s [=binary data=] to an empty [=byte sequence=].
1. Set |child|'s [=modification timestamp=] to the current time.
1. [=set/Append=] |child| to |entry|'s [=directory entry/children=].
1. If creating |child| in the underlying file system throws an exception,
[=/reject=] |result| with that exception and abort these steps.
Issue(11): Better specify what possible exceptions this could throw.
1. [=/Resolve=] |result| with the result of
<a>creating a child `FileSystemFileHandle`</a> with |locator| and
|child|'s [=file system entry/name=] in |realm|.
1. Return |result|.
</div>
### The {{FileSystemDirectoryHandle/getDirectoryHandle()}} method ### {#api-filesystemdirectoryhandle-getdirectoryhandle}
<div class="note domintro">
: |subdirHandle| = await |directoryHandle| . {{FileSystemDirectoryHandle/getDirectoryHandle()|getDirectoryHandle}}(|name|)
: |subdirHandle| = await |directoryHandle| . {{FileSystemDirectoryHandle/getDirectoryHandle()|getDirectoryHandle}}(|name|, { {{FileSystemGetDirectoryOptions/create}}: false })
:: Returns a handle for a directory named |name| in the [=directory entry=]
[=locate an entry|locatable=] by |directoryHandle|'s [=FileSystemHandle/locator=].
If no such directory exists, this rejects.
: |subdirHandle| = await |directoryHandle| . {{FileSystemDirectoryHandle/getDirectoryHandle()|getDirectoryHandle}}(|name|, { {{FileSystemGetDirectoryOptions/create}}: true })
:: Returns a handle for a directory named |name| in the [=directory entry=]
[=locate an entry|locatable=] by |directoryHandle|'s [=FileSystemHandle/locator=] .
If no such directory exists, this creates a new directory. If creating the
directory failed, this rejects. Creation can fail because there already is a file with the same
name, or because the name uses characters that aren't supported in file names on the underlying
file system.
This operation requires write permission, even if the directory being returned already exists.
If this handle doesn't already have write permission, this could result in a prompt being shown
to the user. To get an existing directory without needing write permission, call this method
with <code>{ {{FileSystemGetDirectoryOptions/create}}: false }</code>.
</div>
<div algorithm>
The <dfn method for=FileSystemDirectoryHandle>getDirectoryHandle(|name|, |options|)</dfn> method steps are:
1. Let |result| be [=a new promise=].
1. Let |realm| be [=this=]'s [=relevant Realm=].
1. Let |locator| be [=this=]'s [=FileSystemHandle/locator=].
1. Let |global| be [=this=]'s [=relevant global object=].
1. [=Enqueue the following steps=] to the [=file system queue=]:
1. If |name| is not a [=valid file name=], [=queue a storage task=] with
|global| to [=/reject=] |result| with a {{TypeError}} and
abort these steps.
1. Let |entry| be the result of [=locating an entry=] given |locator|.
1. If |options|["{{FileSystemGetDirectoryOptions/create}}"] is true:
1. Let |accessResult| be the result of running |entry|'s
[=file system entry/request access=] given "`readwrite`".
1. Otherwise:
1. Let |accessResult| be the result of running |entry|'s
[=file system entry/query access=] given "`read`".
1. [=Queue a storage task=] with |global| to run these steps:
1. If |accessResult|'s [=file system access result/permission state=]
is not "{{PermissionState/granted}}", [=/reject=] |result| with a
{{DOMException}} of |accessResult|'s
[=file system access result/error name=] and abort these steps.
1. If |entry| is `null`, [=/reject=] |result| with a
"{{NotFoundError}}" {{DOMException}} and abort these steps.
1. [=Assert=]: |entry| is a [=directory entry=].
1. [=set/For each=] |child| of |entry|'s [=directory entry/children=]:
1. If |child|'s [=file system entry/name=] equals |name|:
1. If |child| is a [=file entry=]:
1. [=/Reject=] |result| with a
"{{TypeMismatchError}}" {{DOMException}} and abort these steps.
1. [=/Resolve=] |result| with the result of
<a>creating a child `FileSystemDirectoryHandle`</a> with
|locator| and |child|'s [=file system entry/name=] in |realm| and
abort these steps.
1. If |options|["{{FileSystemGetFileOptions/create}}"] is false:
1. [=/Reject=] |result| with a "{{NotFoundError}}" {{DOMException}} and
abort these steps.
1. Let |child| be a new [=directory entry=] whose [=query access=] and
[=request access=] algorithms are those of |entry|.
1. Set |child|'s [=file system entry/name=] to |name|.
1. Set |child|'s [=directory entry/children=] to an empty [=/set=].
1. [=set/Append=] |child| to |entry|'s [=directory entry/children=].
1. If creating |child| in the underlying file system throws an exception,
[=/reject=] |result| with that exception and abort these steps.
Issue(11): Better specify what possible exceptions this could throw.
1. [=/Resolve=] |result| with the result of
<a>creating a child `FileSystemDirectoryHandle`</a> with
|locator| and |child|'s [=file system entry/name=] in |realm|.
1. Return |result|.
</div>
### The {{FileSystemDirectoryHandle/removeEntry()}} method ### {#api-filesystemdirectoryhandle-removeentry}
<div class="note domintro">
: await |directoryHandle| . {{FileSystemDirectoryHandle/removeEntry()|removeEntry}}(|name|)
: await |directoryHandle| . {{FileSystemDirectoryHandle/removeEntry()|removeEntry}}(|name|, { {{FileSystemRemoveOptions/recursive}}: false })
:: If the [=directory entry=] [=locate an entry|locatable=] by |directoryHandle|'s
[=FileSystemHandle/locator=] contains a file named |name|, or an empty
directory named |name|, this will attempt to delete that file or directory.
Attempting to delete a file or directory that does not exist is considered success,
while attempting to delete a non-empty directory will result in a promise rejection.
: await |directoryHandle| . {{FileSystemDirectoryHandle/removeEntry()|removeEntry}}(|name|, { {{FileSystemRemoveOptions/recursive}}: true })
:: Removes the [=/file system entry=] named |name| in the [=directory entry=]
[=locate an entry|locatable=] by |directoryHandle|'s [=FileSystemHandle/locator=].
If that entry is a directory, its contents will also be deleted recursively.
Attempting to delete a file or directory that does not exist is considered success.
</div>
<div algorithm>
The <dfn method for=FileSystemDirectoryHandle>removeEntry(|name|, |options|)</dfn> method steps are:
1. Let |result| be [=a new promise=].
1. Let |locator| be [=this=]'s [=FileSystemHandle/locator=].
1. Let |global| be [=this=]'s [=relevant global object=].
1. [=Enqueue the following steps=] to the [=file system queue=]:
1. If |name| is not a [=valid file name=], [=queue a storage task=] with