You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Promise<void> write((BufferSource or Blob or USVString or WriteParams) data);
Promise<void> seek(unsigned long long position);
Promise<void> truncate(unsigned long long size);
Promise<void> close();
};
</xmp>
Issue(19): We want some kind of integration with writable streams. One possible option is to make
FileStreamWriter inherit from WritableStream, but other options should be considered as well.
A {{FileSystemWritableFileStream}} object is a {{WritableStream}} object with additional methods to operate
on a single file on disk.
Upon creation, an underlying sink will have been created and the stream will be usable. All operations executed on the stream are queuable and producers will be able to respond to backpressure.
The underlying sink's write method, and therefore {{WritableStreamDefaultWriter/write()|WritableStreamDefaultWriter's write()}} method, will accept byte-like data or {{WriteParams}} as input.
The {{FileSystemWritableFileStream}} has a file position cursor initialized at byte offset 0 from the top of the file. When using {{FileSystemWritableFileStream/write()|write()}} or by using WritableStream capabilities through the {{WritableStreamDefaultWriter/write()|WritableStreamDefaultWriter's write()}} method, this position will be advanced based on the number of bytes written through the stream object.
Similarly, when piping a {{ReadableStream}} into a {{FileSystemWritableFileStream}} object, this position is updated with the number of bytes that passed through the stream.
### The {{FileSystemWriter/write()}} method ### {#api-filesystemwriter-write}
{{WritableStream/getWriter()|getWriter()}} returns an instance of {{WritableStreamDefaultWriter}}.
<div algorithm="serialization steps">
{{FileSystemWritableFileStream}} objects are [=serializable objects=]. They not cloneable, i.e. they are transferable-only, as are {{WritableStream}} objects.
Advisement: In the Origin Trial as available in Chrome 82, these objects are not yet serializable.
Their [=serialization steps=], given |value|, |serialized| and |forStorage| are:
1. Set |serialized|.\[[Origin]] to |value|'s [=relevant settings object=]'s [=environment settings object/origin=].
1. TODO
</div>
<div algorithm="deserialization steps">
Their [=deserialization steps=], given |serialized| and |value| are:
1. If |serialized|.\[[Origin]] is not [=same origin=] with
:: Writes the content of |data| into the file associated with |stream| at the current file
cursor offset in bytes from the top of the file by default.
No changes are written to the actual file until on disk until {{FileSystemWriter/close()}}
No changes are written to the actual file until on disk until {{FileSystemWritableFileStream/close()}}
is called. Changes are typically written to a temporary file instead.
If |data| is of type {{WriteParams}}, validates and executes the content of |data|, which might result in changes into the file associated with |stream|.
{{WriteParams}} requires the attribute {{WriteParams/type|type}} which determines what the operations to
execute are.
If {{WriteParams/type|type}} is {{truncate}}, {{WriteParams/size|size}} is a <span class=allow-2119>required</span> attribute.
If {{WriteParams/type|type}} is {{seek}}, {{WriteParams/position|position}} is a <span class=allow-2119>required</span> attribute.
If {{WriteParams/type|type}} is {{write}}, {{WriteParams/position|position}} is an <span class=allow-2119>optional</span> attribute, {{WriteParams/data|data}} is a <span class=allow-2119>required</span> attribute.
No changes are written to the actual file until on disk until {{FileSystemWritableFileStream/close()}}
is called. Changes are typically written to a temporary file instead.
</div>
<div algorithm>
The <dfn method for=FileSystemWriter>write(|position|, |data|)</dfn> method, when invoked, must run
The <dfn method for=FileSystemWritableFileStream>write(|data|)</dfn> method, when invoked, must run
these steps:
1. TODO
</div>
### The {{FileSystemWriter/truncate()}} method ### {#api-filesystemwriter-truncate}
### The {{FileSystemWritableFileStream/truncate()}} method ### {#api-filesystemwritablefilestream-truncate}
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace createWriter, FileSystemWriter with createWritable, WritableFileStream #62
Replace createWriter, FileSystemWriter with createWritable, WritableFileStream #62
Changes from all commits
7f9fa0d
890e901
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing