@@ -619,7 +621,7 @@ Requests permissions from the user in a dialog box. This API uses a promise to
...
@@ -619,7 +621,7 @@ Requests permissions from the user in a dialog box. This API uses a promise to
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| context | Context | Yes| Ability context of the application that requests the permissions. |
| context | Context | Yes| Ability context of the application that requests the permissions. |
| permissionList | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
| permissionList | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
@@ -8,7 +8,7 @@ The **relationalStore** module provides the following functions:
...
@@ -8,7 +8,7 @@ The **relationalStore** module provides the following functions:
-[RdbStore](#rdbstore): provides APIs for managing data in an RDB store.
-[RdbStore](#rdbstore): provides APIs for managing data in an RDB store.
-[Resultset](#resultset): provides APIs for accessing the result set obtained from the RDB store.
-[Resultset](#resultset): provides APIs for accessing the result set obtained from the RDB store.
> **NOTE**<br/>
> **NOTE**
>
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...
@@ -30,7 +30,7 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul
...
@@ -30,7 +30,7 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul
| 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-application-uiAbilityContext.md).|
| config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. |
| config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. |
| callback | AsyncCallback<[RdbStore](#rdbstore)> | Yes | Callback invoked to return the RDB store obtained. |
| callback | AsyncCallback<[RdbStore](#rdbstore)> | Yes | Callback invoked to return the RDB store obtained. |
...
@@ -108,7 +108,7 @@ Obtains an RDB store. This API uses a promise to return the result. You can set
...
@@ -108,7 +108,7 @@ Obtains an RDB store. This API uses a promise to return the result. You can set
| 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-application-uiAbilityContext.md).|
| config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. |
| config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. |
**Return value**
**Return value**
...
@@ -188,7 +188,7 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul
...
@@ -188,7 +188,7 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul
| 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-application-uiAbilityContext.md).|
| name | string | Yes | Name of the RDB store to delete. |
| name | string | Yes | Name of the RDB store to delete. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
...
@@ -249,7 +249,7 @@ Deletes an RDB store. This API uses a promise to return the result.
...
@@ -249,7 +249,7 @@ Deletes an RDB store. This API uses a promise to return the result.
| 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-application-uiAbilityContext.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**
...
@@ -2612,9 +2612,9 @@ Synchronizes data between devices. This API uses a promise to return the result.
...
@@ -2612,9 +2612,9 @@ Synchronizes data between devices. This API uses a promise to return the result.
Before using the APIs provided by this module to perform operations on files or directories, obtain the path of the file or directory in the application sandbox as follows:
Before using the APIs provided by this module to perform operations on files or folders, obtain the path of the file or directory in the application sandbox as follows:
**Stage Model**
**Stage Model**
...
@@ -60,14 +60,14 @@ Obtains detailed file information. This API uses a promise to return the result.
...
@@ -60,14 +60,14 @@ Obtains detailed file information. This API uses a promise to return the result.
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| ---------------------------- | ---------- |
| ---------------------------- | ---------- |
| Promise<[Stat](#stat)> | Promise used to return the file information obtained.|
| Promise<[Stat](#stat)> | Promise used to return the file information obtained.|
**Example**
**Example**
```js
```js
letfilePath=pathDir+"test.txt";
letfilePath=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)=>{
...
@@ -119,9 +119,9 @@ Obtains detailed file information synchronously.
...
@@ -119,9 +119,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**
...
@@ -146,9 +146,9 @@ Checks whether a file exists. This API uses a promise to return the result.
...
@@ -146,9 +146,9 @@ Checks whether a file exists. This API uses a promise to return the result.
| 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.|
| 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<void> | Yes | Callback invoked when the file is copied asynchronously. |
| callback | AsyncCallback<void> | Yes | Callback invoked when the file is copied asynchronously. |
**Example**
**Example**
```js
```js
letsrcPath=pathDir+"srcDir/test.txt";
letsrcPath=pathDir+"/srcDir/test.txt";
letdstPath=pathDir+"dstDir/test.txt";
letdstPath=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);
...
@@ -383,17 +383,17 @@ Synchronously copies a file.
...
@@ -383,17 +383,17 @@ Synchronously copies a file.
| 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
letsrcPath=pathDir+"srcDir/test.txt";
letsrcPath=pathDir+"/srcDir/test.txt";
letdstPath=pathDir+"dstDir/test.txt";
letdstPath=pathDir+"/dstDir/test.txt";
fs.copyFileSync(srcPath,dstPath);
fs.copyFileSync(srcPath,dstPath);
```
```
...
@@ -414,14 +414,14 @@ Creates a directory. This API uses a promise to return the result.
...
@@ -414,14 +414,14 @@ Creates a directory. This API uses a promise to return the result.
| 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<number> | Yes | Callback invoked when the data is read asynchronously. |
| callback | AsyncCallback<number> | Yes | Callback invoked when the data is read asynchronously. |
**Example**
**Example**
...
@@ -637,7 +637,7 @@ Reads data from a file. This API uses an asynchronous callback to return the res
...
@@ -637,7 +637,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);
| 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**
...
@@ -693,14 +693,14 @@ Deletes a directory. This API uses a promise to return the result.
...
@@ -693,14 +693,14 @@ Deletes a directory. This API uses a promise to return the result.
| 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<number> | Promise used to return the length of the data written.|
| Promise<number> | Promise used to return the length of the data written.|
**Example**
**Example**
...
@@ -889,12 +889,12 @@ Writes data into a file. This API uses an asynchronous callback to return the re
...
@@ -889,12 +889,12 @@ Writes data into a file. This API uses an asynchronous callback to return the re
| 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<number> | Yes | Callback invoked when the data is written asynchronously. |
| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. |
**Example**
**Example**
...
@@ -922,17 +922,17 @@ Synchronously writes data into a file.
...
@@ -922,17 +922,17 @@ Synchronously writes data into a 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**
...
@@ -961,9 +961,9 @@ Truncates a file. This API uses a promise to return the result.
...
@@ -961,9 +961,9 @@ Truncates a file. This API uses a promise to return the result.
Lists all files in a directory. This API uses a promise to return the result.<br>This API supports recursive listing of all files (including files in subdirectories) and file filtering.
Lists all files in a folder. This API uses a promise to return the result.<br>This API supports recursive listing of all files (including files in subfolders) and file filtering.
| 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 subfolders 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<string[]> | Promise used to return the files names listed.|
| Promise<string[]> | Promise used to return the files names listed.|
**Example**
**Example**
...
@@ -1608,7 +1608,7 @@ Lists all files in a directory. This API uses a promise to return the result.<br
...
@@ -1608,7 +1608,7 @@ Lists all files in a directory. This API uses a promise to return the result.<br
Lists all files in a directory. This API uses an asynchronous callback to return the result.<br>This API supports recursive listing of all files (including files in subdirectories) and file filtering.
Lists all files in a folder. This API uses an asynchronous callback to return the result.<br>This API supports recursive listing of all files (including files in subfolders) and file filtering.
| 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 subfolders 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**
...
@@ -1659,7 +1659,7 @@ Lists all files in a directory. This API uses an asynchronous callback to return
...
@@ -1659,7 +1659,7 @@ Lists all files in a directory. This API uses an asynchronous callback to return
console.info("list file failed with error message: "+err.message+", error code: "+err.code);
console.info("list file failed with error message: "+err.message+", error code: "+err.code);
| 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 subfolders 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**
...
@@ -1712,13 +1712,13 @@ Lists all files in a directory synchronously. This API supports recursive listin
...
@@ -1712,13 +1712,13 @@ Lists all files in a directory synchronously. This API supports recursive listin
| 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
letsrcPath=pathDir+"/source.txt";
letdestPath=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)=>{
...
@@ -1744,7 +1746,7 @@ Moves a file. This API uses a promise to return the result.
...
@@ -1744,7 +1746,7 @@ Moves a file. This API uses a promise to return the result.
| 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<void> | Yes | Callback invoked when the file is moved. |
| callback | AsyncCallback<void> | Yes | Callback invoked when the file is moved. |
**Example**
**Example**
```js
```js
letsrcPath=pathDir+"/source.txt";
letdestPath=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);
...
@@ -1781,15 +1785,17 @@ Moves a file synchronously.
...
@@ -1781,15 +1785,17 @@ Moves a file synchronously.
| 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
letsrcPath=pathDir+"/source.txt";
letdestPath=pathDir+"/dest.txt";
fs.moveFileSync(srcPath,destPath,0);
fs.moveFileSync(srcPath,destPath,0);
console.info("move file succeed");
console.info("move file succeed");
```
```
...
@@ -1804,15 +1810,15 @@ Creates a temporary directory. This API uses a promise to return the result.
...
@@ -1804,15 +1810,15 @@ Creates a temporary directory. This API uses a promise to return the result.
| 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<[Stream](#stream)> | Promise used to return the result.|
| Promise<[Stream](#stream)> | Promise used to return the result.|
**Example**
**Example**
...
@@ -2014,11 +2020,11 @@ Opens a file stream based on the file descriptor. This API uses an asynchronous
...
@@ -2014,11 +2020,11 @@ Opens a file stream based on the file descriptor. This API uses an asynchronous
| 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<[Stream](#stream)> | Yes | Callback invoked when the stream is open asynchronously. |
| callback | AsyncCallback<[Stream](#stream)> | Yes | Callback invoked when the stream is open asynchronously. |
**Example**
**Example**
...
@@ -2045,16 +2051,16 @@ Synchronously opens a stream based on the file descriptor.
...
@@ -2045,16 +2051,16 @@ Synchronously opens a stream based on the file descriptor.
| 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**
...
@@ -2077,17 +2083,17 @@ Creates a **Watcher** object to observe file or directory changes.
...
@@ -2077,17 +2083,17 @@ Creates a **Watcher** object to observe file or directory changes.
| path | string | Yes | Path of the file or directory to observe in the application sandbox. |
| path | string | Yes | Path of the file or directory to observe in the application sandbox. |
| events | number | Yes | Events to observe. Multiple events can be separated|by a bitwise OR operator (|).<br>- **0x1: IN_ACCESS**: A file is accessed.<br>- **0x2: IN_MODIFY**: The file content is modified.<br>- **0x4: IN_ATTRIB**: Metadata is changed.<br>- **0x8: IN_CLOSE_WRITE**: The file opened for writing is closed.<br>- **0x10: IN_CLOSE_NOWRITE**: The file or directory not opened for writing is closed.<br>- **0x20: IN_OPEN**: A file or directory is opened.<br>- **0x40: IN_MOVED_FROM**: A file in the observed directory is moved.<br>- **0x80: IN_MOVED_TO**: A file is moved to the observed directory.<br>- **0x100: IN_CREATE**: A file or directory is created in the observed directory.<br>- **0x200: IN_DELETE**: A file or directory is deleted form the observed directory.<br>- **0x400: IN_DELETE_SELF**: The observed directory is deleted. After the directory is deleted, the listening stops.<br>- **0x800: IN_MOVE_SELF**: The observed file or directory is moved. After the file or directory is moved, the listening continues.<br>- **0xfff: IN_ALL_EVENTS**: All events.|
| events | number | Yes | Events to observe. Multiple events can be separated by a bitwise OR operator (|).<br>- **0x1: IN_ACCESS**: A file is accessed.<br>- **0x2: IN_MODIFY**: The file content is modified.<br>- **0x4: IN_ATTRIB**: Metadata is changed.<br>- **0x8: IN_CLOSE_WRITE**: The file opened for writing is closed.<br>- **0x10: IN_CLOSE_NOWRITE**: The file or directory not opened for writing is closed.<br>- **0x20: IN_OPEN**: A file or directory is opened.<br>- **0x40: IN_MOVED_FROM**: A file in the observed directory is moved.<br>- **0x80: IN_MOVED_TO**: A file is moved to the observed directory.<br>- **0x100: IN_CREATE**: A file or directory is created in the observed directory.<br>- **0x200: IN_DELETE**: A file or directory is deleted form the observed directory.<br>- **0x400: IN_DELETE_SELF**: The observed directory is deleted. After the directory is deleted, the listening stops.<br>- **0x800: IN_MOVE_SELF**: The observed file or directory is moved. After the file or directory is moved, the listening continues.<br>- **0xfff: IN_ALL_EVENTS**: All events.|
| listener | WatchEventListener | Yes | Callback invoked when an observed event occurs. The callback will be invoked each time an observed event occurs. |
| listener | WatchEventListener | Yes | Callback invoked when an observed event occurs. The callback will be invoked each time an observed event occurs. |
| ino | number | Yes | No | File ID. Different files on the same device have different **ino**s.| |
| ino | number | Yes | No | File ID. Different files on the same device have different **ino**s.| |
| mode | number | Yes | No | File permissions. The meaning of each bit is as follows:<br>- **0o400**: The owner has the read permission on a regular file or a directory entry.<br>- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.<br>- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o040**: The user group has the read permission on a regular file or a directory entry.<br>- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.<br>- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o004**: Other users have the permission to read a regular file or read a directory entry.<br>- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.<br>- **0o001**: Other users have the permission to execute a regular file or search for the specified path in a directory.|
| mode | number | Yes | No | File permissions. The meaning of each bit is as follows:<br>- **0o400**: The owner has the read permission on a regular file or a directory entry.<br>- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.<br>- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o040**: The user group has the read permission on a regular file or a directory entry.<br>- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.<br>- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o004**: Other users have the permission to read a regular file or read a directory entry.<br>- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.<br>- **0o001**: Other users have the permission to execute a regular file or search for the specified path in a directory.|
| uid | number | Yes | No | ID of the file owner.|
| uid | number | Yes | No | ID of the file owner.|
...
@@ -2167,9 +2173,9 @@ Checks whether this file is a block special file. A block special file supports
...
@@ -2167,9 +2173,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**
...
@@ -2188,9 +2194,9 @@ Checks whether this file is a character special file. A character special file s
...
@@ -2188,9 +2194,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**
...
@@ -2210,9 +2216,9 @@ Checks whether this file is a directory.
...
@@ -2210,9 +2216,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**
...
@@ -2232,9 +2238,9 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int
...
@@ -2232,9 +2238,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**
...
@@ -2254,9 +2260,9 @@ Checks whether this file is a regular file.
...
@@ -2254,9 +2260,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**
...
@@ -2276,9 +2282,9 @@ Checks whether this file is a socket.
...
@@ -2276,9 +2282,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**
...
@@ -2298,9 +2304,9 @@ Checks whether this file is a symbolic link.
...
@@ -2298,9 +2304,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**
...
@@ -2324,9 +2330,9 @@ Closes the stream. This API uses a promise to return the result.
...
@@ -2324,9 +2330,9 @@ Closes the stream. This API uses a promise to return the result.
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| ------------------- | ------------- |
| ------------------- | ------------- |
| Promise<void> | Promise used to return the stream close result.|
| Promise<void> | Promise used to return the stream close result.|
**Example**
**Example**
...
@@ -2351,9 +2357,9 @@ Closes the stream. This API uses an asynchronous callback to return the result.
...
@@ -2351,9 +2357,9 @@ Closes the stream. This API uses an asynchronous callback to return the result.
| 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<number> | Promise used to return the length of the data written.|
| Promise<number> | Promise used to return the length of the data written.|
**Example**
**Example**
...
@@ -2500,11 +2506,11 @@ Writes data into the stream. This API uses an asynchronous callback to return th
...
@@ -2500,11 +2506,11 @@ Writes data into the stream. This API uses an asynchronous callback to return th
| 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<number> | Yes | Callback invoked when the data is written asynchronously. |
| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. |
**Example**
**Example**
...
@@ -2532,16 +2538,16 @@ Synchronously writes data into the stream.
...
@@ -2532,16 +2538,16 @@ Synchronously writes data into the stream.
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **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**
...
@@ -2561,16 +2567,16 @@ Reads data from the stream. This API uses a promise to return the result.
...
@@ -2561,16 +2567,16 @@ Reads data from the stream. This API uses a promise to return the result.
| 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<number> | Promise used to return the data read.|
| Promise<number> | Promise used to return the data read.|
**Example**
**Example**
...
@@ -2580,7 +2586,7 @@ Reads data from the stream. This API uses a promise to return the result.
...
@@ -2580,7 +2586,7 @@ Reads data from the stream. This API uses a promise to return the result.
| 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<number> | Yes | Callback invoked when data is read asynchronously from the stream. |
| callback | AsyncCallback<number> | Yes | Callback invoked when data is read asynchronously from the stream. |
**Example**
**Example**
...
@@ -2614,7 +2620,7 @@ Reads data from the stream. This API uses an asynchronous callback to return the
...
@@ -2614,7 +2620,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);
| 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. This parameter is optional. 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**
...
@@ -2662,7 +2668,7 @@ Represents a **File** object opened by **open()**.
...
@@ -2662,7 +2668,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.
...
@@ -2670,15 +2676,15 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A
...
@@ -2670,15 +2676,15 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A
| 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**
...
@@ -2760,13 +2766,13 @@ Unlocks this file synchronously.
...
@@ -2760,13 +2766,13 @@ Unlocks this file synchronously.
## Watcher<sup>10+</sup>
## Watcher<sup>10+</sup>
Provides APIs for file or directory listening. Before using the APIs of **Watcher** , call **createWatcher()** to create a **Watcher** object.
Provides APIs for observing the changes of files or folders. Before using the APIs of **Watcher** , call **createWatcher()** to create a **Watcher** object.
### start<sup>10+</sup>
### start<sup>10+</sup>
start(): void
start(): void
Starts file or directory listening.
Starts listening.
**System API**: This is a system API.
**System API**: This is a system API.
...
@@ -2785,7 +2791,7 @@ Starts file or directory listening.
...
@@ -2785,7 +2791,7 @@ Starts file or directory listening.
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If true is returned, the current account has been verified. If false is returned, the current account has not been verified.|
**Error codes**
**Error codes**
| ID| Error Message |
| ID| Error Message |
| -------- | ------------------- |
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid localId. |
| 12300003 | Account not found. |
**Example**
**Example**
...
@@ -531,9 +527,9 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca
...
@@ -531,9 +527,9 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca
| ID| Error Message |
| ID| Error Message |
| -------- | ------------------- |
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid localId. |
| 12300002 | invalid localId. |
| 12300003 | Account not found. |
| 12300003 | the account indicated by localId dose not exist. |
**Example**
**Example**
...
@@ -555,7 +551,7 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca
...
@@ -555,7 +551,7 @@ Checks whether an OS account has been verified. This API uses an asynchronous ca
| localId | number | No | ID of the target OS account. If this parameter is not specified, this API checks whether the current OS account has been verified.|
| localId | number | Yes | ID of the target OS account. If this parameter is not specified, this API checks whether the current OS account has been verified.|
**Return value**
**Return value**
...
@@ -579,9 +575,9 @@ Checks whether an OS account has been verified. This API uses a promise to retur
...
@@ -579,9 +575,9 @@ Checks whether an OS account has been verified. This API uses a promise to retur
| ID| Error Message |
| ID| Error Message |
| -------- | ------------------- |
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid localId. |
| 12300002 | invalid localId. |
| 12300003 | Account not found. |
| 12300003 | the account indicated by localId dose not exist. |
**Example**
**Example**
...
@@ -991,7 +987,7 @@ Obtains the ID of the OS account to which the current process belongs. This API
...
@@ -991,7 +987,7 @@ Obtains the ID of the OS account to which the current process belongs. This API
| ID| Error Message |
| ID| Error Message |
| -------- | ------------------- |
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
**Example**
**Example**
...
@@ -1028,7 +1024,7 @@ Obtains the ID of the OS account to which the current process belongs. This API
...
@@ -1028,7 +1024,7 @@ Obtains the ID of the OS account to which the current process belongs. This API
| ID| Error Message |
| ID| Error Message |
| -------- | ------------------- |
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
**Example**
**Example**
...
@@ -1064,8 +1060,8 @@ Obtains the OS account ID based on the process UID. This API uses an asynchronou
...
@@ -1064,8 +1060,8 @@ Obtains the OS account ID based on the process UID. This API uses an asynchronou
| ID| Error Message |
| ID| Error Message |
| -------- | --------------- |
| -------- | --------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid uid. |
| 12300002 | invalid uid. |
**Example**: Obtain the ID of the OS account whose process UID is **12345678**.
**Example**: Obtain the ID of the OS account whose process UID is **12345678**.
...
@@ -1108,8 +1104,8 @@ Obtains the OS account ID based on the process UID. This API uses a promise to r
...
@@ -1108,8 +1104,8 @@ Obtains the OS account ID based on the process UID. This API uses a promise to r
| ID| Error Message |
| ID| Error Message |
| -------- | ------------- |
| -------- | ------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid uid. |
| 12300002 | invalid uid. |
**Example**: Obtain the ID of the OS account whose process UID is **12345678**.
**Example**: Obtain the ID of the OS account whose process UID is **12345678**.
...
@@ -1148,8 +1144,8 @@ Obtains the OS account ID based on the domain account information. This API uses
...
@@ -1148,8 +1144,8 @@ Obtains the OS account ID based on the domain account information. This API uses
| ID| Error Message |
| ID| Error Message |
| -------- | ------------- |
| -------- | ------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid domainInfo. |
| 12300002 | invalid domainInfo. |
**Example**
**Example**
...
@@ -1195,8 +1191,8 @@ Obtains the OS account ID based on the domain account information. This API uses
...
@@ -1195,8 +1191,8 @@ Obtains the OS account ID based on the domain account information. This API uses
| ID| Error Message |
| ID| Error Message |
| -------- | ------------- |
| -------- | ------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid domainInfo. |
| 12300002 | invalid domainInfo. |
**Example**
**Example**
...
@@ -1474,7 +1470,7 @@ Obtains information about all activated OS accounts. This API uses an asynchrono
...
@@ -1474,7 +1470,7 @@ Obtains information about all activated OS accounts. This API uses an asynchrono
| ID| Error Message |
| ID| Error Message |
| -------- | ------------- |
| -------- | ------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
**Example**
**Example**
...
@@ -1511,7 +1507,7 @@ Obtains information about all activated OS accounts. This API uses a promise to
...
@@ -1511,7 +1507,7 @@ Obtains information about all activated OS accounts. This API uses a promise to
| ID| Error Message |
| ID| Error Message |
| -------- | ------------- |
| -------- | ------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
**Example**
**Example**
...
@@ -2233,9 +2229,9 @@ Obtains the OS account ID based on the serial number (SN). This API uses an asyn
...
@@ -2233,9 +2229,9 @@ Obtains the OS account ID based on the serial number (SN). This API uses an asyn
| ID| Error Message |
| ID| Error Message |
| -------- | ------------------- |
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid serialNumber. |
| 12300002 | invalid serialNumber. |
| 12300003 | Account not found. |
| 12300003 | the account indicated by serialNumber dose not exist. |
**Example**: Obtain the ID of the OS account whose SN is 12345.
**Example**: Obtain the ID of the OS account whose SN is 12345.
...
@@ -2276,9 +2272,9 @@ Obtains the OS account ID based on the SN. This API uses a promise to return the
...
@@ -2276,9 +2272,9 @@ Obtains the OS account ID based on the SN. This API uses a promise to return the
| ID| Error Message |
| ID| Error Message |
| -------- | ------------------- |
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid serialNumber. |
| 12300002 | invalid serialNumber. |
| 12300003 | Account not found. |
| 12300003 | the account indicated by serialNumber dose not exist. |
**Example**: Obtain the ID of the OS account whose SN is 12345.
**Example**: Obtain the ID of the OS account whose SN is 12345.
...
@@ -2315,9 +2311,9 @@ Obtains the SN of an OS account based on the account ID. This API uses an asynch
...
@@ -2315,9 +2311,9 @@ Obtains the SN of an OS account based on the account ID. This API uses an asynch
| ID| Error Message |
| ID| Error Message |
| -------- | ------------------- |
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid localId. |
| 12300002 | invalid localId. |
| 12300003 | Account not found. |
| 12300003 | the account indicated by localId dose not exist. |
**Example**: Obtain the SN of the OS account 100.
**Example**: Obtain the SN of the OS account 100.
...
@@ -2358,9 +2354,9 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise
...
@@ -2358,9 +2354,9 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise
| ID| Error Message |
| ID| Error Message |
| -------- | ------------------- |
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid localId. |
| 12300002 | invalid localId. |
| 12300003 | Account not found. |
| 12300003 | the account indicated by localId dose not exist. |
**Example**: Obtain the SN of the OS account 100.
**Example**: Obtain the SN of the OS account 100.
...
@@ -2483,8 +2479,8 @@ Obtains the bundle ID based on the UID. This API uses an asynchronous callback t
...
@@ -2483,8 +2479,8 @@ Obtains the bundle ID based on the UID. This API uses an asynchronous callback t
| ID| Error Message |
| ID| Error Message |
| -------- | ------------- |
| -------- | ------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid uid. |
| 12300002 | invalid uid. |
**Example**
**Example**
...
@@ -2526,8 +2522,8 @@ Obtains the bundle ID based on the UID. This API uses a promise to return the re
...
@@ -2526,8 +2522,8 @@ Obtains the bundle ID based on the UID. This API uses a promise to return the re
| ID| Error Message |
| ID| Error Message |
| -------- | ------------- |
| -------- | ------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid uid. |
| 12300002 | invalid uid. |
**Example**
**Example**
...
@@ -2644,9 +2640,9 @@ Obtains the constraint source information of an OS account. This API uses an asy
...
@@ -2644,9 +2640,9 @@ Obtains the constraint source information of an OS account. This API uses an asy
| ID| Error Message |
| ID| Error Message |
| -------- | ------------- |
| -------- | ------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid localId or constraint. |
| 12300002 | invalid name or constraint. |
| 12300003 | Account not found. |
| 12300003 | the account indicated by localId dose not exist. |
**Example**
**Example**
...
@@ -2691,9 +2687,9 @@ Obtains the constraint source information of an OS account. This API uses a prom
...
@@ -2691,9 +2687,9 @@ Obtains the constraint source information of an OS account. This API uses a prom
| ID| Error Message |
| ID| Error Message |
| -------- | ------------- |
| -------- | ------------- |
| 12300001 | System service exception. |
| 12300001 | system service exception. |
| 12300002 | Invalid localId or constraint. |
| 12300002 | invalid name or constraint. |
| 12300003 | Account not found. |
| 12300003 | the account indicated by localId dose not exist. |
**Example**
**Example**
...
@@ -4433,15 +4429,26 @@ Authenticates a domain account.
...
@@ -4433,15 +4429,26 @@ Authenticates a domain account.
This **wifiext** module provides WLAN extension interfaces for non-universal products.
This **wifiext** module provides WLAN extension interfaces for non-universal products.
> **NOTE**
> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
The APIs described in this document are used only for non-universal products, such as routers.
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs described in this document are used only for non-universal products, such as routers.
## Modules to Import
## Modules to Import
...
@@ -12,9 +13,9 @@ The APIs described in this document are used only for non-universal products, su
...
@@ -12,9 +13,9 @@ The APIs described in this document are used only for non-universal products, su
importwifiManagerExtfrom'@ohos.wifiManagerExt';
importwifiManagerExtfrom'@ohos.wifiManagerExt';
```
```
## wifiext.enableHotspot
## wifiext.enableHotspot<sup>9+</sup>
enableHotspot(): boolean;
enableHotspot(): void;
Enables the WLAN hotspot.
Enables the WLAN hotspot.
...
@@ -27,12 +28,12 @@ Enables the WLAN hotspot.
...
@@ -27,12 +28,12 @@ Enables the WLAN hotspot.
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| **Type**| **Description**|
| -------- | -------- |
| -------- | -------- |
| 2701000 | Operation failed.|
| 2701000 | Operation failed.|
## wifiext.disableHotspot
## wifiext.disableHotspot<sup>9+</sup>
disableHotspot(): boolean;
disableHotspot(): void;
Disables the WLAN hotspot.
Disables the WLAN hotspot.
...
@@ -45,14 +46,14 @@ Disables the WLAN hotspot.
...
@@ -45,14 +46,14 @@ Disables the WLAN hotspot.
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
@@ -97,23 +98,23 @@ Obtains the supported power models. This API uses an asynchronous callback to re
...
@@ -97,23 +98,23 @@ Obtains the supported power models. This API uses an asynchronous callback to re
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<Array<[PowerModel](#powermodel)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power models obtained. If **err** is not **0**, an error has occurred.|
| callback | AsyncCallback<Array<[PowerMode](#powermode)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power modes obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| **Type**| **Description**|
| -------- | -------- |
| -------- | -------- |
| 2701000 | Operation failed.|
| 2701000 | Operation failed.|
## wifiext.getPowerModel
## wifiext.getPowerMode<sup>9+</sup>
getPowerModel(): Promise<PowerModel>
getPowerMode(): Promise<PowerMode>
Obtains the power model. This API uses a promise to return the result.
Obtains the power mode. This API uses a promise to return the result.
@@ -145,23 +146,23 @@ Obtains the power model. This API uses an asynchronous callback to return the re
...
@@ -145,23 +146,23 @@ Obtains the power model. This API uses an asynchronous callback to return the re
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[PowerModel](#powermodel)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.|
| callback | AsyncCallback<[PowerMode](#powermode)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power mode obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).