FileSystemWritableFileStream Class
The state of a stream that writes a file (https://fs.spec.whatwg.org/#api-filesystemwritablefilestream), created by FileSystemFileHandle.CreateWritable: a buffer and a cursor. The buffer replaces the content of the file when the stream is closed (FileSystemWritableFileStream.Close); FileSystemWritableFileStream.Abort discards it. In the scripts, the FileSystemWritableFileStream interface is a WritableStream (Streams.js) whose underlying sink is this object.
public sealed class FileSystemWritableFileStreamProperties
| Name | Description |
|---|---|
| IsClosed | Gets whether the stream was closed or aborted: its lock is released, and it cannot be written. |
| Mode | Gets the locking mode of the stream: see FileSystemCreateWritableOptions.Mode. |
IsClosed
FileSystemFileHandle.cs- Experimental (WEBPLATEXP0007)
Gets the locking mode of the stream: see FileSystemCreateWritableOptions.Mode.
[Experimental("WEBPLATEXP0007", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public string Mode { get; }Property value
Methods
| Name | Description |
|---|---|
| Abort() | The abort algorithm of the stream: the buffer is discarded and the lock is released. Does nothing when the stream is closed. |
| Close() | The close algorithm of the stream: the buffer replaces the content of the file, and the lock is released. The file that was removed meanwhile is not created again (a NotFoundError). |
| Seek(long) | Moves the cursor (the "seek" command). |
| Truncate(long) | Sets the size of the file (the "truncate" command): the file is truncated or grows with zeros, and a cursor after its end moves to its end. |
| Write(ReadOnlySpan<byte>, long?) | Writes data at the position of the cursor, or at position (https://fs.spec.whatwg.org/#write-a-chunk), and moves the cursor after the data. The file grows with zeros when the position is after its end. |
Abort()
FileSystemFileHandle.csThe abort algorithm of the stream: the buffer is discarded and the lock is released. Does nothing when the stream is closed.
public void Abort()Close()
FileSystemFileHandle.csThe close algorithm of the stream: the buffer replaces the content of the file, and the lock is released. The file that was removed meanwhile is not created again (a NotFoundError).
public void Close()Seek(long)
FileSystemFileHandle.csTruncate(long)
FileSystemFileHandle.csSets the size of the file (the "truncate" command): the file is truncated or grows with zeros, and a cursor after its end moves to its end.
Write(ReadOnlySpan<byte>, long?)
FileSystemFileHandle.csWrites data at the position of the cursor, or at position (https://fs.spec.whatwg.org/#write-a-chunk), and moves the cursor after the data. The file grows with zeros when the position is after its end.
public void Write(ReadOnlySpan<byte> data, long? position = null)Parameters
dataReadOnlySpan<byte>positionlong?
Exceptions
QuotaExceededError- The write exceeds the quota of the storage.