From 05091d527338b3ef79a7223b447bd51c6214cba1 Mon Sep 17 00:00:00 2001 From: annie_wangli Date: Mon, 4 Apr 2022 20:02:49 +0800 Subject: [PATCH] update docs Signed-off-by: annie_wangli --- .../reference/apis/js-apis-fileio.md | 1573 +++++++++++------ .../apis/js-apis-resource-manager.md | 288 +-- 2 files changed, 1211 insertions(+), 650 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-fileio.md b/en/application-dev/reference/apis/js-apis-fileio.md index 67e1d8d19e..f574cc1589 100644 --- a/en/application-dev/reference/apis/js-apis-fileio.md +++ b/en/application-dev/reference/apis/js-apis-fileio.md @@ -45,13 +45,13 @@ Asynchronously obtains file information. This method uses a promise to return th **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------- | + | path | string | Yes | Absolute path of the target file.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | Promise used to return the file information obtained.| - Example @@ -73,10 +73,10 @@ Asynchronously obtains file information. This method uses a callback to return t **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | callback | AsyncCallback<[Stat](#stat)> | Yes| Callback invoked to return the file information obtained.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------- | ---- | --------------- | + | path | string | Yes | Absolute path of the target file. | + | callback | AsyncCallback<[Stat](#stat)> | Yes | Callback invoked to return the file information obtained.| - Example ```js @@ -95,14 +95,14 @@ Synchronously obtains file information. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------- | + | path | string | Yes | Absolute path of the target file.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------- | ---------- | | [Stat](#stat) | File information obtained.| - Example @@ -121,13 +121,13 @@ Asynchronously opens a directory. This method uses a promise to return the resul **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the directory to open.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------- | + | path | string | Yes | Absolute path of the directory to open.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | -------------------------- | -------- | | Promise<[Dir](#dir)> | A **Dir** instance corresponding to the directory.| - Example @@ -149,10 +149,10 @@ Asynchronously opens a directory. This method uses a callback to return the resu **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the directory to open.| - | callback | AsyncCallback<[Dir](#dir)> | Yes| Callback invoked when the directory is open asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | -------------------------------- | ---- | -------------- | + | path | string | Yes | Absolute path of the directory to open. | + | callback | AsyncCallback<[Dir](#dir)> | Yes | Callback invoked when the directory is open asynchronously.| - Example ```js @@ -173,13 +173,13 @@ Synchronously opens a directory. - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the directory to open.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------- | + | path | string | Yes | Absolute path of the directory to open.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ----------- | -------- | | [Dir](#dir) | A **Dir** instance corresponding to the directory.| - Example @@ -199,14 +199,14 @@ Asynchronously checks whether the current process can access a file. This method **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | mode | number | No| Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | mode | number | No | Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -228,11 +228,11 @@ Asynchronously checks whether the current process can access a file. This method **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | mode | number | No| Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the file is asynchronously checked.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | mode | number | No | Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is asynchronously checked. | - Example ```js @@ -251,10 +251,10 @@ Synchronously checks whether the current process can access the specified file. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | mode | number | No| Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | mode | number | No | Options for accessing the file. You can specify multiple options, separated with a bitwise OR operator (|). The default value is **0**.
The options are as follows:
- **0**: check whether the file exists.
- **1**: check whether the current process has the execute permission on the file.
- **2**: check whether the current process has the write permission on the file.
- **4**: check whether the current process has the read permission on the file.| - Example ```js @@ -275,13 +275,13 @@ Asynchronously closes a file. This method uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to close.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor of the file to close.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -304,10 +304,10 @@ Asynchronously closes a file. This method uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to close.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the file is closed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------ | + | fd | number | Yes | File descriptor of the file to close.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is closed asynchronously.| - Example ```js @@ -327,9 +327,9 @@ Synchronously closes a file. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to close.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor of the file to close.| - Example ```js @@ -346,8 +346,8 @@ Asynchronously closes the stream. This method uses a promise to return the resul **System capability**: SystemCapability.FileManagement.File.FileIO - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -369,9 +369,9 @@ Asynchronously closes the stream. This method uses a callback to return the resu **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback invoked when the stream is closed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------- | + | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| - Example ```js @@ -390,15 +390,15 @@ Asynchronously copies a file. This method uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | string \| number | Yes| Path or file descriptor of the file to copy.| - | dest | string \| number | Yes| Path or file descriptor of the new file.| - | mode | number | No| Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| + | Name | Type | Mandatory | Description | + | ---- | -------------------------- | ---- | ---------------------------------------- | + | src | string \| number | Yes | Path or file descriptor of the file to copy. | + | dest | string \| number | Yes | Path or file descriptor of the new file. | + | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -420,12 +420,12 @@ Asynchronously copies a file. This method uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | string \| number | Yes| Path or file descriptor of the file to copy.| - | dest | string \| number | Yes| Path or file descriptor of the new file.| - | mode | number | No| Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely 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.| + | Name | Type | Mandatory | Description | + | -------- | -------------------------- | ---- | ---------------------------------------- | + | src | string \| number | Yes | Path or file descriptor of the file to copy. | + | dest | string \| number | Yes | Path or file descriptor of the new file. | + | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely 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. | - Example ```js @@ -444,11 +444,11 @@ Synchronously copies a file. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | src | string \| number | Yes| Path or file descriptor of the file to copy.| - | dest | string \| number | Yes| Path or file descriptor of the new file.| - | mode | number | No| Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| + | Name | Type | Mandatory | Description | + | ---- | -------------------------- | ---- | ---------------------------------------- | + | src | string \| number | Yes | Path or file descriptor of the file to copy. | + | dest | string \| number | Yes | Path or file descriptor of the new file. | + | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| - Example ```js @@ -465,14 +465,14 @@ Asynchronously creates a directory. This method uses a promise to return the res **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the directory to create.| - | mode | number | No| Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the directory to create. | + | mode | number | No | Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -494,11 +494,11 @@ Asynchronously creates a directory. This method uses a callback to return the re **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the directory to create.| - | mode | number | No| Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the directory is created asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the directory to create. | + | mode | number | No | Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the directory is created asynchronously. | - Example ```js @@ -519,10 +519,10 @@ Synchronously creates a directory. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the directory to create.| - | mode | number | No| Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the directory to create. | + | mode | number | No | Permission on the directory to create. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o775**.
- **0o775**: The owner has the read, write, and execute permissions, and other users have the read and execute permissions.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - Example ```js @@ -539,15 +539,15 @@ Asynchronously opens a file. This method uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | flags | number | No| Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| - | mode | number | No| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | Name | Type | Mandatory | Description | + | ----- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | flags | number | No | Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| + | mode | number | No | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | --------------------- | ----------- | | Promise<number> | File descriptor of the file opened.| - Example @@ -569,12 +569,12 @@ Asynchronously opens a file. This method uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | flags | number | Yes| Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| - | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - | callback | AsyncCallback <void> | Yes| Callback invoked when the file is open asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | flags | number | Yes | Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| + | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | callback | AsyncCallback <void> | Yes | Callback invoked when the file is open asynchronously. | - Example ```js @@ -593,15 +593,15 @@ Synchronously opens a file. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | flags | number | No| Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| - | mode | number | No| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.
The file permissions on newly created files are affected by umask, which is set as the process starts. Currently, the modification of umask is not open.| + | Name | Type | Mandatory | Description | + | ----- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | flags | number | No | Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
In addition, you can specify the following options, separated using a bitwise OR operator (|). By default, no additional option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.

- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| + | mode | number | No | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.
The file permissions on newly created files are affected by umask, which is set as the process starts. Currently, the modification of umask is not open.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------ | ----------- | | number | File descriptor of the file opened.| - Example @@ -623,15 +623,15 @@ Asynchronously reads data from a file. This method uses a promise to return the **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to read.| - | buffer | ArrayBuffer | Yes| Buffer used to store the file data read.| - | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the file to read. | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | Data read.| - Example @@ -659,12 +659,12 @@ Asynchronously reads data from a file. This method uses a callback to return the **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to read.| - | buffer | ArrayBuffer | Yes| Buffer used to store the file data read.| - | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| - | callback | AsyncCallback<[ReadOut](#readout)> | Yes| Callback invoked when the data is read asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the file to read. | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously. | - Example ```js @@ -691,15 +691,15 @@ Synchronously reads data from a file. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to read.| - | buffer | ArrayBuffer | Yes| Buffer used to store the file data read.| - | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the file to read. | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------ | -------- | | number | Length of the data read.| - Example @@ -719,13 +719,13 @@ Asynchronously deletes a directory. This method uses a promise to return the res **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the directory to delete.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------- | + | path | string | Yes | Absolute path of the directory to delete.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -747,10 +747,10 @@ Asynchronously deletes a directory. This method uses a callback to return the re **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the directory to delete.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the directory is deleted asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------ | + | path | string | Yes | Absolute path of the directory to delete. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the directory is deleted asynchronously.| - Example ```js @@ -769,9 +769,9 @@ Synchronously deletes a directory. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the directory to delete.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------- | + | path | string | Yes | Absolute path of the directory to delete.| - Example ```js @@ -788,13 +788,13 @@ Asynchronously deletes a file. This method uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the file to delete.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------- | + | path | string | Yes | Absolute path of the file to delete.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -816,10 +816,10 @@ Asynchronously deletes a file. This method uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the file to delete.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the file is deleted asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------ | + | path | string | Yes | Absolute path of the file to delete. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is deleted asynchronously.| - Example ```js @@ -840,9 +840,9 @@ Synchronously deletes a file. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the file to delete.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------- | + | path | string | Yes | Absolute path of the file to delete.| - Example ```js @@ -864,15 +864,15 @@ Asynchronously writes data into a file. This method uses a promise to return the **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to write.| - | buffer | ArrayBuffer \| string | Yes| Data to write. It can be a string or data from a buffer.| - | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the file to write. | + | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | --------------------- | -------- | | Promise<number> | Length of the data written in the file.| - Example @@ -900,12 +900,12 @@ Asynchronously writes data into a file. This method uses a callback to return th **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to write.| - | buffer | ArrayBuffer \| string | Yes| Data to write. It can be a string or data from a buffer.| - | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| - | callback | AsyncCallback<number> | Yes| Callback invoked when the data is written asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the file to write. | + | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | - Example ```js @@ -932,15 +932,15 @@ Synchronously writes data into a file. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to write.| - | buffer | ArrayBuffer \| string | Yes| Data to write. It can be a string or data from a buffer.| - | options | Object | No| The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the file to write. | + | buffer | ArrayBuffer \| string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------ | -------- | | number | Length of the data written in the file.| - Example @@ -959,14 +959,14 @@ Asynchronously calculates the hash value of a file. This method uses a promise t **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | algorithm | string | Yes| Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**.**sha256** is recommended for security purposes.| + | Name | Type | Mandatory | Description | + | --------- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**.**sha256** is recommended for security purposes.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | --------------------- | -------------------------- | | Promise<string> | Promise used to return the hash value of the file. The hash value is a hexadecimal string consisting of digits and uppercase letters.| - Example @@ -988,11 +988,11 @@ Asynchronously calculates the hash value of a file. This method uses a callback **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | algorithm | string | Yes| Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**.**sha256** is recommended for security purposes.| - | callback | AsyncCallback<string> | Yes| Callback used to return the hash value. The hash value is a hexadecimal string consisting of digits and uppercase letters.| + | Name | Type | Mandatory | Description | + | --------- | --------------------------- | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**.**sha256** is recommended for security purposes.| + | callback | AsyncCallback<string> | Yes | Callback used to return the hash value. The hash value is a hexadecimal string consisting of digits and uppercase letters.| - Example ```js @@ -1013,14 +1013,14 @@ Asynchronously changes the file permissions based on its path. This method uses **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -1042,11 +1042,11 @@ Asynchronously changes the file permissions based on its path. This method uses **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the file permissions are changed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the file permissions are changed asynchronously. | - Example ```js @@ -1065,10 +1065,10 @@ Synchronously changes the file permissions based on its path. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - Example ```js @@ -1085,12 +1085,12 @@ Asynchronously obtains file status information based on the file descriptor. Thi **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor of the target file.| - Return value - | Type| Description| + | Type | Description | | -------- | -------- | | Promise<[Stat](#stat)> | Promise used to return the file status information obtained.| @@ -1113,10 +1113,10 @@ Asynchronously obtains file status information based on the file descriptor. Thi **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| - | callback | AsyncCallback<[Stat](#stat)> | Yes| Callback invoked when the file status information is obtained asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------- | ---- | ---------------- | + | fd | number | Yes | File descriptor of the target file. | + | callback | AsyncCallback<[Stat](#stat)> | Yes | Callback invoked when the file status information is obtained asynchronously.| - Example ```js @@ -1136,13 +1136,13 @@ Synchronously obtains file status information based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor of the target file.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------- | ---------- | | [Stat](#stat) | File status information obtained.| - Example @@ -1161,14 +1161,14 @@ Asynchronously truncates a file based on the file descriptor. This method uses a **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to truncate.| - | len | number | Yes| File length, in bytes, after truncation.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------- | + | fd | number | Yes | File descriptor of the file to truncate. | + | len | number | Yes | File length, in bytes, after truncation.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -1191,11 +1191,11 @@ Asynchronously truncates a file based on the file descriptor. This method uses a **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to truncate.| - | len | number | Yes| File length, in bytes, after truncation.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the file is truncated asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ---------------- | + | fd | number | Yes | File descriptor of the file to truncate. | + | len | number | Yes | File length, in bytes, after truncation.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is truncated asynchronously. | - Example ```js @@ -1214,10 +1214,10 @@ Synchronously truncates a file based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to truncate.| - | len | number | No| File length, in bytes, after truncation.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------- | + | fd | number | Yes | File descriptor of the file to truncate. | + | len | number | No | File length, in bytes, after truncation.| - Example ```js @@ -1234,14 +1234,14 @@ Asynchronously truncates a file based on its path. This method uses a promise to **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the file to truncate.| - | len | number | Yes| File length, in bytes, after truncation.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------- | + | path | string | Yes | Absolute path of the file to truncate. | + | len | number | Yes | File length, in bytes, after truncation.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -1263,11 +1263,11 @@ Asynchronously truncates a file based on its path. This method uses a callback t **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the file to truncate.| - | len | number | Yes| File length, in bytes, after truncation.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the file is truncated asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ---------------- | + | path | string | Yes | Absolute path of the file to truncate. | + | len | number | Yes | File length, in bytes, after truncation.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is truncated asynchronously. | - Example ```js @@ -1286,10 +1286,10 @@ Synchronously truncates a file based on the file path. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the file to truncate.| - | len | number | No| File length, in bytes, after truncation.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------- | + | path | string | Yes | Absolute path of the file to truncate. | + | len | number | No | File length, in bytes, after truncation.| - Example ```js @@ -1310,14 +1310,14 @@ Asynchronously reads the text of a file. This method uses a promise to return th **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | filePath | string | Yes| Absolute path of the file to read.| - | options | Object | No| The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | -------- | ------ | ---- | ---------------------------------------- | + | filePath | string | Yes | Absolute path of the file to read. | + | options | Object | No | The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | --------------------- | ---------- | | Promise<string> | Promise used to return the content of the file read.| - Example @@ -1343,11 +1343,11 @@ Asynchronously reads the text of a file. This method uses a callback to return t **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | filePath | string | Yes| Absolute path of the file to read.| - | options | Object | No| The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| - | callback | AsyncCallback<string> | Yes| Callback invoked when the file is read asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | ---------------------------------------- | + | filePath | string | Yes | Absolute path of the file to read. | + | options | Object | No | The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| + | callback | AsyncCallback<string> | Yes | Callback invoked when the file is read asynchronously. | - Example ```js @@ -1370,15 +1370,15 @@ Synchronously reads the text of a file. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | filePath | string | Yes| Absolute path of the file to read.| - | options | Object | No| The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | -------- | ------ | ---- | ---------------------------------------- | + | filePath | string | Yes | Absolute path of the file to read. | + | options | Object | No | The options are as follows:
- **position** (number): position of the data to read in the file. By default, data is read from the current position.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **encoding** (string): format of the data (string) to be encoded. The default value is **utf-8**, which is the only value supported.| - Return value - | Type| Description| - | -------- | -------- | - | <string>| Content of the file read.| + | Type | Description | + | ------ | -------------------- | + | string | Content of the file read.| - Example ```js @@ -1395,13 +1395,13 @@ Asynchronously obtains link status information. This method uses a promise to re **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file, pointing to the link status.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------------- | + | path | string | Yes | Absolute path of the target file, pointing to the link status.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ---------------------------- | ---------- | | Promise<[Stat](#stat)> | Promise used to return the link status obtained.| - Example @@ -1423,10 +1423,10 @@ Asynchronously obtains link status information. This method uses a callback to r **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file, pointing to the link status.| - | callback | AsyncCallback<[Stat](#stat)> | Yes| Callback invoked when the link status information is obtained asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------- | ---- | ----------------- | + | path | string | Yes | Absolute path of the target file, pointing to the link status.| + | callback | AsyncCallback<[Stat](#stat)> | Yes | Callback invoked when the link status information is obtained asynchronously. | - Example ```js @@ -1445,13 +1445,13 @@ Synchronously obtains link status information. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file, pointing to the link status.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------------- | + | path | string | Yes | Absolute path of the target file, pointing to the link status.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------- | ---------- | | [Stat](#stat) | Link status obtained.| - Example @@ -1473,14 +1473,14 @@ Asynchronously reads data from a file. This method uses a promise to return the **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | buffer | ArrayBuffer | Yes| Buffer used to store the file data read.| - | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ---------------------------------- | ------ | | Promise<[ReadOut](#readout)> | Data read.| - Example @@ -1506,11 +1506,11 @@ Asynchronously reads data from a file. This method uses a callback to return the **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | buffer | ArrayBuffer | Yes| Buffer used to store the file data read.| - | options | Object | No| The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.| - | callback | AsyncCallback<[ReadOut](#readout)> | Yes| Callback invoked when the data is read asynchronously from the file.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.| + | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously from the file. | - Example ```js @@ -1532,19 +1532,19 @@ Asynchronously renames a file. This method uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | oldPath | string | Yes| Absolute path of the file to rename.| - | Newpath | String | Yes| Absolute path of the file renamed.| + | Name | Type | Mandatory| Description | + | ------- | ------ | ---- | ------------------------ | + | oldPath | string | Yes | Absolute path of the file to rename.| + | newPath | String | Yes | Absolute path of the file renamed. | - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example ```js - fileio.rename(oldPath, Newpath).then(function() { + fileio.rename(oldPath, newPath).then(function() { console.info("rename successfully"); }).catch(function(err){ console.info("rename failed with error:"+ err); @@ -1561,15 +1561,15 @@ Asynchronously renames a file. This method uses a callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | oldpath | string | Yes| Absolute path of the file to rename.| - | Newpath | String | Yes| Absolute path of the file renamed.| - | Callback | AsyncCallback<void> | Yes| Callback invoked when the file is asynchronously renamed.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------- | + | oldPath | string | Yes | Absolute path of the file to rename. | + | newPath | String | Yes | Absolute path of the file renamed. | + | Callback | AsyncCallback<void> | Yes | Callback invoked when the file is asynchronously renamed.| - Example ```js - fileio.rename(oldpath, Newpath, function(err){ + fileio.rename(oldPath, newPath, function(err){ }); ``` @@ -1583,14 +1583,14 @@ Synchronously renames a file. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | oldPath | string | Yes| Absolute path of the file to rename.| - | Newpath | String | Yes| Absolute path of the file renamed.| + | Name | Type | Mandatory | Description | + | ------- | ------ | ---- | ------------ | + | oldPath | string | Yes | Absolute path of the file to rename.| + | newPath | String | Yes | Absolute path of the file renamed. | - Example ```js - fileio.renameSync(oldpath, newpath); + fileio.renameSync(oldPath, newPath); ``` @@ -1603,13 +1603,13 @@ Asynchronously synchronizes a file. This method uses a promise to return the res **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to synchronize.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor of the file to synchronize.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -1631,10 +1631,10 @@ Asynchronously synchronizes a file. This method uses a callback to return the re **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to synchronize.| - | Callback | AsyncCallback<void> | Yes| Callback invoked when the file is synchronized in asynchronous mode.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | --------------- | + | fd | number | Yes | File descriptor of the file to synchronize. | + | Callback | AsyncCallback<void> | Yes | Callback invoked when the file is synchronized in asynchronous mode.| - Example ```js @@ -1653,9 +1653,9 @@ Synchronizes a file in synchronous mode. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to synchronize.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor of the file to synchronize.| - Example ```js @@ -1672,13 +1672,13 @@ Asynchronously synchronizes data in a file. This method uses a promise to return **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to synchronize.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor of the file to synchronize.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| - Example @@ -1700,10 +1700,10 @@ Asynchronously synchronizes data in a file. This method uses a callback to retur **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to synchronize.| - | callback | AsyncCallback <void> | Yes| Callback invoked when the file data is synchronized in asynchronous mode.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ----------------- | + | fd | number | Yes | File descriptor of the file to synchronize. | + | callback | AsyncCallback <void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| - Example ```js @@ -1722,9 +1722,9 @@ Synchronizes data in a file in synchronous mode. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the file to synchronize.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor of the file to synchronize.| - Example ```js @@ -1741,14 +1741,14 @@ Asynchronously creates a symbolic link based on a path. This method uses a promi **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | target | string | Yes| Absolute path of the symbolic link.| - | srcPath | string | Yes| Absolute path of the referenced file or directory contained in the symbolic link.| + | Name | Type | Mandatory | Description | + | ------- | ------ | ---- | ------------ | + | target | string | Yes | Absolute path of the symbolic link. | + | srcPath | string | Yes | Absolute path of the referenced file or directory contained in the symbolic link.| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| - Example @@ -1770,11 +1770,11 @@ Asynchronously creates a symbolic link based on a path. This method uses a callb **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | target | string | Yes| Absolute path of the symbolic link.| - | srcPath | string | Yes| Absolute path of the referenced file or directory contained in the symbolic link.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the symbolic link is created asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ---------------- | + | target | string | Yes | Absolute path of the symbolic link. | + | srcPath | string | Yes | Absolute path of the referenced file or directory contained in the symbolic link. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the symbolic link is created asynchronously.| - Example ```js @@ -1793,10 +1793,10 @@ Synchronously creates a symbolic link based on a specified path. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | target | string | Yes| Absolute path of the symbolic link.| - | srcPath | string | Yes| Absolute path of the referenced file or directory contained in the symbolic link.| + | Name | Type | Mandatory | Description | + | ------- | ------ | ---- | ------------ | + | target | string | Yes | Absolute path of the symbolic link. | + | srcPath | string | Yes | Absolute path of the referenced file or directory contained in the symbolic link.| - Example ```js @@ -1813,15 +1813,15 @@ Asynchronously changes the file owner based on its path. This method uses a prom **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | uid | number | Yes| New user ID (UID).| - | gid | number | Yes| New group ID (GID).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | --------------- | + | path | string | Yes | Absolute path of the target file. | + | uid | number | Yes | New user ID (UID). | + | gid | number | Yes | New group ID (GID).| - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| - Example @@ -1844,12 +1844,12 @@ Asynchronously changes the file owner based on its path. This method uses a call **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | uid | number | Yes| New UID.| - | gid | number | Yes| New GID.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the file owner is changed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | --------------- | + | path | string | Yes | Absolute path of the target file. | + | uid | number | Yes | New UID. | + | gid | number | Yes | New GID. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the file owner is changed asynchronously.| - Example ```js @@ -1869,11 +1869,11 @@ Synchronously changes the file owner based on its path. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | uid | number | Yes| New UID.| - | gid | number | Yes| New GID.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------- | + | path | string | Yes | Absolute path of the target file.| + | uid | number | Yes | New UID. | + | gid | number | Yes | New GID. | - Example ```js @@ -1891,13 +1891,13 @@ Asynchronously creates a temporary directory. This method uses a promise to retu **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | prefix | string | Yes| A randomly generated string used to replace "XXXXXX" in a directory.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| - Return value - | Name| Description| - | -------- | -------- | + | Name | Description | + | --------------------- | ---------- | | Promise<string> | Unique path generated.| - Example @@ -1919,10 +1919,10 @@ Asynchronously creates a temporary directory. This method uses a callback to ret **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | prefix | string | Yes| A randomly generated string used to replace "XXXXXX" in a directory.| - | callback | AsyncCallback<string> | Yes| Callback invoked when a temporary directory is created asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| + | callback | AsyncCallback<string> | Yes | Callback invoked when a temporary directory is created asynchronously. | - Example ```js @@ -1941,13 +1941,13 @@ Synchronously creates a temporary directory. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | prefix | string | Yes| A randomly generated string used to replace "XXXXXX" in a directory.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| - Return value - | Name| Description| - | -------- | -------- | + | Name | Description | + | ------ | ---------- | | string | Unique path generated.| - Example @@ -1965,14 +1965,14 @@ Asynchronously changes the file permissions based on the file descriptor. This m **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| - | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the target file. | + | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - Return value - | Name| Description| - | -------- | -------- | + | Name | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result asynchronously. An empty value is returned.| - Example @@ -1994,11 +1994,11 @@ Asynchronously changes the file permissions based on the file descriptor. This m **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| - | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - | callback | AsyncCallback <void> | Yes| Callback invoked when the file permissions are changed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the target file. | + | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | callback | AsyncCallback <void> | Yes | Callback invoked when the file permissions are changed asynchronously. | - Example ```js @@ -2017,10 +2017,10 @@ Synchronously changes the file permissions based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| - | mode | number | Yes| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the target file. | + | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|).
- **0o700**: The owner has the read, write, and execute permissions.
-  **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| - Example ```js @@ -2037,14 +2037,14 @@ Asynchronously opens a stream based on the file path. This method uses a promise **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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 - | Type| Description| - | -------- | -------- | + | Type | Description | + | --------------------------------- | --------- | | Promise<[Stream](#stream7)> | Promise used to return the result.| - Example @@ -2066,11 +2066,11 @@ Asynchronously opens a stream based on the file path. This method uses a callbac **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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](#stream7)> | Yes| Callback invoked when the stream is open asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | --------------------------------------- | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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](#stream7)> | Yes | Callback invoked when the stream is open asynchronously. | - Example ```js @@ -2089,14 +2089,14 @@ Synchronously opens a stream based on the file path. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | path | string | Yes | Absolute path of the target file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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 - | Name| Description| - | -------- | -------- | + | Name | Description | + | ------------------ | --------- | | [Stream](#stream7) | Stream opened.| - Example @@ -2114,14 +2114,14 @@ Asynchronously opens a stream based on the file descriptor. This method uses a p **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| - | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the target file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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 - | Name| Description| - | -------- | -------- | + | Name | Description | + | --------------------------------- | --------- | | Promise<[Stream](#stream7)> | Promise used to return the result.| - Example @@ -2143,11 +2143,11 @@ Asynchronously opens a stream based on the file descriptor. This method uses a c **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| - | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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](#stream7)> | Yes| Callback invoked when the stream is open asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the target file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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](#stream7)> | Yes | Callback invoked when the stream is open asynchronously. | - Example ```js @@ -2166,14 +2166,14 @@ Synchronously opens a stream based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| - | mode | string | Yes| - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | Yes | File descriptor of the target file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **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.
- **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).
- **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 - | Name| Description| - | -------- | -------- | + | Name | Description | + | ------------------ | --------- | | [Stream](#stream7) | Stream opened.| - Example @@ -2191,15 +2191,15 @@ Asynchronously changes the file owner based on the file descriptor. This method **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| - | uid | number | Yes| New UID.| - | gid | number | Yes| New GID.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor of the target file.| + | uid | number | Yes | New UID. | + | gid | number | Yes | New GID. | - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -2222,12 +2222,12 @@ Asynchronously changes the file owner based on the file descriptor. This method **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| - | uid | number | Yes| New UID.| - | gid | number | Yes| New GID.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the file owner is changed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | --------------- | + | fd | number | Yes | File descriptor of the target file. | + | uid | number | Yes | New UID. | + | gid | number | Yes | New GID. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the file owner is changed asynchronously.| - Example ```js @@ -2247,11 +2247,11 @@ Synchronously changes the file owner based on the file descriptor. **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fd | number | Yes| File descriptor of the target file.| - | uid | number | Yes| New UID.| - | gid | number | Yes| New GID.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | File descriptor of the target file.| + | uid | number | Yes | New UID. | + | gid | number | Yes | New GID. | - Example ```js @@ -2269,15 +2269,15 @@ Asynchronously changes the file owner based on the file path, changes the owner **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | uid | number | Yes| New UID.| - | gid | number | Yes| New GID.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------- | + | path | string | Yes | Absolute path of the target file.| + | uid | number | Yes | New UID. | + | gid | number | Yes | New GID. | - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------------------- | ---------------------------- | | Promise<void> | Promise used to return the result. An empty value is returned.| - Example @@ -2300,12 +2300,12 @@ Asynchronously changes the file owner based on the file path, changes the owner **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | uid | number | Yes| New UID.| - | gid | number | Yes| New GID.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the file owner is changed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | --------------- | + | path | string | Yes | Absolute path of the target file. | + | uid | number | Yes | New UID. | + | gid | number | Yes | New GID. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the file owner is changed asynchronously.| - Example ```js @@ -2325,11 +2325,11 @@ Synchronously changes the file owner based on the file path and changes the owne **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | path | string | Yes| Absolute path of the target file.| - | uid | number | Yes| New UID.| - | gid | number | Yes| New GID.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ----------- | + | path | string | Yes | Absolute path of the target file.| + | uid | number | Yes | New UID. | + | gid | number | Yes | New GID. | - Example ```js @@ -2347,15 +2347,15 @@ Asynchronously listens for the changes of a file or directory. This method uses **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | filename | string | Yes| Absolute path of the target file.| - | events | Number | Yes| - **1**: The file or directory is renamed.
- **2**: The file or directory is modified.
- **3**: The file or directory is modified and renamed.| - | callback | AsyncCallback<number > | Yes| Called each time a change is detected.| + | Name | Type | Mandatory | Description | + | -------- | --------------------------------- | ---- | ---------------------------------------- | + | filename | string | Yes | Absolute path of the target file. | + | events | Number | Yes | - **1**: The file or directory is renamed.
- **2**: The file or directory is modified.
- **3**: The file or directory is modified and renamed.| + | callback | AsyncCallback<number > | Yes | Called each time a change is detected. | - Return value - | Name| Description| - | -------- | -------- | + | Name | Description | + | -------------------- | ---------- | | [Watcher](#watcher7) | Instance for listening for a file change event.| - Example @@ -2372,11 +2372,11 @@ Obtains the file read result. This class applies only to the **read()** method. **System capability**: SystemCapability.FileManagement.File.FileIO -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| bytesRead | number | Yes| Yes| Length of the data read.| -| offset | number | Yes| Yes| Position of the buffer to which the data will be read in reference to the start address of the buffer.| -| buffer | ArrayBufer | Yes| Yes| Buffer for storing the data read.| +| Name | Type | Readable | Writable | Description | +| --------- | ---------- | ---- | ---- | ----------------- | +| bytesRead | number | Yes | Yes | Length of the data read. | +| offset | number | Yes | Yes | Position of the buffer to which the data will be read in reference to the start address of the buffer.| +| buffer | ArrayBufer | Yes | Yes | Buffer for storing the data read. | ## Stat @@ -2387,20 +2387,20 @@ Provides detailed file information. Before calling a method of the **Stat** clas ### Attributes -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| dev | number | Yes| No| Major device number.| -| ino | number | Yes| No| File ID. Different files on the same device have different **ino**s.| -| mode | number | Yes| No| File type and permissions. The first four bits indicate the file type, and the last 12 bits indicate the permissions. The bit fields are described as follows:
- **0o170000**: mask used to obtain the file type.
- **0o140000**: The file is a socket.
- **0o120000**: The file is a symbolic link.
- **0o100000**: The file is a regular file.
- **0o060000**: The file is a block device.
- **0o040000**: The file is a directory.
- **0o020000**: The file is a character device.
- **0o010000**: The file is a named pipe (FIFO).
- **0o0700**: mask used to obtain the owner permissions.
- **0o0400**: The owner has the permission to read a regular file or a directory entry.
- **0o0200**: The owner has the permission to write a regular file or create and delete a directory entry.
- **0o0100**: The owner has the permission to execute a regular file or search for the specified path in a directory.
- **0o0070**: mask used to obtain the user group permissions.
- **0o0040**: The user group has the permission to read a regular file or a directory entry.
- **0o0020**: The user group has the permission to write a regular file or create and delete a directory entry.
- **0o0010**: The user group has the permission to execute a regular file or search for the specified path in a directory.
- **0o0007**: mask used to obtain the permissions of other users.
- **0o0004**: Other users have the permission to read a regular file or a directory entry.
- **0o0002**: Other users have the permission to write a regular file or create and delete a directory entry.
- **0o0001**: Other users have the permission to execute a regular file or search for the specified path in a directory.| -| nlink | number | Yes| No| Number of hard links in the file.| -| uid | number | Yes| No| User ID, that is ID of the file owner.| -| gid | number | Yes| No| Group ID, that is, ID of the user group of the file.| -| rdev | number | Yes| No| Minor device number.| -| size | number | Yes| No| File size, in bytes. This parameter is valid only for regular files.| -| blocks | number | Yes| No| Number of blocks occupied by a file. Each block is 512 bytes.| -| atime | number | Yes| No| Time of the last access to the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970.| -| mtime | number | Yes| No| Time of the last modification to the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970.| -| ctime | number | Yes| No| Time of the last status change of the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970.| +| Name | Type | Readable | Writable | Description | +| ------ | ------ | ---- | ---- | ---------------------------------------- | +| dev | number | Yes | No | Major device number. | +| ino | number | Yes | No | File ID. Different files on the same device have different **ino**s. | +| mode | number | Yes | No | File type and permissions. The first four bits indicate the file type, and the last 12 bits indicate the permissions. The bit fields are described as follows:
- **0o170000**: mask used to obtain the file type.
- **0o140000**: The file is a socket.
- **0o120000**: The file is a symbolic link.
- **0o100000**: The file is a regular file.
- **0o060000**: The file is a block device.
- **0o040000**: The file is a directory.
- **0o020000**: The file is a character device.
- **0o010000**: The file is a named pipe (FIFO).
- **0o0700**: mask used to obtain the owner permissions.
- **0o0400**: The owner has the permission to read a regular file or a directory entry.
- **0o0200**: The owner has the permission to write a regular file or create and delete a directory entry.
- **0o0100**: The owner has the permission to execute a regular file or search for the specified path in a directory.
- **0o0070**: mask used to obtain the user group permissions.
- **0o0040**: The user group has the permission to read a regular file or a directory entry.
- **0o0020**: The user group has the permission to write a regular file or create and delete a directory entry.
- **0o0010**: The user group has the permission to execute a regular file or search for the specified path in a directory.
- **0o0007**: mask used to obtain the permissions of other users.
- **0o0004**: Other users have the permission to read a regular file or a directory entry.
- **0o0002**: Other users have the permission to write a regular file or create and delete a directory entry.
- **0o0001**: Other users have the permission to execute a regular file or search for the specified path in a directory.| +| nlink | number | Yes | No | Number of hard links in the file. | +| uid | number | Yes | No | User ID, that is ID of the file owner. | +| gid | number | Yes | No | Group ID, that is, ID of the user group of the file. | +| rdev | number | Yes | No | Minor device number. | +| size | number | Yes | No | File size, in bytes. This parameter is valid only for regular files. | +| blocks | number | Yes | No | Number of blocks occupied by a file. Each block is 512 bytes. | +| atime | number | Yes | No | Time of the last access to the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970. | +| mtime | number | Yes | No | Time of the last modification to the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970. | +| ctime | number | Yes | No | Time of the last status change of the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970. | ### isBlockDevice @@ -2412,8 +2412,8 @@ Checks whether the current directory entry is a block special file. A block spec **System capability**: SystemCapability.FileManagement.File.FileIO - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------- | ---------------- | | boolean | Whether the directory entry is a block special file.| - Example @@ -2431,8 +2431,8 @@ Checks whether the current directory entry is a character special file. A charac **System capability**: SystemCapability.FileManagement.File.FileIO - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------- | ----------------- | | boolean | Whether the directory entry is a character special file.| - Example @@ -2450,8 +2450,8 @@ Checks whether a directory entry is a directory. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------- | ------------- | | boolean | Whether the directory entry is a directory.| - Example @@ -2469,8 +2469,8 @@ Checks whether the current directory entry is a named pipe (or FIFO). Named pipe **System capability**: SystemCapability.FileManagement.File.FileIO - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------- | --------------------- | | boolean | Whether the directory entry is a FIFO.| - Example @@ -2488,8 +2488,8 @@ Checks whether a directory entry is a regular file. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------- | --------------- | | boolean | Whether the directory entry is a regular file.| - Example @@ -2507,8 +2507,8 @@ Checks whether a directory entry is a socket. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------- | -------------- | | boolean | Whether the directory entry is a socket.| - Example @@ -2526,8 +2526,8 @@ Checks whether a directory entry is a symbolic link. **System capability**: SystemCapability.FileManagement.File.FileIO - Return value - | Type| Description| - | -------- | -------- | + | Type | Description | + | ------- | --------------- | | boolean | Whether the directory entry is a symbolic link.| - Example @@ -2564,9 +2564,9 @@ Asynchronously stops **watcher**. This method uses a callback to return the resu **System capability**: SystemCapability.FileManagement.File.FileIO - Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback invoked when **watcher** is stopped asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ---------------------- | + | callback | AsyncCallback<void> | Yes | Callback invoked when **watcher** is stopped asynchronously.| - Example ```js @@ -2574,3 +2574,564 @@ Asynchronously stops **watcher**. This method uses a callback to return the resu // Do something. }); ``` + + +## Stream7+ + +File stream. Before calling a method of the **Stream** class, use the **createStream()** method synchronously or asynchronously to create a **Stream** instance. + + +### close7+ + +close(): Promise<void> + +Asynchronously closes the stream. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | ------------------- | ------------- | + | Promise<void> | Promise used to return the stream close result.| + +- Example + ```js + let ss= fileio.createStreamSync(path); + ss.close().then(function(){ + console.info("close fileStream successfully"); + }).catch(function(err){ + console.info("close fileStream failed with error:"+ err); + }); + ``` + + +### close7+ + +close(callback: AsyncCallback<void>): void + +Asynchronously closes the stream. This method uses a callback to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------- | + | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| + +- Example + ```js + let ss= fileio.createStreamSync(path); + ss.close(function (err) { + // do something + }); + ``` + + +### closeSync + +closeSync(): void + +Synchronously closes the stream. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Example + ```js + let ss= fileio.createStreamSync(path); + ss.closeSync(); + ``` + + +### flush7+ + +flush(): Promise<void> + +Asynchronously flushes the stream. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | ------------------- | ------------- | + | Promise<void> | Promise used to return the stream flushing result.| + +- Example + ```js + let ss= fileio.createStreamSync(path); + ss.flush().then(function (){ + console.info("flush successfully"); + }).catch(function(err){ + console.info("flush failed with error:"+ err); + }); + ``` + + +### flush7+ + +flush(callback: AsyncCallback<void>): void + +Asynchronously flushes the stream. This method uses a callback to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | -------------- | + | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is asynchronously flushed.| + +- Example + ```js + let ss= fileio.createStreamSync(path); + ss.flush(function (err) { + // do something + }); + ``` + + +### flushSync7+ + +flushSync(): void + +Synchronously flushes the stream. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Example + ```js + let ss= fileio.createStreamSync(path); + ss.flushSync(); + ``` + + +### write7+ + +write(buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + position?: number; + encoding?: string; +}): Promise<number> + +Asynchronously writes data into the stream. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | 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:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + +- Return value + | Type | Description | + | --------------------- | -------- | + | Promise<number> | Length of the data written in the file.| + +- Example + ```js + let ss= fileio.createStreamSync(fpath, "r+"); + ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number){ + console.info("write successfully:"+ number); + }).catch(function(err){ + console.info("write failed with error:"+ err); + }); + ``` + + +### write7+ + +write(buffer: ArrayBuffer | string, options: { + offset?: number; + length?: number; + position?: number; + encoding?: string; +}, callback: AsyncCallback<number>): void + +Asynchronously writes data into the stream. This method uses a callback to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | 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:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | + +- Example + ```js + let ss= fileio.createStreamSync(fpath, "r+"); + ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) { + if (!err) { + // do something + console.log(bytesWritten); + } + }); + ``` + + +### writeSync7+ + +writeSync(buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + position?: number; + encoding?: string; +}): number + +Synchronously writes data into the stream. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | 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:
- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.
- **length** (number): length of the data to write. The default value is the buffer length minus the offset.
- **position** (number): start position to write the data in the file. By default, data is written from the current position.
- **encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| + +- Return value + | Type | Description | + | ------ | -------- | + | number | Length of the data written in the file.| + +- Example + ```js + let ss= fileio.createStreamSync(fpath,"r+"); + let num = ss.writeSync("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}); + ``` + + +### read7+ + +read(buffer: ArrayBuffer, options?: { + position?: number; + offset?: number; + length?: number; +}): Promise<ReadOut> + +Asynchronously reads data from the stream. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + +- Return value + | Type | Description | + | ---------------------------------- | ------ | + | Promise<[ReadOut](#readout)> | Data read.| + +- Example + ```js + let ss = fileio.createStreamSync(fpath, "r+"); + ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readout){ + console.info("read data successfully"); + }).catch(function(err){ + console.info("read data failed with error:"+ err); + }); + ``` + + +### read7+ + +read(buffer: ArrayBuffer, options: { + position?: number; + offset?: number; + length?: number; +}, callback: AsyncCallback<ReadOut>): void + +Asynchronously reads data from the stream. This method uses a callback to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when data is read asynchronously from the stream. | + +- Example + ```js + let ss = fileio.createStreamSync(fpath, "r+"); + ss.read(new ArrayBuffer(4096),{offset: 1, length: 5, position: 5},function (err, readOut) { + if (!err) { + // do something + } + }); + ``` + + +### readSync7+ + +readSync(buffer: ArrayBuffer, options?: { + position?: number; + offset?: number; + length?: number; +}): number + +Synchronously reads data from the stream. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.
- **length** (number): length of the data to read. The default value is the buffer length minus the offset.
- **position** (number): position of the data to read in the file. By default, data is read from the current position.| + +- Return value + | Type | Description | + | ------ | -------- | + | number | Length of the data read.| + +- Example + ```js + let ss = fileio.createStreamSync(fpath, "r+"); + let num = ss.readSync(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}); + ``` + + +## Dir + +Manages directories. Before calling a method of the **Dir** class, use the [opendir()](#fileioopendir) method synchronously or asynchronously to create a **Dir** instance. + + +### read + +read(): Promise<Dirent> + +Asynchronously reads the next directory entry. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | -------------------------------- | ------------- | + | Promise<[Dirent](#dirent)> | Directory entry that is read asynchronously.| + +- Example + ```js + let dir = fileio.opendirSync(path); + dir.read().then(function (dirent){ + console.info("read successfully:"+ dirent.name); + }).catch(function(err){ + console.info("read failed with error:"+ err); + }); + ``` + + +### read + +read(callback: AsyncCallback<Dirent>): void + +Asynchronously reads the next directory entry. This method uses a callback to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------------------------------------- | ---- | ---------------- | + | callback | AsyncCallback<[Dirent](#dirent)> | Yes | Callback invoked when the next directory entry is asynchronously read.| + +- Example + ```js + let dir = fileio.opendirSync(path); + dir.read(function (err, dirent) { + if (!err) { + // do something + console.log(dirent.name) + } + }); + ``` + + +### readSync + +readSync(): Dirent + +Synchronously reads the next directory entry. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | ----------------- | -------- | + | [Dirent](#dirent) | Directory entry read.| + +- Example + ```js + let dir = fileio.opendirSync(path); + let dirent = dir.readSync(); + ``` + + +### closeSync + +closeSync(): void + +Closes a directory. After a directory is closed, the file descriptor in Dir will be released and no directory entry can be read from Dir. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Example + ```js + let dir = fileio.opendirSync(path); + dir.closeSync(); + ``` + + +## Dirent + +Provides information about files and directories. Before calling a method of the **Dirent** class, use the [dir.read()](#read) method synchronously or asynchronously to create a **Dirent** instance. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +### Attributes + +| Name | Type | Readable | Writable | Description | +| ---- | ------ | ---- | ---- | ------- | +| name | string | Yes | No | Directory entry name.| + + +### isBlockDevice + +isBlockDevice(): boolean + +Checks whether the current directory entry is a block special file. A block special file supports access by block only, and it is cached when accessed. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | ------- | ---------------- | + | boolean | Whether the directory entry is a block special file.| + +- Example + ```js + let dir = fileio.opendirSync(path); + let isBLockDevice = dir.readSync().isBlockDevice(); + ``` + + +### isCharacterDevice + +isCharacterDevice(): boolean + +Checks whether a directory entry is a character special file. A character special file supports random access, and it is not cached when accessed. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | ------- | ----------------- | + | boolean | Whether the directory entry is a character special file.| + +- Example + ```js + let dir = fileio.opendirSync(path); + let isCharacterDevice = dir.readSync().isCharacterDevice(); + ``` + + +### isDirectory + +isDirectory(): boolean + +Checks whether a directory entry is a directory. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | ------- | ------------- | + | boolean | Whether the directory entry is a directory.| + +- Example + ```js + let dir = fileio.opendirSync(path); + let isDirectory = dir.readSync().isDirectory(); + ``` + + +### isFIFO + +isFIFO(): boolean + +Checks whether the current directory entry is a named pipe (or FIFO). Named pipes are used for inter-process communication. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | ------- | --------------- | + | boolean | Whether the directory entry is a FIFO.| + +- Example + ```js + let dir = fileio.opendirSync(path); + let isFIFO = dir.readSync().isFIFO(); + ``` + + +### isFile + +isFile(): boolean + +Checks whether a directory entry is a regular file. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | ------- | --------------- | + | boolean | Whether the directory entry is a regular file.| + +- Example + ```js + let dir = fileio.opendirSync(path); + let isFile = dir.readSync().isFile(); + ``` + + +### isSocket + +isSocket(): boolean + +Checks whether a directory entry is a socket. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | ------- | -------------- | + | boolean | Whether the directory entry is a socket.| + +- Example + ```js + let dir = fileio.opendirSync(dpath); + let isSocket = dir.readSync().isSocket(); + ``` + + +### isSymbolicLink + +isSymbolicLink(): boolean + +Checks whether a directory entry is a symbolic link. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Return value + | Type | Description | + | ------- | --------------- | + | boolean | Whether the directory entry is a symbolic link.| + +- Example + ```js + let dir = fileio.opendirSync(path); + let isSymbolicLink = dir.readSync().isSymbolicLink(); + ``` diff --git a/en/application-dev/reference/apis/js-apis-resource-manager.md b/en/application-dev/reference/apis/js-apis-resource-manager.md index e5e0509263..62664b3cc0 100644 --- a/en/application-dev/reference/apis/js-apis-resource-manager.md +++ b/en/application-dev/reference/apis/js-apis-resource-manager.md @@ -1,4 +1,4 @@ -# Resource Management +#Resource Management > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -19,9 +19,9 @@ Obtains the **ResourceManager** object of this application. This method uses a c **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | ---------------------------------------- | -| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the **ResourceManager** object obtained. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ----------------------------- | +| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the **ResourceManager** object obtained.| **Example** ``` @@ -50,10 +50,10 @@ Obtains the **ResourceManager** object of an application. This method uses an as **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ---------------------------------------- | --------- | ---------------------------------------- | -| bundleName | string | Yes | Bundle name of the target application. | -| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the **ResourceManager** object obtained. | +| Name | Type | Mandatory | Description | +| ---------- | ---------------------------------------- | ---- | ----------------------------- | +| bundleName | string | Yes | Bundle name of the target application. | +| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the **ResourceManager** object obtained.| **Example** ``` @@ -71,9 +71,9 @@ Obtains the **ResourceManager** object of this application. This method uses a p **System capability**: SystemCapability.Global.ResourceManager **Return value** -| Type | Description | -| ---------------------------------------- | ---------------------------------------- | -| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained. | +| Type | Description | +| ---------------------------------------- | ----------------- | +| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained.| **Example** ``` @@ -100,14 +100,14 @@ Obtains the **ResourceManager** object of an application. This method uses a pro **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ------ | --------- | -------------------------------------- | -| bundleName | string | Yes | Bundle name of the target application. | +| Name | Type | Mandatory | Description | +| ---------- | ------ | ---- | ------------- | +| bundleName | string | Yes | Bundle name of the target application.| **Return value** -| Type | Description | -| ---------------------------------------- | ---------------------------------------- | -| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained. | +| Type | Description | +| ---------------------------------------- | ------------------ | +| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained.| **Example** ``` @@ -125,10 +125,10 @@ Enumerates the screen directions. **System capability**: SystemCapability.Global.ResourceManager -| Name | Default Value | Description | -| -------------------- | ------------- | ----------- | -| DIRECTION_VERTICAL | 0 | Portrait | -| DIRECTION_HORIZONTAL | 1 | Landscape | +| Name | Default Value | Description | +| -------------------- | ---- | ---- | +| DIRECTION_VERTICAL | 0 | Portrait | +| DIRECTION_HORIZONTAL | 1 | Landscape | ## DeviceType @@ -137,14 +137,14 @@ Enumerates the device types. **System capability**: SystemCapability.Global.ResourceManager -| Name | Default Value | Description | -| -------------------- | ------------- | ------------- | -| DEVICE_TYPE_PHONE | 0x00 | Mobile phone. | -| DEVICE_TYPE_TABLET | 0x01 | Tablet. | -| DEVICE_TYPE_CAR | 0x02 | Automobile. | -| DEVICE_TYPE_PC | 0x03 | Computer. | -| DEVICE_TYPE_TV | 0x04 | TV. | -| DEVICE_TYPE_WEARABLE | 0x06 | Wearable. | +| Name | Default Value | Description | +| -------------------- | ---- | ---- | +| DEVICE_TYPE_PHONE | 0x00 | Mobile phone. | +| DEVICE_TYPE_TABLET | 0x01 | Tablet. | +| DEVICE_TYPE_CAR | 0x02 | Automobile. | +| DEVICE_TYPE_PC | 0x03 | Computer. | +| DEVICE_TYPE_TV | 0x04 | TV. | +| DEVICE_TYPE_WEARABLE | 0x06 | Wearable. | ## ScreenDensity @@ -153,14 +153,14 @@ Enumerates the screen density types. **System capability**: SystemCapability.Global.ResourceManager -| Name | Default Value | Description | -| -------------- | ------------- | ---------------------------------------- | -| SCREEN_SDPI | 120 | Screen density with small-scale dots per inch (SDPI). | -| SCREEN_MDPI | 160 | Screen density with medium-scale dots per inch (MDPI). | -| SCREEN_LDPI | 240 | Screen density with large-scale dots per inch (LDPI). | -| SCREEN_XLDPI | 320 | Screen density with extra-large-scale dots per inch (XLDPI). | -| SCREEN_XXLDPI | 480 | Screen density with extra-extra-large-scale dots per inch (XXLDPI). | -| SCREEN_XXXLDPI | 640 | Screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). | +| Name | Default Value | Description | +| -------------- | ---- | ---------- | +| SCREEN_SDPI | 120 | Screen density with small-scale dots per inch (SDPI). | +| SCREEN_MDPI | 160 | Screen density with medium-scale dots per inch (MDPI). | +| SCREEN_LDPI | 240 | Screen density with large-scale dots per inch (LDPI). | +| SCREEN_XLDPI | 320 | Screen density with extra-large-scale dots per inch (XLDPI). | +| SCREEN_XXLDPI | 480 | Screen density with extra-extra-large-scale dots per inch (XXLDPI). | +| SCREEN_XXXLDPI | 640 | Screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI).| ## Configuration @@ -170,10 +170,10 @@ Defines the device configuration. **System capability**: SystemCapability.Global.ResourceManager -| Name | Type | Readable | Writable | Description | -| --------- | ----------------------- | -------- | -------- | ------------------------------- | -| direction | [Direction](#direction) | Yes | No | Screen direction of the device. | -| locale | string | Yes | No | Current system language. | +| Name | Type | Readable | Writable | Description | +| --------- | ----------------------- | ---- | ---- | -------- | +| direction | [Direction](#direction) | Yes | No | Screen direction of the device.| +| locale | string | Yes | No | Current system language. | ## DeviceCapability @@ -183,10 +183,10 @@ Defines the device capability. **System capability**: SystemCapability.Global.ResourceManager -| Name | Type | Readable | Writable | Description | -| ------------- | ------------------------------- | -------- | -------- | ----------------------------- | -| screenDensity | [ScreenDensity](#screendensity) | Yes | No | Screen density of the device. | -| deviceType | [DeviceType](#devicetype) | Yes | No | Type of the device. | +| Name | Type | Readable | Writable | Description | +| ------------- | ------------------------------- | ---- | ---- | -------- | +| screenDensity | [ScreenDensity](#screendensity) | Yes | No | Screen density of the device.| +| deviceType | [DeviceType](#devicetype) | Yes | No | Type of the device. | ## RawFileDescriptor8+ @@ -194,11 +194,11 @@ Defines the device capability. Defines the descriptor information of the raw file.
**System capability**: SystemCapability.Global.ResourceManager -| Name | Type | Description | -| ------ | ------ | ---------------------------------------- | -| fd | number | Descriptor of a raw file. | -| offset | number | Offset to the start position of the raw file. | -| length | number | Length of the raw file. | +| Name | Type | Description | +| ------ | ------ | ------------------ | +| fd | number | Descriptor of a raw file.| +| offset | number | Offset to the start position of the raw file. | +| length | number | Length of the raw file. | ## ResourceManager @@ -220,10 +220,10 @@ Obtains the string corresponding to the specified resource ID. This method uses **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | --------- | ---------------------------------------- | -| resId | number | Yes | Resource ID. | -| callback | AsyncCallback<string> | Yes | Callback used to return the string obtained. | +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | --------------- | +| resId | number | Yes | Resource ID. | +| callback | AsyncCallback<string> | Yes | Callback used to return the string obtained.| **Example** ``` @@ -248,14 +248,14 @@ Obtains the string corresponding to the specified resource ID. This method uses **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | --------- | ------------ | -| resId | number | Yes | Resource ID. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resId | number | Yes | Resource ID.| **Return value** -| Type | Description | -| --------------------- | ---------------------------------------- | -| Promise<string> | Promise used to return the string obtained. | +| Type | Description | +| --------------------- | ----------- | +| Promise<string> | Promise used to return the string obtained.| **Example** ``` @@ -278,10 +278,10 @@ Obtains the array of strings corresponding to the specified resource ID. This me **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | ---------------------------------------- | -| resId | number | Yes | Resource ID. | -| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the obtained array of strings. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ----------------- | +| resId | number | Yes | Resource ID. | +| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the obtained array of strings.| **Example** ``` @@ -306,14 +306,14 @@ Obtains the array of strings corresponding to the specified resource ID. This me **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | --------- | ------------ | -| resId | number | Yes | Resource ID. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resId | number | Yes | Resource ID.| **Return value** -| Type | Description | -| ---------------------------------- | ---------------------------------------- | -| Promise<Array<string>> | Promise used to return the array of strings obtained. | +| Type | Description | +| ---------------------------------- | ------------- | +| Promise<Array<string>> | Promise used to return the array of strings obtained.| **Example** ``` @@ -336,10 +336,10 @@ Obtains the content of the media file corresponding to the specified resource ID **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | --------- | ---------------------------------------- | -| resId | number | Yes | Resource ID. | -| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the content of the media file obtained. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------------- | ---- | ------------------ | +| resId | number | Yes | Resource ID. | +| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the content of the media file obtained.| **Example** ``` @@ -364,14 +364,14 @@ Obtains the content of the media file corresponding to the specified resource ID **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | --------- | ------------ | -| resId | number | Yes | Resource ID. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resId | number | Yes | Resource ID.| **Return value** -| Type | Description | -| ------------------------- | ---------------------------------------- | -| Promise<Uint8Array> | Promise used to return the content of the media file obtained. | +| Type | Description | +| ------------------------- | -------------- | +| Promise<Uint8Array> | Promise used to return the content of the media file obtained.| **Example** ``` @@ -394,10 +394,10 @@ Obtains the Base64 code of the image corresponding to the specified resource ID. **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | --------- | ---------------------------------------- | -| resId | number | Yes | Resource ID. | -| callback | AsyncCallback<string> | Yes | Callback used to return the Base64 code of the image obtained. | +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | ------------------------ | +| resId | number | Yes | Resource ID. | +| callback | AsyncCallback<string> | Yes | Callback used to return the Base64 code of the image obtained.| **Example** ``` @@ -422,14 +422,14 @@ Obtains the Base64 code of the image corresponding to the specified resource ID. **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | --------- | ------------ | -| resId | number | Yes | Resource ID. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resId | number | Yes | Resource ID.| **Return value** -| Type | Description | -| --------------------- | ---------------------------------------- | -| Promise<string> | Promise used to return the Base64 code of the image obtained. | +| Type | Description | +| --------------------- | -------------------- | +| Promise<string> | Promise used to return the Base64 code of the image obtained.| **Example** ``` @@ -452,9 +452,9 @@ Obtains the device configuration. This method uses an asynchronous callback to r **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | ---------------------------------------- | -| callback | AsyncCallback<[Configuration](#configuration)> | Yes | Callback used to return the obtained device configuration. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------- | +| callback | AsyncCallback<[Configuration](#configuration)> | Yes | Callback used to return the obtained device configuration.| **Example** ``` @@ -479,9 +479,9 @@ Obtains the device configuration. This method uses a promise to return the resul **System capability**: SystemCapability.Global.ResourceManager **Return value** -| Type | Description | -| ---------------------------------------- | ---------------------------------------- | -| Promise<[Configuration](#configuration)> | Promise used to return the device configuration. | +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise<[Configuration](#configuration)> | Promise used to return the device configuration.| **Example** ``` @@ -504,9 +504,9 @@ Obtains the device capability. This method uses an asynchronous callback to retu **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | ---------------------------------------- | -| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes | Callback used to return the obtained device capability. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ---------------------------- | +| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes | Callback used to return the obtained device capability.| **Example** ``` @@ -531,9 +531,9 @@ Obtains the device capability. This method uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager **Return value** -| Type | Description | -| ---------------------------------------- | ---------------------------------------- | -| Promise<[DeviceCapability](#devicecapability)> | Promise used to return the obtained device capability. | +| Type | Description | +| ---------------------------------------- | ------------------- | +| Promise<[DeviceCapability](#devicecapability)> | Promise used to return the obtained device capability.| **Example** ``` @@ -556,11 +556,11 @@ Obtains the specified number of singular-plural strings corresponding to the spe **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | --------- | ---------------------------------------- | -| resId | number | Yes | Resource ID. | -| num | number | Yes | Number that determines the plural or singular form. | -| callback | AsyncCallback<string> | Yes | Callback used to return the singular-plural string obtained. | +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | ------------------------------- | +| resId | number | Yes | Resource ID. | +| num | number | Yes | Number that determines the plural or singular form. | +| callback | AsyncCallback<string> | Yes | Callback used to return the singular-plural string obtained.| **Example** ``` @@ -585,15 +585,15 @@ Obtains the specified number of singular-plural strings corresponding to the spe **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ----- | ------ | --------- | ---------------------------------------- | -| resId | number | Yes | Resource ID. | -| num | number | Yes | Number that determines the plural or singular form. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resId | number | Yes | Resource ID.| +| num | number | Yes | Number that determines the plural or singular form. | **Return value** -| Type | Description | -| --------------------- | ---------------------------------------- | -| Promise<string> | Promise used to return the singular-plural string obtained. | +| Type | Description | +| --------------------- | ------------------------- | +| Promise<string> | Promise used to return the singular-plural string obtained.| **Example** ``` @@ -615,10 +615,10 @@ Obtains the content of the raw file in the specified path. This method uses an a **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | --------- | ---------------------------------------- | -| path | string | Yes | Path of the raw file. | -| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the raw file content, in byte arrays. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------------- | ---- | ----------------------- | +| path | string | Yes | Path of the raw file. | +| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the raw file content, in byte arrays.| **Example** ``` @@ -642,14 +642,14 @@ Obtains the content of the raw file in the specified path. This method uses a pr **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | --------- | --------------------- | -| path | string | Yes | Path of the raw file. | +| Name | Type | Mandatory | Description | +| ---- | ------ | ---- | ----------- | +| path | string | Yes | Path of the raw file.| **Return value** -| Type | Description | -| ------------------------- | ---------------------------------------- | -| Promise<Uint8Array> | Promise used to return the raw file content, in byte arrays. | +| Type | Description | +| ------------------------- | ----------- | +| Promise<Uint8Array> | Promise used to return the raw file content, in byte arrays.| **Example** ``` @@ -671,10 +671,10 @@ Obtains the descriptor of the raw file in the specified path. This method uses a **System capability**: SystemCapability.Global.ResourceManager **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | ---------------------------------------- | -| path | string | Yes | Path of the raw file. | -| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8+