| fd | number | Yes | File descriptor of the file to read. |
| fd | number | Yes | File descriptor of the file to read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size. |
- Return value
- Return value
| Type | Description |
| Type | Description |
...
@@ -662,7 +662,7 @@ Asynchronously reads data from a file. This method uses a callback to return the
...
@@ -662,7 +662,7 @@ Asynchronously reads data from a file. This method uses a callback to return the
| fd | number | Yes | File descriptor of the file to read. |
| fd | number | Yes | File descriptor of the file to read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size. |
| callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously. |
| callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously. |
- Example
- Example
...
@@ -695,7 +695,7 @@ Synchronously reads data from a file.
...
@@ -695,7 +695,7 @@ Synchronously reads data from a file.
| fd | number | Yes | File descriptor of the file to read. |
| fd | number | Yes | File descriptor of the file to read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size. |
- Return value
- Return value
| Type | Description |
| Type | Description |
...
@@ -867,7 +867,7 @@ Asynchronously writes data into a file. This method uses a promise to return the
...
@@ -867,7 +867,7 @@ Asynchronously writes data into a file. This method uses a promise to return the
| fd | number | Yes | File descriptor of the file to write. |
| fd | number | Yes | File descriptor of the file to write. |
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size.|
- Return value
- Return value
| Type | Description |
| Type | Description |
...
@@ -903,7 +903,7 @@ Asynchronously writes data into a file. This method uses a callback to return th
...
@@ -903,7 +903,7 @@ Asynchronously writes data into a file. This method uses a callback to return th
| fd | number | Yes | File descriptor of the file to write. |
| fd | number | Yes | File descriptor of the file to write. |
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size.|
| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. |
| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. |
- Example
- Example
...
@@ -935,7 +935,7 @@ Synchronously writes data into a file.
...
@@ -935,7 +935,7 @@ Synchronously writes data into a file.
| fd | number | Yes | File descriptor of the file to write. |
| fd | number | Yes | File descriptor of the file to write. |
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size.|
- Return value
- Return value
| Type | Description |
| Type | Description |
...
@@ -1472,10 +1472,10 @@ Asynchronously reads data from a file. This method uses a promise to return the
...
@@ -1472,10 +1472,10 @@ Asynchronously reads data from a file. This method uses a promise to return the
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size.|
- Return value
- Return value
| Type | Description |
| Type | Description |
...
@@ -1509,7 +1509,7 @@ Asynchronously reads data from a file. This method uses a callback to return the
...
@@ -1509,7 +1509,7 @@ Asynchronously reads data from a file. This method uses a callback to return the
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size.|
| callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously from the file. |
| callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously from the file. |
- Example
- Example
...
@@ -2577,6 +2577,7 @@ Asynchronously stops **watcher**. This method uses a callback to return the resu
...
@@ -2577,6 +2577,7 @@ Asynchronously stops **watcher**. This method uses a callback to return the resu
```
```
## Stream<sup>7+</sup>
## Stream<sup>7+</sup>
File stream. Before calling a method of the **Stream** class, use the **createStream()** method synchronously or asynchronously to create a **Stream** instance.
File stream. Before calling a method of the **Stream** class, use the **createStream()** method synchronously or asynchronously to create a **Stream** instance.
...
@@ -2721,7 +2722,7 @@ Asynchronously writes data into the stream. This method uses a promise to return
...
@@ -2721,7 +2722,7 @@ Asynchronously writes data into the stream. This method uses a promise to return
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size. |
- Return value
- Return value
| Type | Description |
| Type | Description |
...
@@ -2753,11 +2754,11 @@ Asynchronously writes data into the stream. This method uses a callback to retur
...
@@ -2753,11 +2754,11 @@ Asynchronously writes data into the stream. This method uses a callback to retur
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size.|
| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. |
| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. |
- Example
- Example
```js
```js
...
@@ -2788,7 +2789,7 @@ Synchronously writes data into the stream.
...
@@ -2788,7 +2789,7 @@ Synchronously writes data into the stream.
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size. |
- Return value
- Return value
| Type | Description |
| Type | Description |
...
@@ -2818,7 +2819,7 @@ Asynchronously reads data from the stream. This method uses a promise to return
...
@@ -2818,7 +2819,7 @@ Asynchronously reads data from the stream. This method uses a promise to return
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size. |
- Return value
- Return value
| Type | Description |
| Type | Description |
...
@@ -2853,7 +2854,7 @@ Asynchronously reads data from the stream. This method uses a callback to return
...
@@ -2853,7 +2854,7 @@ Asynchronously reads data from the stream. This method uses a callback to return
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size. |
| callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when data is read asynchronously from the stream. |
| callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when data is read asynchronously from the stream. |
- Example
- Example
...
@@ -2884,7 +2885,7 @@ Synchronously reads data from the stream.
...
@@ -2884,7 +2885,7 @@ Synchronously reads data from the stream.
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.|
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>- The sum of **offset** and **length** must be less than or equal to the buffer size. |
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
## Modules to Import
## Modules to Import
...
@@ -15,7 +15,7 @@ import storagestatistics from "@ohos.storageStatistics";
...
@@ -15,7 +15,7 @@ import storagestatistics from "@ohos.storageStatistics";
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The initial APIs of this module are supported since API version 9.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.