Skip to content

Commit

Permalink
Rework FileSystemDirectoryReader definition
Browse files Browse the repository at this point in the history
Previously, FileSystemDirectoryReader IDL type was defined as having
an associated "directory reader" concept type, but (a) the properties
of that concept type were erroneously defined globally and (b) no
indirection from "this" to it's associated concept object to the
properties was done. Simplify by removing the concept object entirely,
and defining the properties as associated with the IDL type object,
properly scoped.

The association of an entry and directory was very loose and done
without naming the property. Explicitly name those.

No normative/observable behavior changes, just a (significant)
clarification in the text.
  • Loading branch information
inexorabletash committed Jul 5, 2023
1 parent c58c0e3 commit c1baef8
Showing 1 changed file with 22 additions and 49 deletions.
71 changes: 22 additions & 49 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,6 @@ note:
The <dfn for=entry>file system</dfn> of an [=entry=] is the
[=/file system=] associated with the [=entry=]'s [=entry/root=].

<!-- ============================================================ -->
## Directory Reader ## {#dir-reader}
<!-- ============================================================ -->

A <dfn>directory reader</dfn> consists of an associated [=directory
entry=], an associated [=directory=] (initially null), a <dfn>reading
flag</dfn> (initially unset), a <dfn>done flag</dfn> (initially
unset), and a <dfn>reader error</dfn> (initially null).


<!-- ============================================================ -->
# Algorithms # {#algorithms}
<!-- ============================================================ -->
Expand Down Expand Up @@ -632,11 +622,8 @@ entry=].

The <dfn method for=FileSystemDirectoryEntry>createReader()</dfn> method steps are:

1. Let |reader| be a new [=directory reader=] associated with the
[=directory entry=]'s [=directory=].

1. Return a newly created {{FileSystemDirectoryReader}} object
associated with |reader|.
associated with [=directory entry=].

</div>

Expand Down Expand Up @@ -754,60 +741,46 @@ interface FileSystemDirectoryReader {
callback FileSystemEntriesCallback = undefined (sequence<FileSystemEntry> entries);
</xmp>

A {{FileSystemDirectoryReader}} has an associated [=directory reader=].
<div dfn-for=FileSystemDirectoryReader>
A {{FileSystemDirectoryReader}} has
an associated <dfn>entry</dfn> (a [=directory entry=]),
an associated <dfn>directory</dfn> (initially null),
a <dfn>reading flag</dfn> (initially unset),
a <dfn>done flag</dfn> (initially unset),
and a <dfn>reader error</dfn> (initially null).
</div>

<div algorithm>

The <dfn method for=FileSystemDirectoryEntry>readEntries(|successCallback|, |errorCallback|)</dfn> method steps are:

1. If [=/this=]'s [=reading flag=] is set, [=queue a
task=] to [=invoke=] |errorCallback| with a newly
[=exception/created=] "{{InvalidStateError}}" {{DOMException}}, and abort these
steps.
1. If [=/this=]'s [=FileSystemDirectoryReader/reading flag=] is set, [=queue a task=] to [=invoke=] |errorCallback| with a newly [=exception/created=] "{{InvalidStateError}}" {{DOMException}}, and abort these steps.

1. If [=/this=]'s [=reader error=] is not null, [=queue
a task=] to [=invoke=] |errorCallback| (if given)
with [=reader error=], and abort these steps.
1. If [=/this=]'s [=FileSystemDirectoryReader/reader error=] is not null, [=queue a task=] to [=invoke=] |errorCallback| (if given) with [=FileSystemDirectoryReader/reader error=], and abort these steps.

1. If [=/this=]'s [=done flag=] is set, [=queue a
task=] to [=invoke=] |successCallback| with an empty
sequence and abort these steps.
1. If [=/this=]'s [=FileSystemDirectoryReader/done flag=] is set, [=queue a task=] to [=invoke=] |successCallback| with an empty sequence and abort these steps.

1. Set [=/this=]'s [=reading flag=].
1. Set [=/this=]'s [=FileSystemDirectoryReader/reading flag=].

1. [=Queue a task=] to perform the following steps:

1. Clear [=/this=]'s [=reading flag=].

1. Let |dir| be [=/this=]'s [=directory=].
1. Clear [=/this=]'s [=FileSystemDirectoryReader/reading flag=].

1. If |dir| is null, then:
1. If [=/this=]'s [=FileSystemDirectoryReader/directory=] is null, then:

1. Let |dir| be the result of [=evaluating
a path=] with [=/this=]'s [=entry/root=] and [=full path=].
1. Let |dir| be the result of [=evaluating a path=] with [=/this=]'s [=FileSystemDirectoryReader/entry=]'s [=entry/root=] and [=full path=].

1. If |dir| is failure, set [=/this=]'s
[=reader error=] to a newly [=exception/created=]
"{{NotFoundError}}" {{DOMException}}, [=invoke=] |errorCallback|
(if given) with [=reader error=], and abort these
steps.
1. If |dir| is failure, then set [=/this=]'s [=FileSystemDirectoryReader/reader error=] to a newly [=exception/created=] "{{NotFoundError}}" {{DOMException}}, [=invoke=] |errorCallback| (if given) with [=FileSystemDirectoryReader/reader error=], and abort these steps.

1. Set [=/this=]'s [=directory=] to |dir|.
1. Set [=/this=]'s [=FileSystemDirectoryReader/directory=] to |dir|.

1. Let |entries| be a non-zero number of entries from the
|dir| that have not yet been produced by this
[=directory reader=], if any.
1. Let |entries| be a non-zero number of entries from [=/this=]'s [=FileSystemDirectoryReader/directory=] that have not yet been produced by this {{FileSystemDirectoryReader}}, if any.

1. If the previous step failed (for example, the [=directory=] was
deleted or permission is denied), then set [=/this=]'s
[=reader error=] to an appropriate {{DOMException}},
[=invoke=] |errorCallback| (if given) with
[=reader error=], and abort these steps.
1. If the previous step failed (for example, the [=directory=] was deleted or permission is denied), then set [=/this=]'s [=FileSystemDirectoryReader/reader error=] to an appropriate {{DOMException}}, [=invoke=] |errorCallback| (if given) with [=FileSystemDirectoryReader/reader error=], and abort these steps.

1. If |entries| is empty, set [=/this=]'s [=done
flag=].
1. If |entries| is empty, set [=/this=]'s [=FileSystemDirectoryReader/done flag=].

1. [=invoke=] |successCallback| with |entries|.
1. [=Invoke=] |successCallback| with |entries|.

</div>

Expand Down

0 comments on commit c1baef8

Please sign in to comment.