close();
+ void truncate([EnforceRange] unsigned long long newSize);
+ unsigned long long getSize();
+ void flush();
+ void close();
};
@@ -1059,9 +1058,8 @@ a string that may exclusively be "`open`" or "`closed`".
A {{FileSystemSyncAccessHandle}} is an object that is capable of reading from/writing to,
as well as obtaining and changing the size of, a single file.
-The {{FileSystemSyncAccessHandle/read()}} and {{FileSystemSyncAccessHandle/write()}} methods are synchronous.
-This allows for higher performance for critical methods on contexts where asynchronous
-operations come with high overhead, e.g., WebAssembly.
+A {{FileSystemSyncAccessHandle}} offers synchronous methods. This allows for higher performance on
+contexts where asynchronous operations come with high overhead, e.g., WebAssembly.
To create a new FileSystemSyncAccessHandle given a [=file entry=] |file|
@@ -1121,7 +1119,7 @@ these steps:
The write(|buffer|, {{FileSystemReadWriteOptions}}: |options|) method, when invoked, must run
these steps:
-1. If [=this=].[=[[state]]=] is "`closed`", throw a {{InvalidStateError}}.
+1. If [=this=].[=[[state]]=] is "`closed`", throw an {{InvalidStateError}}.
1. Let |writePosition| be |options|.{{FileSystemReadWriteOptions/at}}.
1. Let |fileContents| be a copy of [=this=].[=[[file]]=]'s [=file entry/binary data=].
1. Let |oldSize| be |fileContents|'s [=byte sequence/length=].
@@ -1168,26 +1166,21 @@ these steps:
The truncate(|newSize|) method, when invoked, must run
these steps:
-1. If [=this=].[=[[state]]=] is "`closed`", return [=a promise rejected with=] an {{InvalidStateError}}.
+1. If [=this=].[=[[state]]=] is "`closed`", throw an {{InvalidStateError}}.
1. Let |fileContents| be a copy of [=this=].[=[[file]]=]'s [=file entry/binary data=].
-1. Let |p| be [=a new promise=] created in the [=relevant Realm=] of [=this=].
-1. Run the following steps [=in parallel=]:
- 1. Let |oldSize| be the [=byte sequence/length=] of [=this=].[=[[file]]=]'s [=file entry/binary data=].
- 1. If |newSize| is larger than |oldSize|:
- 1. If |newSize| − |oldSize| exceeds the available [=storage quota=], [=/reject=] |p|
- with a {{QuotaExceededError}} and abort.
- 1. Set [=this=].[=[[file]]=]'s to a [=byte sequence=] formed by concatenating
- |fileContents| with a [=byte sequence=]
- containing |newSize| − |oldSize| 0x00 bytes.
- 1. If the operations modifying the [=this=].[=[[file]]=]'s [=file entry/binary data=] in the previous steps
- failed, [=/reject=] |p| with a {{InvalidStateError}} and abort.
- 1. Otherwise, if |newSize| is smaller than |oldSize|:
- 1. Set [=this=].[=[[file]]=]'s to a [=byte sequence=] containing the first |newSize| bytes
- in |fileContents|.
- 1. If the operations modifying the [=this=].[=[[file]]=]'s [=file entry/binary data=] in the previous steps
- failed, [=/reject=] |p| with a {{InvalidStateError}} and abort.
- 1. [=/Resolve=] |p|.
-1. Return |p|.
+1. Let |oldSize| be the [=byte sequence/length=] of [=this=].[=[[file]]=]'s [=file entry/binary data=].
+1. If |newSize| is larger than |oldSize|:
+ 1. If |newSize| − |oldSize| exceeds the available [=storage quota=], throw a {{QuotaExceededError}}.
+ 1. Set [=this=].[=[[file]]=]'s to a [=byte sequence=] formed by concatenating
+ |fileContents| with a [=byte sequence=]
+ containing |newSize| − |oldSize| 0x00 bytes.
+ 1. If the operations modifying the [=this=].[=[[file]]=]'s [=file entry/binary data=] in the previous steps
+ failed, throw an {{InvalidStateError}}.
+1. Otherwise, if |newSize| is smaller than |oldSize|:
+ 1. Set [=this=].[=[[file]]=]'s to a [=byte sequence=] containing the first |newSize| bytes
+ in |fileContents|.
+ 1. If the operations modifying the [=this=].[=[[file]]=]'s [=file entry/binary data=] in the previous steps
+ failed, throw an {{InvalidStateError}}.
@@ -1202,12 +1195,9 @@ these steps:
The getSize() method, when invoked, must run
these steps:
-1. If [=this=].[=[[state]]=] is "`closed`", return [=a promise rejected with=] an {{InvalidStateError}}.
-1. Let |p| be [=a new promise=] created in the [=relevant Realm=] of [=this=].
-1. Run the following steps [=in parallel=]:
- 1. Let |size| be the [=byte sequence/length=] of [=this=].[=[[file]]=]'s [=file entry/binary data=].
- 1. [=/Resolve=] |p| with |size|.
-1. Return |p|.
+1. If [=this=].[=[[state]]=] is "`closed`", throw an {{InvalidStateError}}.
+1. Let |size| be the [=byte sequence/length=] of [=this=].[=[[file]]=]'s [=file entry/binary data=].
+1. Return |size|.
@@ -1240,11 +1230,7 @@ these steps:
The close() method, when invoked, must run
these steps:
-1. Let |p| be [=a new promise=] created in the [=relevant Realm=] of [=this=].
-1. Run the following steps [=in parallel=]:
- 1. Set [=this=].[=[[state]]=] to "`closed`".
- 1. [=/Resolve=] |p|.
-1. Return |p|.
+1. Set [=this=].[=[[state]]=] to "`closed`".