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
:: Resizes the file associated with stream to be size bytes long. If size is larger than the current file size this pads the file with null bytes, otherwise it truncates the file.
:: Resizes the file associated with stream to be |newSize| bytes long. If size is larger than the current file size this pads the file with null bytes, otherwise it truncates the file.
1375
1375
</div>
1376
1376
1377
-
//TODO(fivedots):Make sure negative lengths are not allowed.
1378
1377
<div algorithm>
1379
-
The <dfn method for=FileSystemSyncAccessHandle>truncate(|size|)</dfn> method, when invoked, must run
1378
+
The <dfn method for=FileSystemSyncAccessHandle>truncate(|newSize|)</dfn> method, when invoked, must run
1380
1379
these steps:
1381
1380
1382
-
// TODO(fivedots): fill in.
1381
+
1. If [=this=].[=[[state]]=] is "closed", throw a {{InvalidStateError}}.
1382
+
1. If |newSize| is less than 0, throw a {{InvalidStateError}}.
1383
+
1. Let |fileContents| be a copy of [=this=].[=[[file]]=]'s [=file entry/binary data=].
1384
+
1. Let |p| be [=a new promise=].
1385
+
1. Run the following steps [=in parallel=]:
1386
+
1. Let |oldSize| be the [=byte sequence/length=] of [=this=].[=[[file]]=]'s [=file entry/binary data=].
1387
+
1. If |newSize| is larger than |oldSize|:
1388
+
1. If |newSize| - |oldSize| exceeds the available [=storage quota=], [=/reject=] |p|
1389
+
with a {{QuotaExceededError}} and abort.
1390
+
1. Set [=this=].[=[[file]]=]'s to a [=byte sequence=] formed by concating
1391
+
|fileContents| with a [=byte sequence=]
1392
+
containing |newSize|-|oldSize| `0x00` bytes.
1393
+
1. Else if |newSize| is smaller than |oldSize|:
1394
+
1. Set [=this=].[=[[file]]=]'s to a [=byte sequence=] containing the first |newSize| bytes
1395
+
in |fileContents|.
1396
+
1. [=/Resolve=] |p|.
1397
+
1. Return |p|
1383
1398
1384
1399
</div>
1385
1400
@@ -1394,7 +1409,13 @@ these steps:
1394
1409
The <dfn method for=FileSystemSyncAccessHandle>getSize()</dfn> method, when invoked, must run
1395
1410
these steps:
1396
1411
1397
-
// TODO(fivedots): fill in.
1412
+
1. If [=this=].[=[[state]]=] is "closed", throw a {{InvalidStateError}}.
1413
+
1. Let |p| be [=a new promise=].
1414
+
1. Run the following steps [=in parallel=]:
1415
+
1. Let |size| be the [=byte sequence/length=] of [=this=].[=[[file]]=]'s [=file entry/binary data=].
1416
+
1. [=/Resolve=] |p| with |size|.
1417
+
1. Return |p|
1418
+
1398
1419
1399
1420
</div>
1400
1421
@@ -1409,7 +1430,7 @@ these steps:
1409
1430
The <dfn method for=FileSystemSyncAccessHandle>flush()</dfn> method, when invoked, must run
1410
1431
these steps:
1411
1432
1412
-
// TODO(fivedots): fill in.
1433
+
// TODO(fivedots): Fill in, after figuring out language to describe flushing at the OS level.
0 commit comments