@@ -60,8 +60,60 @@ different storage mechanism with a different API for such files. The entry point
6060
6161## Concepts ## {#concepts}
6262
63+ ### File System ### {#concept-file-system}
64+
65+ A <dfn export>file system</dfn> is an [=implementation-defined=]
66+ [=storage endpoint=] that maintains a mapping of [=file system path=] s to
67+ [=file system entry|file system entries=] .
68+
69+ Each [=/file system=] has an associated <dfn for="file system" export>root</dfn> ,
70+ an opaque [=string=] whose value is [=implementation-defined=] .
71+
72+ A <dfn export>file system path</dfn> is a [=/list=] of one or more [=strings=] .
73+ This may be a virtual path that is mapped to real location on disk or in memory,
74+ may correspond directly to a path on the local file system, or may not
75+ correspond to any file on disk at all. The actual physical location of the
76+ corresponding [=/file system entry=] is [=implementation-defined=] .
77+
78+ A [=/file system path=] |a| is <dfn for="file system path">the same path as</dfn>
79+ a [=/file system path=] |b| if
80+ |a|'s [=list/size=] is the same as |b|' s [=list/size=] and
81+ [=list/for each=] |index| of |a|'s [=list/indices=]
82+ |a|.\[[|index|]] is |b|.\[[|index|]] .
83+
84+ <div algorithm>
85+ Each [=/file system=] has an associated
86+ <dfn for="file system">locate an entry</dfn>
87+ algorithm, which takes [=/file system path=] |path| and runs an
88+ [=implementation-defined=] series of steps returning a [=file system entry=] or null.
89+ A non-null return value |entry| must adhere to these constraints:
90+
91+ - [=file system/Getting the path=] with |entry| returns |path|,
92+ provided no intermediate file system operations were run.
93+ - |entry|'s [=file system entry/name=] is the last [=list/item=] of |path|.
94+
95+ </div>
96+
97+ <div algorithm>
98+ Each [=/file system=] has an associated
99+ <dfn for="file system">get the path</dfn>
100+ algorithm, which takes [=/file system entry=] |entry| and runs an
101+ [=implementation-defined=] series of steps returning a [=file system path=] . The
102+ return value |path| must adhere to these constraints:
103+
104+ - [=file system/Locating an entry=] with |path| returns |entry|,
105+ provided no intermediate file system operations were run.
106+ - |entry|'s [=file system entry/name=] is the last [=list/item=] of |path|.
107+
108+ </div>
109+
110+ ### File System Entry ### {#concept-file-system-entry}
111+
63112A <dfn export id="entry">file system entry</dfn> is either a [=file entry=] or a [=directory entry=] .
64113
114+ Each [=/file system entry=] has an associated
115+ <dfn for="file system entry">file system</dfn> (a [=/file system=] ).
116+
65117Each [=/file system entry=] has an associated
66118<dfn for="file system entry" id=entry-query-access>query access</dfn>
67119algorithm, which takes "`read`" or "`readwrite`" <var ignore> mode</var> and
@@ -200,15 +252,50 @@ A [=/file system entry=] |a| is <dfn for="file system entry">the same entry as</
200252a [=/file system entry=] |b| if |a| is equal to |b|, or
201253if |a| and |b| are backed by the same file or directory on the local file system.
202254
255+ ### File System Locator ### {#concept-file-system-locator}
256+
257+ A <dfn export>file system locator</dfn> represents a potential location of a
258+ [=/file system entry=] . A [=/file system locator=] is either a [=file locator=]
259+ or a [=directory locator=] .
260+
261+ Each [=/file system locator=] has an associated <dfn export for="file system locator" id=locator-path>path</dfn> (a [=/file system path=] ),
262+ a <dfn export for="file system locator" id=locator-kind>kind</dfn> (a {{FileSystemHandleKind}} ), and
263+ a <dfn export for="file system locator" id=locator-root>file system</dfn> (a [=/file system=] ).
264+
265+ Issue(109): Consider giving each locator a [=storage bucket=] .
266+
267+ A <dfn export>file locator</dfn> is a [=/file system locator=] whose
268+ [=file system locator/kind=] is "{{FileSystemHandleKind/file}} ".
269+ A <dfn export>directory locator</dfn> is a [=/file system locator=] whose
270+ [=file system locator/kind=] is "{{FileSystemHandleKind/directory}} ".
271+
272+ <p class=example id=example-locator> For a [=/file system locator=] |locator|
273+ whichs [=locate an entry|locates to=] a [=file entry=] |entry| that conceptually
274+ exists at the path `data/drafts/example.txt` relative to the root directory of
275+ a [=/bucket file system=] ,
276+ |locator|'s [=file system locator/kind=] has to be "{{FileSystemHandleKind/file}} ",
277+ |locator|'s [=file system locator/path=] has to be « "`data`", "`drafts`", "`example.txt`" », and
278+ |locator|'s [=file system locator/file system=] has to be [=/bucket file system=] .
279+
280+ A [=/file system locator=] |a| is <dfn for="file system locator">the same locator as</dfn>
281+ a [=/file system locator=] |b| if
282+ |a|'s [=file system locator/kind=] is |b|' s [=file system locator/kind=] ,
283+ |a|'s [=file system locator/file system=] is |b|' s [=file system locator/file system=] , and
284+ |a|'s [=file system locator/path=] is [=the same path as=] |b|' s [=file system locator/path=] .
285+
286+ <p class=example id=example-path> Let |path| be the [=/list=]
287+ « "`data`", "`drafts`", "`example.txt`" ».
288+ There is no expectation that a file named `example.txt` exists anywhere on disk.
289+
203290<div algorithm>
204291
205292To <dfn for="file system locator" id=locator-resolve>resolve</dfn> a
206293[=/file system locator=] |child| relative to a [=directory locator=] |root|:
207294
2082951. Let |result| be [=a new promise=] .
2092961. [=Enqueue the following steps=] to the [=file system queue=] :
210- 1. If |child|'s [=FileSystemHandle/locator=]' s [=file system locator/root =]
211- is not |root|'s [=FileSystemHandle/locator=]' s [=file system locator/root =] ,
297+ 1. If |child|'s [=FileSystemHandle/locator=]' s [=file system locator/file system =]
298+ is not |root|'s [=FileSystemHandle/locator=]' s [=file system locator/file system =] ,
212299 [=/resolve=] |result| with null, and abort these steps.
213300
214301 1. Let |childPath| be |child|'s [=FileSystemHandle/locator=]' s [=file system locator/path=] .
@@ -234,85 +321,36 @@ To <dfn for="file system locator" id=locator-resolve>resolve</dfn> a
234321
235322</div>
236323
237- A <dfn export>file system locator</dfn> represents a potential location of a
238- [=/file system entry=] . A [=/file system locator=] is either a [=file locator=]
239- or a [=directory locator=] .
240-
241- Each [=/file system locator=] has an associated <dfn export for="file system locator" id=locator-path>path</dfn> (a [=/file system path=] ),
242- a <dfn export for="file system locator" id=locator-kind>kind</dfn> (a {{FileSystemHandleKind}} ), and
243- a <dfn export for="file system locator" id=locator-root>root</dfn> (a [=file system root=] ).
244-
245- Issue(109): Consider giving each locator a [=storage bucket=] .
246-
247- A <dfn export>file locator</dfn> is a [=/file system locator=] whose
248- [=file system locator/kind=] is "{{FileSystemHandleKind/file}} ".
249- A <dfn export>directory locator</dfn> is a [=/file system locator=] whose
250- [=file system locator/kind=] is "{{FileSystemHandleKind/directory}} ".
251-
252- A <dfn export>file system root</dfn> is an opaque [=string=] whose value is
253- [=implementation-defined=] .
254-
255- <p class=example id=example-locator> For a [=/file system locator=] |locator|
256- whichs [=locate an entry|locates to=] a [=file entry=] |entry| that conceptually
257- exists at the path `data/drafts/example.txt` relative to the root directory of
258- a [=/bucket file system=] ,
259- |locator|'s [=file system locator/kind=] has to be "{{FileSystemHandleKind/file}} ",
260- |locator|'s [=file system locator/path=] has to be « "`data`", "`drafts`", "`example.txt`" », and
261- |locator|'s [=file system locator/root=] might include relevant identifying
262- information such as the [=storage bucket=] and the disk drive.
263-
264- A [=/file system locator=] |a| is <dfn for="file system locator">the same locator as</dfn>
265- a [=/file system locator=] |b| if
266- |a|'s [=file system locator/kind=] is |b|' s [=file system locator/kind=] ,
267- |a|'s [=file system locator/root=] is |b|' s [=file system locator/root=] , and
268- |a|'s [=file system locator/path=] is [=the same path as=] |b|' s [=file system locator/path=] .
269-
270324<div algorithm>
271325The <dfn export data-lt="locating an entry">locate an entry</dfn> algorithm given a
272- [=/file system locator=] |locator| runs an [=implementation-defined=] series of steps adhering to
273- these constraints:
326+ [=/file system locator=] |locator| runs the following steps:
274327
275- - If |locator| is a [=file locator=] , they return a [=file entry=] or null.
276- - If |locator| is a [=directory locator=] , they return a [=directory entry=] or null.
277- - If these steps return a non-null |entry|, then:
278- - [=Getting the locator=] with |entry| returns |locator|,
279- provided no intermediate file system operations were run.
280- - |entry|'s [=file system entry/name=] is the last [=list/item=] of |locator|' s
281- [=file system locator/path=] .
328+ 1. Let |file system| be |locator|'s [=file system locator/file system=] .
329+ 1. Let |path| be |locator|'s [=file system locator/path=] .
330+ 1. Let |entry| be the result of running |file system|'s
331+ [=file system/locate an entry=] given |path|.
332+ 1. If |entry| is null, return null.
333+ 1. If |locator| is a [=file locator=] , [=Assert=] : |entry| is a [=file entry=] .
334+ 1. If |locator| is a [=directory locator=] , [=Assert=] : |entry| is a [=directory entry=] .
335+ 1. Return |entry|.
282336
283337</div>
284338
285339<div algorithm>
286- The <dfn export data-lt="getting the locator">get the locator</dfn> algorithm given
287- [=/file system entry=] |entry| runs an [=implementation-defined=] series of steps adhering to these
288- constraints:
289-
290- - If |entry| is a [=file entry=] , they return a [= file locator=] .
291- - If |entry| is a [=directory entry=] , they return a [=directory locator=] .
292- - If these steps return | locator|, then:
293- - [=Locating an entry =] with |locator| returns |entry|,
294- provided no intermediate file system operations were run .
295- - |entry|'s [=file system entry/name=] is the last [=list/item =] of |locator|' s
296- [=file system locator/path=] .
340+ The <dfn export data-lt="getting the locator">get the locator</dfn> algorithm given a
341+ [=/file system entry=] |entry| runs the following steps:
342+
343+ 1. Let |file system| be |entry|'s [=file system entry/file system=] .
344+ 1. Let |path| be the result of running | file system|'s
345+ [=file system/get the path=] given |entry| .
346+ 1. Let |locator| be a [=file system locator=] whose [=file system locator/path=]
347+ is |path| and whose [=file system locator/file system =] is |file system|.
348+ 1. If |entry| is a [=file entry=] , set |locator|'s [= file system locator/kind=] to "file" .
349+ 1. If |entry| is a [=directory entry=] , set |locator|'s [=file system locator/kind =] to "directory".
350+ 1. Return |entry| .
297351
298352</div>
299353
300- A <dfn export>file system path</dfn> is a [=/list=] of one or more [=strings=] .
301- This may be a virtual path that is mapped to real location on disk or in memory,
302- may correspond directly to a path on the local file system, or may not
303- correspond to any file on disk at all. The actual physical location of the
304- corresponding [=/file system entry=] is [=implementation-defined=] .
305-
306- <p class=example id=example-path> Let |path| be the [=/list=]
307- « "`data`", "`drafts`", "`example.txt`" ».
308- There is no expectation that a file named `example.txt` exists anywhere on disk.
309-
310- A [=/file system path=] |a| is <dfn for="file system path">the same path as</dfn>
311- a [=/file system path=] |b| if
312- |a|'s [=list/size=] is the same as |b|' s [=list/size=] and
313- [=list/for each=] |index| of |a|'s [=list/indices=]
314- |a|.\[[|index|]] is |b|.\[[|index|]] .
315-
316354<p class=warning> The contents of a [=/file system locator=] , including its
317355[=file system locator/path=] , are not expected to be shared in their entirety
318356with the website process. The [=/file system path=] might contain components
@@ -443,12 +481,12 @@ given a [=directory locator=] |parentLocator| and a string |name| in a [=/Realm=
443481
4444821. Let |handle| be a [=new=] {{FileSystemFileHandle}} in |realm|.
4454831. Let |childType| be "{{FileSystemHandleKind/file}} ".
446- 1. Let |childRoot | be a copy of |parentLocator|'s [=file system locator/root=] .
484+ 1. Let |childFileSystem | be the |parentLocator|'s [=file system locator/file system=]
4474851. Let |childPath| be the result of [=list/clone|cloning=] |parentLocator|'s
448486 [=file system locator/path=] and [=list/append|appending=] |name|.
4494871. Set |handle|'s [=FileSystemHandle/locator=] to a [=/file system locator=] whose
450488 [=file system locator/kind=] is |childType|,
451- [=file system locator/root =] is |childRoot |, and
489+ [=file system locator/file system =] is |childFileSystem |, and
452490 [=file system locator/path=] is |childPath|.
4534911. Return |handle|.
454492
@@ -457,13 +495,13 @@ given a [=directory locator=] |parentLocator| and a string |name| in a [=/Realm=
457495<div algorithm>
458496To
459497<dfn export data-lt="creating a new FileSystemFileHandle">create a new `FileSystemFileHandle`</dfn>
460- given a [=/file system root =] |root | and a [=/file system path=] |path|
498+ given a [=/file system=] |file system | and a [=/file system path=] |path|
461499in a [=/Realm=] |realm|:
462500
4635011. Let |handle| be a [=new=] {{FileSystemFileHandle}} in |realm|.
4645021. Set |handle|'s [=FileSystemHandle/locator=] to a [=/file system locator=] whose
465503 [=file system locator/kind=] is "{{FileSystemHandleKind/file}} ",
466- [=file system locator/root =] is |root |, and
504+ [=file system locator/file system =] is |file system |, and
467505 [=file system locator/path=] is |path|.
4685061. Return |handle|.
469507
@@ -698,12 +736,12 @@ given a [=directory locator=] |parentLocator| and a string |name| in a [=/Realm=
698736
6997371. Let |handle| be a [=new=] {{FileSystemDirectoryHandle}} in |realm|.
7007381. Let |childType| be "{{FileSystemHandleKind/directory}} ".
701- 1. Let |childRoot | be a copy of |parentLocator|'s [=file system locator/root =] .
739+ 1. Let |childFileSystem | be the |parentLocator|'s [=file system locator/file system =] .
7027401. Let |childPath| be the result of [=list/clone|cloning=] |parentLocator|'s
703741 [=file system locator/path=] and [=list/append|appending=] |name|.
7047421. Set |handle|'s [=FileSystemHandle/locator=] to a [=/file system locator=] whose
705743 [=file system locator/kind=] is |childType|,
706- [=file system locator/root =] is |childRoot |, and
744+ [=file system locator/file system =] is |childFileSystem |, and
707745 [=file system locator/path=] is |childPath|.
7087461. Return |handle|.
709747
@@ -712,13 +750,13 @@ given a [=directory locator=] |parentLocator| and a string |name| in a [=/Realm=
712750<div algorithm>
713751To
714752<dfn export data-lt="creating a new FileSystemDirectoryHandle">create a new `FileSystemDirectoryHandle`</dfn>
715- given a [=/file system root =] |root | and a [=/file system path=] |path|
753+ given a [=/file system=] |file system | and a [=/file system path=] |path|
716754in a [=/Realm=] |realm|:
717755
7187561. Let |handle| be a [=new=] {{FileSystemDirectoryHandle}} in |realm|.
7197571. Set |handle|'s [=FileSystemHandle/locator=] to a [=/file system locator=] whose
720758 [=file system locator/kind=] is "{{FileSystemHandleKind/directory}} ",
721- [=file system locator/root =] is |root |, and
759+ [=file system locator/file system =] is |file system |, and
722760 [=file system locator/path=] is |path|.
7237611. Return |handle|.
724762
@@ -1675,12 +1713,17 @@ guarantee.
16751713
16761714# Accessing the Bucket File System # {#sandboxed-filesystem}
16771715
1678- The <dfn export id=origin-private-file-system>bucket file system</dfn> is a
1679- [=storage endpoint=] whose
1680- <a spec=storage for="storage endpoint">identifier</a> is `"fileSystem"`,
1716+ The <dfn export id=origin-private-file-system>bucket file system</dfn>
1717+ is a [=/file system=] implementation
1718+ whose [=file system/root=] is an [=implementation-defined=] opaque [=string=]
1719+ and whose [=storage endpoint=] 's
1720+ <a spec=storage for="storage endpoint">identifier</a> of `"fileSystem"`,
16811721<a spec=storage for="storage endpoint">types</a> are `« "local" »`,
16821722and <a spec=storage for="storage endpoint">quota</a> is null.
16831723
1724+ Note: [=/bucket file system=] 's [=file system/root=] might include relevant
1725+ identifying information such as the [=storage bucket=] .
1726+
16841727Issue: Storage endpoints should be defined in [[storage]] itself, rather
16851728than being defined here. So merge this into the table there.
16861729
@@ -1721,13 +1764,10 @@ The <dfn method for=StorageManager>getDirectory()</dfn> method steps are:
17211764 1. Set |dir|'s [=directory entry/children=] to an empty [=/set=] .
17221765 1. Set |map|["root"] to |dir|.
17231766
1724- 1. Let |root | be an [=implementation-defined=] opaque [=string =] .
1767+ 1. Let |file system | be [=/bucket file system=] 's [=file system/root =] .
172517681. Let |path| be « the empty string ».
172617691. Let |handle| be the result of <a>creating a new `FileSystemDirectoryHandle`</a> .
1727- given |root| and |path| in the [=current realm=] .
1728-
1729- Note: |root| might include relevant identifying information such as the
1730- [=storage bucket=] .
1770+ given |file system| and |path| in the [=current realm=] .
17311771
173217721. Assert: [=locating an entry=] given |handle|'s [=FileSystemHandle/locator=]
17331773 returns a [=directory entry=] that is [=the same entry as=] |map|["root"] .
0 commit comments