未验证 提交 6eaae7e4 编写于 作者: O openharmony_ci 提交者: Gitee

!16489 [翻译完成】#I6NBCE (PR16106+16108)

Merge pull request !16489 from Annie_wang/PR16108
...@@ -31,7 +31,7 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul ...@@ -31,7 +31,7 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------ | ---- | ------------------------------------------------------------ |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-app-context.md).|
| config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. | | config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. |
| version | number | Yes | RDB store version.<br>Currently, automatic RDB upgrades and downgrades performed based on **version** is not supported. | | version | number | Yes | RDB store version.<br>Currently, automatic RDB upgrades and downgrades performed based on **version** is not supported. |
| callback | AsyncCallback&lt;[RdbStore](#rdbstore)&gt; | Yes | Callback invoked to return the RDB store obtained. | | callback | AsyncCallback&lt;[RdbStore](#rdbstore)&gt; | Yes | Callback invoked to return the RDB store obtained. |
...@@ -92,7 +92,7 @@ Obtains an RDB store. This API uses a promise to return the result. You can set ...@@ -92,7 +92,7 @@ Obtains an RDB store. This API uses a promise to return the result. You can set
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | --------------------------- | ---- | ------------------------------------------------------------ | | ------- | --------------------------- | ---- | ------------------------------------------------------------ |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-app-context.md).|
| config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. | | config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. |
| version | number | Yes | RDB store version.<br>Currently, automatic RDB upgrades and downgrades performed based on **version** is not supported. | | version | number | Yes | RDB store version.<br>Currently, automatic RDB upgrades and downgrades performed based on **version** is not supported. |
...@@ -156,7 +156,7 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul ...@@ -156,7 +156,7 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-app-context.md).|
| name | string | Yes | Name of the RDB store to delete. | | name | string | Yes | Name of the RDB store to delete. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
...@@ -214,7 +214,7 @@ Deletes an RDB store. This API uses a promise to return the result. ...@@ -214,7 +214,7 @@ Deletes an RDB store. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------- | ---- | ------------------------------------------------------------ | | ------- | ------- | ---- | ------------------------------------------------------------ |
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| | context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-app-context.md).|
| name | string | Yes | Name of the RDB store to delete. | | name | string | Yes | Name of the RDB store to delete. |
**Return value** **Return value**
...@@ -404,7 +404,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -404,7 +404,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**. | | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -433,7 +433,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -433,7 +433,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**. | | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -560,7 +560,7 @@ Sets an **RdbPredicates** to match a string containing the specified value. ...@@ -560,7 +560,7 @@ Sets an **RdbPredicates** to match a string containing the specified value.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**. | | value | string | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -588,7 +588,7 @@ Sets an **RdbPredicates** to match a string that starts with the specified value ...@@ -588,7 +588,7 @@ Sets an **RdbPredicates** to match a string that starts with the specified value
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**. | | value | string | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -616,7 +616,7 @@ Sets an **RdbPredicates** to match a string that ends with the specified value. ...@@ -616,7 +616,7 @@ Sets an **RdbPredicates** to match a string that ends with the specified value.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**. | | value | string | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -697,7 +697,7 @@ Sets an **RdbPredicates** to match a string that is similar to the specified val ...@@ -697,7 +697,7 @@ Sets an **RdbPredicates** to match a string that is similar to the specified val
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**. | | value | string | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -725,7 +725,7 @@ Sets an **RdbPredicates** to match the specified string. ...@@ -725,7 +725,7 @@ Sets an **RdbPredicates** to match the specified string.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**.<br><br>Wildcards are supported. * indicates zero, one, or multiple digits or characters. **?** indicates a single digit or character. | | value | string | Yes| Value to match the **RdbPredicates**.<br><br>Wildcards are supported. * indicates zero, one, or multiple digits or characters. **?** indicates a single digit or character.|
**Return value** **Return value**
...@@ -753,8 +753,8 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -753,8 +753,8 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| low | [ValueType](#valuetype) | Yes| Minimum value to match the **RdbPredicates**. | | low | [ValueType](#valuetype) | Yes| Minimum value to match the **RdbPredicates**.|
| high | [ValueType](#valuetype) | Yes| Maximum value to match the **RdbPredicates**. | | high | [ValueType](#valuetype) | Yes| Maximum value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -782,8 +782,8 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -782,8 +782,8 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| low | [ValueType](#valuetype) | Yes| Minimum value to match the **RdbPredicates**. | | low | [ValueType](#valuetype) | Yes| Minimum value to match the **RdbPredicates**.|
| high | [ValueType](#valuetype) | Yes| Maximum value to match the **RdbPredicates**. | | high | [ValueType](#valuetype) | Yes| Maximum value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -811,7 +811,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -811,7 +811,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**. | | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -839,7 +839,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -839,7 +839,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**. | | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -867,7 +867,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -867,7 +867,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**. | | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
...@@ -895,7 +895,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va ...@@ -895,7 +895,7 @@ Sets an **RdbPredicates** to match the field with data type **ValueType** and va
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.| | field | string | Yes| Column name in the database table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**. | | value | [ValueType](#valuetype) | Yes| Value to match the **RdbPredicates**.|
**Return value** **Return value**
......
...@@ -59,14 +59,14 @@ Obtains detailed file information. This API uses a promise to return the result. ...@@ -59,14 +59,14 @@ Obtains detailed file information. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise used to return the file information obtained.| | Promise&lt;[Stat](#stat)&gt; | Promise used to return the file information obtained.|
**Example** **Example**
```js ```js
let filePath = pathDir + "test.txt"; let filePath = pathDir + "/test.txt";
fs.stat(filePath).then((stat) => { fs.stat(filePath).then((stat) => {
console.info("get file info succeed, the size of file is " + stat.size); console.info("get file info succeed, the size of file is " + stat.size);
}).catch((err) => { }).catch((err) => {
...@@ -118,9 +118,9 @@ Obtains detailed file information synchronously. ...@@ -118,9 +118,9 @@ Obtains detailed file information synchronously.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------- | ---------- | | ------------- | ---------- |
| [Stat](#stat) | File information obtained.| | [Stat](#stat) | File information obtained.|
**Example** **Example**
...@@ -145,9 +145,9 @@ Checks whether a file exists. This API uses a promise to return the result. ...@@ -145,9 +145,9 @@ Checks whether a file exists. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;boolean&gt; | Promise used to return a Boolean value.| | Promise&lt;boolean&gt; | Promise used to return a Boolean value.|
**Example** **Example**
...@@ -232,15 +232,15 @@ Closes a file. This API uses a promise to return the result. ...@@ -232,15 +232,15 @@ Closes a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| file | [File](#file)\|number | Yes | File object or FD of the file to close.| | file | [File](#file)\|number | Yes | File object or FD of the file to close.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -265,10 +265,10 @@ Closes a file. This API uses an asynchronous callback to return the result. ...@@ -265,10 +265,10 @@ Closes a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------ | | -------- | ------------------------- | ---- | ------------ |
| file | [File](#file)\|number | Yes | File object or FD of the file to close.| | file | [File](#file)\|number | Yes | File object or FD of the file to close.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is closed asynchronously.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is closed asynchronously.|
**Example** **Example**
...@@ -294,9 +294,9 @@ Synchronously closes a file. ...@@ -294,9 +294,9 @@ Synchronously closes a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| file | [File](#file)\|number | Yes | File object or FD of the file to close.| | file | [File](#file)\|number | Yes | File object or FD of the file to close.|
**Example** **Example**
...@@ -316,23 +316,23 @@ Copies a file. This API uses a promise to return the result. ...@@ -316,23 +316,23 @@ Copies a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | -------------------------- | ---- | ---------------------------------------- | | ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or FD of the file to copy. | | src | string\|number | Yes | Path or FD of the file to copy. |
| dest | string\|number | Yes | Destination path of the file or FD of the file created. | | dest | string\|number | Yes | Destination path of the file or FD of the file created. |
| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file of the same name.| | mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file of the same name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let srcPath = pathDir + "srcDir/test.txt"; let srcPath = pathDir + "/srcDir/test.txt";
let dstPath = pathDir + "dstDir/test.txt"; let dstPath = pathDir + "/dstDir/test.txt";
fs.copyFile(srcPath, dstPath).then(() => { fs.copyFile(srcPath, dstPath).then(() => {
console.info("copy file succeed"); console.info("copy file succeed");
}).catch((err) => { }).catch((err) => {
...@@ -350,18 +350,18 @@ Copies a file. This API uses an asynchronous callback to return the result. ...@@ -350,18 +350,18 @@ Copies a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ---------------------------------------- | | -------- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or FD of the file to copy. | | src | string\|number | Yes | Path or FD of the file to copy. |
| dest | string\|number | Yes | Destination path of the file or FD of the file created. | | dest | string\|number | Yes | Destination path of the file or FD of the file created. |
| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.| | mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is copied asynchronously. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is copied asynchronously. |
**Example** **Example**
```js ```js
let srcPath = pathDir + "srcDir/test.txt"; let srcPath = pathDir + "/srcDir/test.txt";
let dstPath = pathDir + "dstDir/test.txt"; let dstPath = pathDir + "/dstDir/test.txt";
fs.copyFile(srcPath, dstPath, (err) => { fs.copyFile(srcPath, dstPath, (err) => {
if (err) { if (err) {
console.info("copy file failed with error message: " + err.message + ", error code: " + err.code); console.info("copy file failed with error message: " + err.message + ", error code: " + err.code);
...@@ -382,17 +382,17 @@ Synchronously copies a file. ...@@ -382,17 +382,17 @@ Synchronously copies a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | -------------------------- | ---- | ---------------------------------------- | | ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or FD of the file to copy. | | src | string\|number | Yes | Path or FD of the file to copy. |
| dest | string\|number | Yes | Destination path of the file or FD of the file created. | | dest | string\|number | Yes | Destination path of the file or FD of the file created. |
| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.| | mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.|
**Example** **Example**
```js ```js
let srcPath = pathDir + "srcDir/test.txt"; let srcPath = pathDir + "/srcDir/test.txt";
let dstPath = pathDir + "dstDir/test.txt"; let dstPath = pathDir + "/dstDir/test.txt";
fs.copyFileSync(srcPath, dstPath); fs.copyFileSync(srcPath, dstPath);
``` ```
...@@ -413,14 +413,14 @@ Creates a directory. This API uses a promise to return the result. ...@@ -413,14 +413,14 @@ Creates a directory. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let dirPath = pathDir + '/testDir'; let dirPath = pathDir + "/testDir";
fs.mkdir(dirPath).then(() => { fs.mkdir(dirPath).then(() => {
console.info("Directory created"); console.info("Directory created");
}).catch((err) => { }).catch((err) => {
...@@ -447,7 +447,7 @@ Creates a directory. This API uses an asynchronous callback to return the result ...@@ -447,7 +447,7 @@ Creates a directory. This API uses an asynchronous callback to return the result
**Example** **Example**
```js ```js
let dirPath = pathDir + '/testDir'; let dirPath = pathDir + "/testDir";
fs.mkdir(dirPath, (err) => { fs.mkdir(dirPath, (err) => {
if (err) { if (err) {
console.info("mkdir failed with error message: " + err.message + ", error code: " + err.code); console.info("mkdir failed with error message: " + err.message + ", error code: " + err.code);
...@@ -475,7 +475,7 @@ Synchronously creates a directory. ...@@ -475,7 +475,7 @@ Synchronously creates a directory.
**Example** **Example**
```js ```js
let dirPath = pathDir + '/testDir'; let dirPath = pathDir + "/testDir";
fs.mkdirSync(dirPath); fs.mkdirSync(dirPath);
``` ```
...@@ -497,9 +497,9 @@ Opens a file. This API uses a promise to return the result. File uniform resourc ...@@ -497,9 +497,9 @@ Opens a file. This API uses a promise to return the result. File uniform resourc
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ----------- | | --------------------- | ----------- |
| Promise&lt;[File](#file)&gt; | Promise used to return the file object.| | Promise&lt;[File](#file)&gt; | Promise used to return the file object.|
**Example** **Example**
...@@ -558,9 +558,9 @@ Synchronously opens a file. File URIs are supported. ...@@ -558,9 +558,9 @@ Synchronously opens a file. File URIs are supported.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ----------- | | ------ | ----------- |
| [File](#file) | File object opened.| | [File](#file) | File object opened.|
**Example** **Example**
...@@ -589,9 +589,9 @@ Reads data from a file. This API uses a promise to return the result. ...@@ -589,9 +589,9 @@ Reads data from a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;number&gt; | Promise used to return the data read.| | Promise&lt;number&gt; | Promise used to return the data read.|
**Example** **Example**
...@@ -601,7 +601,7 @@ Reads data from a file. This API uses a promise to return the result. ...@@ -601,7 +601,7 @@ Reads data from a file. This API uses a promise to return the result.
let buf = new ArrayBuffer(4096); let buf = new ArrayBuffer(4096);
fs.read(file.fd, buf).then((readLen) => { fs.read(file.fd, buf).then((readLen) => {
console.info("Read file data successfully"); console.info("Read file data successfully");
console.info(String.fromCharCode.apply(null, new Uint8Array(readLen))); console.info(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen))));
fs.closeSync(file); fs.closeSync(file);
}).catch((err) => { }).catch((err) => {
console.info("read file data failed with error message: " + err.message + ", error code: " + err.code); console.info("read file data failed with error message: " + err.message + ", error code: " + err.code);
...@@ -618,12 +618,12 @@ Reads data from a file. This API uses an asynchronous callback to return the res ...@@ -618,12 +618,12 @@ Reads data from a file. This API uses an asynchronous callback to return the res
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| 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 of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is read asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is read asynchronously. |
**Example** **Example**
...@@ -636,7 +636,7 @@ Reads data from a file. This API uses an asynchronous callback to return the res ...@@ -636,7 +636,7 @@ Reads data from a file. This API uses an asynchronous callback to return the res
console.info("mkdir failed with error message: " + err.message + ", error code: " + err.code); console.info("mkdir failed with error message: " + err.message + ", error code: " + err.code);
} else { } else {
console.info("Read file data successfully"); console.info("Read file data successfully");
console.info(String.fromCharCode.apply(null, new Uint8Array(readLen))); console.info(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen))));
fs.closeSync(file); fs.closeSync(file);
} }
}); });
...@@ -653,17 +653,17 @@ Synchronously reads data from a file. ...@@ -653,17 +653,17 @@ Synchronously reads data from a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| 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 of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data read.| | number | Length of the data read.|
**Example** **Example**
...@@ -692,14 +692,14 @@ Deletes a directory. This API uses a promise to return the result. ...@@ -692,14 +692,14 @@ Deletes a directory. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let dirPath = pathDir + '/testDir'; let dirPath = pathDir + "/testDir";
fs.rmdir(dirPath).then(() => { fs.rmdir(dirPath).then(() => {
console.info("Directory deleted"); console.info("Directory deleted");
}).catch((err) => { }).catch((err) => {
...@@ -726,7 +726,7 @@ Deletes a directory. This API uses an asynchronous callback to return the result ...@@ -726,7 +726,7 @@ Deletes a directory. This API uses an asynchronous callback to return the result
**Example** **Example**
```js ```js
let dirPath = pathDir + '/testDir'; let dirPath = pathDir + "/testDir";
fs.rmdir(dirPath, (err) => { fs.rmdir(dirPath, (err) => {
if (err) { if (err) {
console.info("rmdir failed with error message: " + err.message + ", error code: " + err.code); console.info("rmdir failed with error message: " + err.message + ", error code: " + err.code);
...@@ -754,7 +754,7 @@ Synchronously deletes a directory. ...@@ -754,7 +754,7 @@ Synchronously deletes a directory.
**Example** **Example**
```js ```js
let dirPath = pathDir + '/testDir'; let dirPath = pathDir + "/testDir";
fs.rmdirSync(dirPath); fs.rmdirSync(dirPath);
``` ```
...@@ -775,9 +775,9 @@ Deletes a file. This API uses a promise to return the result. ...@@ -775,9 +775,9 @@ Deletes a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -852,17 +852,17 @@ Writes data into a file. This API uses a promise to return the result. ...@@ -852,17 +852,17 @@ Writes data into a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| 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): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------- | | --------------------- | -------- |
| Promise&lt;number&gt; | Promise used to return the length of the data written.| | Promise&lt;number&gt; | Promise used to return the length of the data written.|
**Example** **Example**
...@@ -888,12 +888,12 @@ Writes data into a file. This API uses an asynchronous callback to return the re ...@@ -888,12 +888,12 @@ Writes data into a file. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ---------------------------------------- | | -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| 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): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. |
**Example** **Example**
...@@ -921,17 +921,17 @@ Synchronously writes data into a file. ...@@ -921,17 +921,17 @@ Synchronously writes data into a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| 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): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data written in the file.| | number | Length of the data written in the file.|
**Example** **Example**
...@@ -960,9 +960,9 @@ Truncates a file. This API uses a promise to return the result. ...@@ -960,9 +960,9 @@ Truncates a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -1049,9 +1049,9 @@ Reads the text content of a file. This API uses a promise to return the result. ...@@ -1049,9 +1049,9 @@ Reads the text content of a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string&gt; | Promise used to return the content read.| | Promise&lt;string&gt; | Promise used to return the content read.|
**Example** **Example**
...@@ -1112,9 +1112,9 @@ Synchronously reads the text of a file. ...@@ -1112,9 +1112,9 @@ Synchronously reads the text of a file.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------------------- | | ------ | -------------------- |
| string | Promise used to return the content of the file read.| | string | Promise used to return the content of the file read.|
**Example** **Example**
...@@ -1140,9 +1140,9 @@ Obtains information about a symbolic link. This API uses a promise to return the ...@@ -1140,9 +1140,9 @@ Obtains information about a symbolic link. This API uses a promise to return the
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise used to return the symbolic link information obtained. For details, see **stat**.| | Promise&lt;[Stat](#stat)&gt; | Promise used to return the symbolic link information obtained. For details, see **stat**.|
**Example** **Example**
...@@ -1200,9 +1200,9 @@ Obtains information about a symbolic link synchronously. ...@@ -1200,9 +1200,9 @@ Obtains information about a symbolic link synchronously.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------- | ---------- | | ------------- | ---------- |
| [Stat](#stat) | File information obtained.| | [Stat](#stat) | File information obtained.|
**Example** **Example**
...@@ -1228,15 +1228,15 @@ Renames a file or directory. This API uses a promise to return the result. ...@@ -1228,15 +1228,15 @@ Renames a file or directory. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let srcFile = pathDir + "/test.txt"; let srcFile = pathDir + "/test.txt";
let dstFile = pathDir + '/new.txt'; let dstFile = pathDir + "/new.txt";
fs.rename(srcFile, dstFile).then(() => { fs.rename(srcFile, dstFile).then(() => {
console.info("File renamed"); console.info("File renamed");
}).catch((err) => { }).catch((err) => {
...@@ -1264,7 +1264,7 @@ Renames a file or directory. This API uses an asynchronous callback to return th ...@@ -1264,7 +1264,7 @@ Renames a file or directory. This API uses an asynchronous callback to return th
```js ```js
let srcFile = pathDir + "/test.txt"; let srcFile = pathDir + "/test.txt";
let dstFile = pathDir + '/new.txt'; let dstFile = pathDir + "/new.txt";
fs.rename(srcFile, dstFile, (err) => { fs.rename(srcFile, dstFile, (err) => {
if (err) { if (err) {
console.info("rename failed with error message: " + err.message + ", error code: " + err.code); console.info("rename failed with error message: " + err.message + ", error code: " + err.code);
...@@ -1293,7 +1293,7 @@ Renames a file or directory synchronously. ...@@ -1293,7 +1293,7 @@ Renames a file or directory synchronously.
```js ```js
let srcFile = pathDir + "/test.txt"; let srcFile = pathDir + "/test.txt";
let dstFile = pathDir + '/new.txt'; let dstFile = pathDir + "/new.txt";
fs.renameSync(srcFile, dstFile); fs.renameSync(srcFile, dstFile);
``` ```
...@@ -1308,15 +1308,15 @@ Flushes data of a file to disk. This API uses a promise to return the result. ...@@ -1308,15 +1308,15 @@ Flushes data of a file to disk. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -1341,10 +1341,10 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return ...@@ -1341,10 +1341,10 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | --------------- | | -------- | ------------------------- | ---- | --------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| Callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| | Callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.|
**Example** **Example**
...@@ -1372,9 +1372,9 @@ Flushes data of a file to disk synchronously. ...@@ -1372,9 +1372,9 @@ Flushes data of a file to disk synchronously.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Example** **Example**
...@@ -1396,15 +1396,15 @@ Flushes data of a file to disk. This API uses a promise to return the result. ** ...@@ -1396,15 +1396,15 @@ Flushes data of a file to disk. This API uses a promise to return the result. **
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -1430,10 +1430,10 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return ...@@ -1430,10 +1430,10 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ----------------- | | -------- | ------------------------------- | ---- | ----------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.|
**Example** **Example**
...@@ -1460,9 +1460,9 @@ Synchronizes data in a file synchronously. ...@@ -1460,9 +1460,9 @@ Synchronizes data in a file synchronously.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Example** **Example**
...@@ -1491,15 +1491,15 @@ Creates a symbolic link based on a file path. This API uses a promise to return ...@@ -1491,15 +1491,15 @@ Creates a symbolic link based on a file path. This API uses a promise to return
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let srcFile = pathDir + "/test.txt"; let srcFile = pathDir + "/test.txt";
let dstFile = pathDir + '/test'; let dstFile = pathDir + "/test";
fs.symlink(srcFile, dstFile).then(() => { fs.symlink(srcFile, dstFile).then(() => {
console.info("Symbolic link created"); console.info("Symbolic link created");
}).catch((err) => { }).catch((err) => {
...@@ -1527,7 +1527,7 @@ Creates a symbolic link based on a file path. This API uses an asynchronous call ...@@ -1527,7 +1527,7 @@ Creates a symbolic link based on a file path. This API uses an asynchronous call
```js ```js
let srcFile = pathDir + "/test.txt"; let srcFile = pathDir + "/test.txt";
let dstFile = pathDir + '/test'; let dstFile = pathDir + "/test";
fs.symlink(srcFile, dstFile, (err) => { fs.symlink(srcFile, dstFile, (err) => {
if (err) { if (err) {
console.info("symlink failed with error message: " + err.message + ", error code: " + err.code); console.info("symlink failed with error message: " + err.message + ", error code: " + err.code);
...@@ -1556,7 +1556,7 @@ Synchronously creates a symbolic link based on a file path. ...@@ -1556,7 +1556,7 @@ Synchronously creates a symbolic link based on a file path.
```js ```js
let srcFile = pathDir + "/test.txt"; let srcFile = pathDir + "/test.txt";
let dstFile = pathDir + '/test'; let dstFile = pathDir + "/test";
fs.symlinkSync(srcFile, dstFile); fs.symlinkSync(srcFile, dstFile);
``` ```
...@@ -1573,24 +1573,24 @@ Lists all files in a directory. This API uses a promise to return the result.<br ...@@ -1573,24 +1573,24 @@ Lists all files in a directory. This API uses a promise to return the result.<br
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| path | string | Yes | Path of the directory in the application sandbox.| | path | string | Yes | Path of the directory in the application sandbox.|
| options | Object | No | File filtering options.| | options | Object | No | File filtering options.|
**options parameters** **options parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| | recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.|
| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| | listNum | number | No | Number of file names to list. The default value **0** means to list all files.|
| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string[]&gt; | Promise used to return the files names listed.| | Promise&lt;string[]&gt; | Promise used to return the files names listed.|
**Example** **Example**
...@@ -1626,19 +1626,19 @@ Lists all files in a directory. This API uses an asynchronous callback to return ...@@ -1626,19 +1626,19 @@ Lists all files in a directory. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| path | string | Yes | Path of the directory in the application sandbox.| | path | string | Yes | Path of the directory in the application sandbox.|
| options | Object | No | File filtering options.| | options | Object | No | File filtering options.|
| callback | AsyncCallback&lt;string[]&gt; | Yes | Callback invoked to return the file names listed. | | callback | AsyncCallback&lt;string[]&gt; | Yes | Callback invoked to return the file names listed. |
**options parameters** **options parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| | recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.|
| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| | listNum | number | No | Number of file names to list. The default value **0** means to list all files.|
| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.|
**Example** **Example**
...@@ -1677,24 +1677,24 @@ Lists all files in a directory synchronously. This API supports recursive listin ...@@ -1677,24 +1677,24 @@ Lists all files in a directory synchronously. This API supports recursive listin
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| path | string | Yes | Path of the directory in the application sandbox.| | path | string | Yes | Path of the directory in the application sandbox.|
| options | Object | No | File filtering options.| | options | Object | No | File filtering options.|
**options parameters** **options parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| | recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.|
| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| | listNum | number | No | Number of file names to list. The default value **0** means to list all files.|
| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| string[] | File names listed.| | string[] | File names listed.|
**Example** **Example**
...@@ -1717,7 +1717,7 @@ Lists all files in a directory synchronously. This API supports recursive listin ...@@ -1717,7 +1717,7 @@ Lists all files in a directory synchronously. This API supports recursive listin
``` ```
## fs.moveFile ## fs.moveFile
moveFile(src: string, dest: string, mode?: number): Promise<void>; moveFile(src: string, dest: string, mode?: number): Promise\<void>;
Moves a file. This API uses a promise to return the result. Moves a file. This API uses a promise to return the result.
...@@ -1725,17 +1725,17 @@ Moves a file. This API uses a promise to return the result. ...@@ -1725,17 +1725,17 @@ Moves a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Path of the file to move in the application sandbox.| | src | string | Yes | Path of the file to move in the application sandbox.|
| dest | string | Yes | Destination path of the file in the application sandbox.| | dest | string | Yes | Destination path of the file in the application sandbox.|
| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| | mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.|
**Example** **Example**
```js ```js
let srcPath = pathDir + '/source.txt'; let srcPath = pathDir + "/source.txt";
let destPath = pathDir + '/dest.txt'; let destPath = pathDir + "/dest.txt";
fs.moveFile(srcPath, destPath, 0).then(() => { fs.moveFile(srcPath, destPath, 0).then(() => {
console.info("move file succeed"); console.info("move file succeed");
}).catch((err) => { }).catch((err) => {
...@@ -1745,7 +1745,7 @@ Moves a file. This API uses a promise to return the result. ...@@ -1745,7 +1745,7 @@ Moves a file. This API uses a promise to return the result.
## fs.moveFile ## fs.moveFile
moveFile(src: string, dest: string, mode?: number, callback: AsyncCallback<void>): void; moveFile(src: string, dest: string, mode?: number, callback: AsyncCallback\<void>): void;
Moves a file. This API uses an asynchronous callback to return the result. Moves a file. This API uses an asynchronous callback to return the result.
...@@ -1753,18 +1753,18 @@ Moves a file. This API uses an asynchronous callback to return the result. ...@@ -1753,18 +1753,18 @@ Moves a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Path of the file to move in the application sandbox.| | src | string | Yes | Path of the file to move in the application sandbox.|
| dest | string | Yes | Destination path of the file in the application sandbox.| | dest | string | Yes | Destination path of the file in the application sandbox.|
| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| | mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is moved. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is moved. |
**Example** **Example**
```js ```js
let srcPath = pathDir + '/source.txt'; let srcPath = pathDir + "/source.txt";
let destPath = pathDir + '/dest.txt'; let destPath = pathDir + "/dest.txt";
fs.moveFile(srcPath, destPath, 0, (err) => { fs.moveFile(srcPath, destPath, 0, (err) => {
if (err) { if (err) {
console.info("move file failed with error message: " + err.message + ", error code: " + err.code); console.info("move file failed with error message: " + err.message + ", error code: " + err.code);
...@@ -1784,17 +1784,17 @@ Moves a file synchronously. ...@@ -1784,17 +1784,17 @@ Moves a file synchronously.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Path of the file to move in the application sandbox.| | src | string | Yes | Path of the source file in the application sandbox.|
| dest | string | Yes | Destination path of the file in the application sandbox.| | dest | string | Yes | Destination path of the file in the application sandbox.|
| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| | mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.|
**Example** **Example**
```js ```js
let srcPath = pathDir + '/source.txt'; let srcPath = pathDir + "/source.txt";
let destPath = pathDir + '/dest.txt'; let destPath = pathDir + "/dest.txt";
fs.moveFileSync(srcPath, destPath, 0); fs.moveFileSync(srcPath, destPath, 0);
console.info("move file succeed"); console.info("move file succeed");
``` ```
...@@ -1809,15 +1809,15 @@ Creates a temporary directory. This API uses a promise to return the result. ...@@ -1809,15 +1809,15 @@ Creates a temporary directory. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string&gt; | Promise used to return the unique directory generated.| | Promise&lt;string&gt; | Promise used to return the unique directory generated.|
**Example** **Example**
...@@ -1840,10 +1840,10 @@ Creates a temporary directory. This API uses an asynchronous callback to return ...@@ -1840,10 +1840,10 @@ Creates a temporary directory. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | --------------------------- | | -------- | --------------------------- | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked when a temporary directory is created asynchronously. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked when a temporary directory is created asynchronously. |
**Example** **Example**
...@@ -1867,15 +1867,15 @@ Synchronously creates a temporary directory. ...@@ -1867,15 +1867,15 @@ Synchronously creates a temporary directory.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ---------- | | ------ | ---------- |
| string | Unique path generated.| | string | Unique path generated.|
**Example** **Example**
...@@ -1900,9 +1900,9 @@ Opens a file stream based on the file path. This API uses a promise to return th ...@@ -1900,9 +1900,9 @@ Opens a file stream based on the file path. This API uses a promise to return th
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------- | --------- | | --------------------------------- | --------- |
| Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.| | Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -1962,9 +1962,9 @@ Synchronously opens a stream based on the file path. ...@@ -1962,9 +1962,9 @@ Synchronously opens a stream based on the file path.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | --------- | | ------------------ | --------- |
| [Stream](#stream) | Stream opened.| | [Stream](#stream) | Stream opened.|
**Example** **Example**
...@@ -1984,16 +1984,16 @@ Opens a file stream based on the file descriptor. This API uses a promise to ret ...@@ -1984,16 +1984,16 @@ Opens a file stream based on the file descriptor. This API uses a promise to ret
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------- | --------- | | --------------------------------- | --------- |
| Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.| | Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -2019,11 +2019,11 @@ Opens a file stream based on the file descriptor. This API uses an asynchronous ...@@ -2019,11 +2019,11 @@ Opens a file stream based on the file descriptor. This API uses an asynchronous
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
| callback | AsyncCallback&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is open asynchronously. | | callback | AsyncCallback&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is open asynchronously. |
**Example** **Example**
...@@ -2050,16 +2050,16 @@ Synchronously opens a stream based on the file descriptor. ...@@ -2050,16 +2050,16 @@ Synchronously opens a stream based on the file descriptor.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | --------- | | ------------------ | --------- |
| [Stream](#stream) | Stream opened.| | [Stream](#stream) | Stream opened.|
**Example** **Example**
...@@ -2100,9 +2100,9 @@ Checks whether this file is a block special file. A block special file supports ...@@ -2100,9 +2100,9 @@ Checks whether this file is a block special file. A block special file supports
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ---------------- | | ------- | ---------------- |
| boolean | Whether the file is a block special file.| | boolean | Whether the file is a block special file.|
**Example** **Example**
...@@ -2121,9 +2121,9 @@ Checks whether this file is a character special file. A character special file s ...@@ -2121,9 +2121,9 @@ Checks whether this file is a character special file. A character special file s
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------- | | ------- | ----------------- |
| boolean | Whether the file is a character special file.| | boolean | Whether the file is a character special file.|
**Example** **Example**
...@@ -2143,9 +2143,9 @@ Checks whether this file is a directory. ...@@ -2143,9 +2143,9 @@ Checks whether this file is a directory.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------- | | ------- | ------------- |
| boolean | Whether the file is a directory.| | boolean | Whether the file is a directory.|
**Example** **Example**
...@@ -2165,9 +2165,9 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int ...@@ -2165,9 +2165,9 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------- | | ------- | --------------------- |
| boolean | Whether the file is a FIFO.| | boolean | Whether the file is a FIFO.|
**Example** **Example**
...@@ -2187,9 +2187,9 @@ Checks whether this file is a regular file. ...@@ -2187,9 +2187,9 @@ Checks whether this file is a regular file.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the file is a regular file.| | boolean | Whether the file is a regular file.|
**Example** **Example**
...@@ -2209,9 +2209,9 @@ Checks whether this file is a socket. ...@@ -2209,9 +2209,9 @@ Checks whether this file is a socket.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | -------------- | | ------- | -------------- |
| boolean | Whether the file is a socket.| | boolean | Whether the file is a socket.|
**Example** **Example**
...@@ -2231,9 +2231,9 @@ Checks whether this file is a symbolic link. ...@@ -2231,9 +2231,9 @@ Checks whether this file is a symbolic link.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the file is a symbolic link.| | boolean | Whether the file is a symbolic link.|
**Example** **Example**
...@@ -2257,9 +2257,9 @@ Closes the stream. This API uses a promise to return the result. ...@@ -2257,9 +2257,9 @@ Closes the stream. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------- | | ------------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the stream close result.| | Promise&lt;void&gt; | Promise used to return the stream close result.|
**Example** **Example**
...@@ -2284,9 +2284,9 @@ Closes the stream. This API uses an asynchronous callback to return the result. ...@@ -2284,9 +2284,9 @@ Closes the stream. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------- | | -------- | ------------------------- | ---- | ------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is closed asynchronously.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is closed asynchronously.|
**Example** **Example**
...@@ -2328,9 +2328,9 @@ Flushes the stream. This API uses a promise to return the result. ...@@ -2328,9 +2328,9 @@ Flushes the stream. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------- | | ------------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the stream flushing result.| | Promise&lt;void&gt; | Promise used to return the stream flushing result.|
**Example** **Example**
...@@ -2355,9 +2355,9 @@ Flushes the stream. This API uses an asynchronous callback to return the result. ...@@ -2355,9 +2355,9 @@ Flushes the stream. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | -------------- | | -------- | ------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is asynchronously flushed.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is asynchronously flushed.|
**Example** **Example**
...@@ -2399,16 +2399,16 @@ Writes data into the stream. This API uses a promise to return the result. ...@@ -2399,16 +2399,16 @@ Writes data into the stream. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| 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>- **length** (number): length of the data to write. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------- | | --------------------- | -------- |
| Promise&lt;number&gt; | Promise used to return the length of the data written.| | Promise&lt;number&gt; | Promise used to return the length of the data written.|
**Example** **Example**
...@@ -2433,11 +2433,11 @@ Writes data into the stream. This API uses an asynchronous callback to return th ...@@ -2433,11 +2433,11 @@ Writes data into the stream. This API uses an asynchronous callback to return th
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| 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>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. |
**Example** **Example**
...@@ -2465,16 +2465,16 @@ Synchronously writes data into the stream. ...@@ -2465,16 +2465,16 @@ Synchronously writes data into the stream.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| 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>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data written in the file.| | number | Length of the data written in the file.|
**Example** **Example**
...@@ -2494,16 +2494,16 @@ Reads data from the stream. This API uses a promise to return the result. ...@@ -2494,16 +2494,16 @@ Reads data from the stream. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| 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>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (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>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. By default, data is read from the current position.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;number&gt; | Promise used to return the data read.| | Promise&lt;number&gt; | Promise used to return the data read.|
**Example** **Example**
...@@ -2513,7 +2513,7 @@ Reads data from the stream. This API uses a promise to return the result. ...@@ -2513,7 +2513,7 @@ Reads data from the stream. This API uses a promise to return the result.
let buf = new ArrayBuffer(4096); let buf = new ArrayBuffer(4096);
ss.read(buf, {offset: 5, length: 5}).then((readLen) => { ss.read(buf, {offset: 5, length: 5}).then((readLen) => {
console.info("Read data successfully"); console.info("Read data successfully");
console.log(String.fromCharCode.apply(null, new Uint8Array(buf))); console.log(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen))));
}).catch((err) => { }).catch((err) => {
console.info("read data failed with error message: " + err.message + ", error code: " + err.code); console.info("read data failed with error message: " + err.message + ", error code: " + err.code);
}); });
...@@ -2530,11 +2530,11 @@ Reads data from the stream. This API uses an asynchronous callback to return the ...@@ -2530,11 +2530,11 @@ Reads data from the stream. This API uses an asynchronous callback to return the
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| 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>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when data is read asynchronously from the stream. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when data is read asynchronously from the stream. |
**Example** **Example**
...@@ -2547,7 +2547,7 @@ Reads data from the stream. This API uses an asynchronous callback to return the ...@@ -2547,7 +2547,7 @@ Reads data from the stream. This API uses an asynchronous callback to return the
console.info("read stream failed with error message: " + err.message + ", error code: " + err.code); console.info("read stream failed with error message: " + err.message + ", error code: " + err.code);
} else { } else {
console.info("Read data successfully"); console.info("Read data successfully");
console.log(String.fromCharCode.apply(null, new Uint8Array(buf))); console.log(String.fromCharCode.apply(null, new Uint8Array(buf.slice(0, readLen))));
} }
}); });
``` ```
...@@ -2562,16 +2562,16 @@ Synchronously reads data from the stream. ...@@ -2562,16 +2562,16 @@ Synchronously reads data from the stream.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| 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>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br> | | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. By default, data is read from the current position.<br> |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data read.| | number | Length of the data read.|
**Example** **Example**
...@@ -2595,7 +2595,7 @@ Represents a **File** object opened by **open()**. ...@@ -2595,7 +2595,7 @@ Represents a **File** object opened by **open()**.
### lock ### lock
lock(exclusive?: boolean): Promise<void>; lock(exclusive?: boolean): Promise\<void>;
Applies an exclusive lock or a shared lock on this file in blocking mode. This API uses a promise to return the result. Applies an exclusive lock or a shared lock on this file in blocking mode. This API uses a promise to return the result.
...@@ -2603,15 +2603,15 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A ...@@ -2603,15 +2603,15 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -2626,7 +2626,7 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A ...@@ -2626,7 +2626,7 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A
### lock ### lock
lock(exclusive?: boolean, callback: AsyncCallback<void>): void; lock(exclusive?: boolean, callback: AsyncCallback\<void>): void;
Applies an exclusive lock or a shared lock on this file in blocking mode. This API uses a promise to return the result. Applies an exclusive lock or a shared lock on this file in blocking mode. This API uses a promise to return the result.
...@@ -2634,10 +2634,10 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A ...@@ -2634,10 +2634,10 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is locked. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is locked. |
**Example** **Example**
...@@ -2662,9 +2662,9 @@ Applies an exclusive lock or a shared lock on this file in non-blocking mode. ...@@ -2662,9 +2662,9 @@ Applies an exclusive lock or a shared lock on this file in non-blocking mode.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. |
**Example** **Example**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册