@@ -375,9 +375,8 @@ The <dfn method for=FileSystemFileHandle>createWritable(|options|)</dfn> method,
375
375
further {{FileSystemSyncAccessHandle}} s or {{FileSystemWritableFileStream}} s
376
376
for the entry, until the access handle is closed.
377
377
378
- The returned {{FileSystemSyncAccessHandle}} offers synchronous {{FileSystemSyncAccessHandle/read()}} and
379
- {{FileSystemSyncAccessHandle/write()}} methods. This allows for higher performance for critical methods on
380
- contexts where asynchronous operations come with high overhead, e.g., WebAssembly.
378
+ The returned {{FileSystemSyncAccessHandle}} offers synchronous methods. This allows for higher performance
379
+ on contexts where asynchronous operations come with high overhead, e.g., WebAssembly.
381
380
382
381
For the time being, this method will only succeed when the |fileHandle| belongs to the
383
382
[=origin private file system=] .
@@ -1035,10 +1034,10 @@ interface FileSystemSyncAccessHandle {
1035
1034
unsigned long long write([AllowShared] BufferSource buffer,
1036
1035
optional FileSystemReadWriteOptions options = {});
1037
1036
1038
- Promise < undefined> truncate([EnforceRange] unsigned long long newSize);
1039
- Promise < unsigned long long> getSize();
1040
- Promise < undefined> flush();
1041
- Promise < undefined> close();
1037
+ undefined truncate([EnforceRange] unsigned long long newSize);
1038
+ unsigned long long getSize();
1039
+ undefined flush();
1040
+ undefined close();
1042
1041
};
1043
1042
1044
1043
</xmp>
@@ -1052,9 +1051,8 @@ a string that may exclusively be "`open`" or "`closed`".
1052
1051
A {{FileSystemSyncAccessHandle}} is an object that is capable of reading from/writing to,
1053
1052
as well as obtaining and changing the size of, a single file.
1054
1053
1055
- The {{FileSystemSyncAccessHandle/read()}} and {{FileSystemSyncAccessHandle/write()}} methods are synchronous.
1056
- This allows for higher performance for critical methods on contexts where asynchronous
1057
- operations come with high overhead, e.g., WebAssembly.
1054
+ A {{FileSystemSyncAccessHandle}} offers synchronous methods. This allows for higher performance on
1055
+ contexts where asynchronous operations come with high overhead, e.g., WebAssembly.
1058
1056
1059
1057
<div algorithm>
1060
1058
To <dfn>create a new FileSystemSyncAccessHandle</dfn> given a [=file entry=] |file|
@@ -1114,7 +1112,7 @@ these steps:
1114
1112
The <dfn method for=FileSystemSyncAccessHandle>write(|buffer|, {{FileSystemReadWriteOptions}}: |options|)</dfn> method, when invoked, must run
1115
1113
these steps:
1116
1114
1117
- 1. If [=this=] .[=[[state]]=] is "`closed`", throw a {{InvalidStateError}} .
1115
+ 1. If [=this=] .[=[[state]]=] is "`closed`", throw an {{InvalidStateError}} .
1118
1116
1. Let |writePosition| be |options|.{{FileSystemReadWriteOptions/at}} .
1119
1117
1. Let |fileContents| be a copy of [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's [=file entry/binary data=] .
1120
1118
1. Let |oldSize| be |fileContents|'s [=byte sequence/length=] .
@@ -1161,26 +1159,21 @@ these steps:
1161
1159
The <dfn method for=FileSystemSyncAccessHandle>truncate(|newSize|)</dfn> method, when invoked, must run
1162
1160
these steps:
1163
1161
1164
- 1. If [=this=] .[=[[state]]=] is "`closed`", return [=a promise rejected with=] an {{InvalidStateError}} .
1162
+ 1. If [=this=] .[=[[state]]=] is "`closed`", throw an {{InvalidStateError}} .
1165
1163
1. Let |fileContents| be a copy of [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's [=file entry/binary data=] .
1166
- 1. Let |p| be [=a new promise=] created in the [=relevant Realm=] of [=this=] .
1167
- 1. Run the following steps [=in parallel=] :
1168
- 1. Let |oldSize| be the [=byte sequence/length=] of [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's [=file entry/binary data=] .
1169
- 1. If |newSize| is larger than |oldSize|:
1170
- 1. If |newSize| − |oldSize| exceeds the available [=storage quota=] , [=/reject=] |p|
1171
- with a {{QuotaExceededError}} and abort.
1172
- 1. Set [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's to a [=byte sequence=] formed by concatenating
1173
- |fileContents| with a [=byte sequence=]
1174
- containing |newSize| − |oldSize| 0x00 bytes.
1175
- 1. If the operations modifying the [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's [=file entry/binary data=] in the previous steps
1176
- failed, [=/reject=] |p| with a {{InvalidStateError}} and abort.
1177
- 1. Otherwise, if |newSize| is smaller than |oldSize|:
1178
- 1. Set [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's to a [=byte sequence=] containing the first |newSize| bytes
1179
- in |fileContents|.
1180
- 1. If the operations modifying the [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's [=file entry/binary data=] in the previous steps
1181
- failed, [=/reject=] |p| with a {{InvalidStateError}} and abort.
1182
- 1. [=/Resolve=] |p|.
1183
- 1. Return |p|.
1164
+ 1. 1. Let |oldSize| be the [=byte sequence/length=] of [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's [=file entry/binary data=] .
1165
+ 1. If |newSize| is larger than |oldSize|:
1166
+ 1. If |newSize| − |oldSize| exceeds the available [=storage quota=] , throw a {{QuotaExceededError}} .
1167
+ 1. Set [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's to a [=byte sequence=] formed by concatenating
1168
+ |fileContents| with a [=byte sequence=]
1169
+ containing |newSize| − |oldSize| 0x00 bytes.
1170
+ 1. If the operations modifying the [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's [=file entry/binary data=] in the previous steps
1171
+ failed, throw an {{InvalidStateError}} .
1172
+ 1. Otherwise, if |newSize| is smaller than |oldSize|:
1173
+ 1. Set [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's to a [=byte sequence=] containing the first |newSize| bytes
1174
+ in |fileContents|.
1175
+ 1. If the operations modifying the [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's [=file entry/binary data=] in the previous steps
1176
+ failed, throw an {{InvalidStateError}} .
1184
1177
1185
1178
</div>
1186
1179
@@ -1195,12 +1188,8 @@ these steps:
1195
1188
The <dfn method for=FileSystemSyncAccessHandle>getSize()</dfn> method, when invoked, must run
1196
1189
these steps:
1197
1190
1198
- 1. If [=this=] .[=[[state]]=] is "`closed`", return [=a promise rejected with=] an {{InvalidStateError}} .
1199
- 1. Let |p| be [=a new promise=] created in the [=relevant Realm=] of [=this=] .
1200
- 1. Run the following steps [=in parallel=] :
1201
- 1. Let |size| be the [=byte sequence/length=] of [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's [=file entry/binary data=] .
1202
- 1. [=/Resolve=] |p| with |size|.
1203
- 1. Return |p|.
1191
+ 1. If [=this=] .[=[[state]]=] is "`closed`", throw an {{InvalidStateError}} .
1192
+ 1. Return [=this=] .[=FileSystemSyncAccessHandle/[[file]]=] 's [=file entry/binary data=]' s [=byte sequence/length=] .
1204
1193
1205
1194
1206
1195
</div>
@@ -1233,11 +1222,7 @@ these steps:
1233
1222
The <dfn method for=FileSystemSyncAccessHandle>close()</dfn> method, when invoked, must run
1234
1223
these steps:
1235
1224
1236
- 1. Let |p| be [=a new promise=] created in the [=relevant Realm=] of [=this=] .
1237
- 1. Run the following steps [=in parallel=] :
1238
- 1. Set [=this=] .[=[[state]]=] to "`closed`".
1239
- 1. [=/Resolve=] |p|.
1240
- 1. Return |p|.
1225
+ 1. Set [=this=] .[=[[state]]=] to "`closed`".
1241
1226
1242
1227
</div>
1243
1228
0 commit comments