Skip to content

Commit

Permalink
make a FileSystemHandle have an associated path
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sully committed Feb 24, 2023
1 parent 8cf7d22 commit b28fdd9
Showing 1 changed file with 43 additions and 21 deletions.
64 changes: 43 additions & 21 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ different storage mechanism with a different API for such files. The entry point

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 {{PermissionState}}. Unless specified
otherwise it returns "{{PermissionState/denied}}". The algorithm is allowed to throw.

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 {{PermissionState}}. Unless specified
otherwise it returns "{{PermissionState/denied}}". The algorithm is allowed to throw.

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=].

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 "..",
Expand Down Expand Up @@ -147,11 +136,12 @@ Exactly how external changes are reflected in the data structures defined by thi
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="entry">the same as</dfn> an [=/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.
A [=/file system entry=] <dfn for="file system entry">exists</dfn> if it is
backed by a file or directory on the underlying file system.

Issue(59): Explain better how entries map to files on disk (multiple entries can map to the same file or
directory on disk but an entry doesn't have to map to any file on disk).
A [=/file system entry=] |a| is <dfn for="file system entry">the same 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>

Expand All @@ -176,6 +166,27 @@ run these steps:

</div>

A <dfn export>file system path</dfn> is an implementation-defined type
representing a potential location of a [=/file system entry=]. For example, this
may be to 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.

Each [=/file system path=] has an associated <dfn for="file system path">locate</dfn>
algorithm, which returns a [=/file system entry=]. Exactly how a [=/file system path=]
maps to a [=/file system entry=] left up to individual user-agent implementations.

Each [=/file system path=] has an associated <dfn for="file system path" id=entry-query-access>query access</dfn> algorithm, which takes "`read`"
or "`readwrite`" <var ignore>mode</var> and returns a {{PermissionState}}. Unless specified
otherwise it returns "{{PermissionState/denied}}". The algorithm is allowed to throw.

Each [=/file system path=] has an associated <dfn for="file system path" id=entry-request-access>request access</dfn> algorithm, which takes
"`read`" or "`readwrite`" <var ignore>mode</var> and returns a {{PermissionState}}. Unless specified
otherwise it returns "{{PermissionState/denied}}". The algorithm is allowed to throw.

Note: Implementations that only implement this specification and not dependent specifications do not
need to bother implementing [=/file system path=]'s [=file system path/query access=] and [=file system path/request access=].

## The {{FileSystemHandle}} interface ## {#api-filesystemhandle}

<xmp class=idl>
Expand All @@ -193,9 +204,18 @@ interface FileSystemHandle {
};
</xmp>

A {{FileSystemHandle}} object represents a [=/file system entry=]. Each {{FileSystemHandle}} object is associated
with an <dfn for=FileSystemHandle export>entry</dfn> (a [=/file system entry=]). Multiple separate objects implementing
the {{FileSystemHandle}} interface can all be associated with the same [=/file system entry=] simultaneously.
A {{FileSystemHandle}} object represents a [=/file system path=].
Each {{FileSystemHandle}} object is associated with a
<dfn for=FileSystemHandle export>path</dfn> (a [=/file system path=]).
Multiple separate objects implementing the {{FileSystemHandle}} interface can
all be associated with the same [=/file system path=] simultaneously.

<div algorithm>
To <dfn for=FileSystemHandle id=get-handle-entry data-lt="getting the entry">get the entry</dfn>
of a given {{FileSystemHandle}} |handle|, return the [=/file system entry=] from
[=file system path/locate|locating] |handle|'s [=FileSystemHandle/path=].

</div>

<div algorithm="serialization steps">
{{FileSystemHandle}} objects are [=serializable objects=].
Expand Down Expand Up @@ -289,12 +309,14 @@ A {{FileSystemFileHandle}}'s associated [=FileSystemHandle/entry=] must be a [=f
The <dfn method for=FileSystemFileHandle>getFile()</dfn> method steps are:

1. Let |result| be [=a new promise=].
1. Let |entry| be the the result of [=getting the entry=] for [=this=].
1. Run these steps [=in parallel=]:
1. Let |access| be the result of running [=this=]'s [=FileSystemHandle/entry=]'s
[=file system entry/query access=] given "`read`".
1. Let |access| be the result of running [=this=]'s [=FileSystemHandle/path=]'s
[=file system path/query access=] given "`read`".
1. If |access| is not "{{PermissionState/granted}}",
[=/reject=] |result| with a "{{NotAllowedError}}" {{DOMException}} and abort.
1. Let |entry| be [=this=]'s [=FileSystemHandle/entry=].
1. If |entry| does not [=file system entry/exist=],
[=/reject=] |result| with a "{{NotFoundError}}" {{DOMException}} and abort.
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=].
Expand Down

0 comments on commit b28fdd9

Please sign in to comment.