提交 cf401841 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 0337b2b7
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
- [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md) - [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md)
- [@ohos.file.volumeManager (Volume Management)](js-apis-file-volumemanager.md) - [@ohos.file.volumeManager (Volume Management)](js-apis-file-volumemanager.md)
- [@ohos.filemanagement.userFileManager (User Data Management)](js-apis-userFileManager.md) - [@ohos.filemanagement.userFileManager (User Data Management)](js-apis-userFileManager.md)
- [@ohos.fileShare (File Sharing)](js-apis-fileShare.md) - [@ohos.fileshare (File Sharing)](js-apis-fileShare.md)
- Telephony Service - Telephony Service
- [@ohos.contact (Contacts)](js-apis-contact.md) - [@ohos.contact (Contacts)](js-apis-contact.md)
......
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
The **cloudSyncManager** module provides APIs for changing the cloud and device service status and notifying the data changes. The **cloudSyncManager** module provides APIs for changing the cloud and device service status and notifying the data changes.
> **NOTE** > **NOTE**
>
> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are system APIs and cannot be called by third-party applications. > - The APIs of this module are system APIs and cannot be called by third-party applications.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
...@@ -36,6 +34,15 @@ Changes the device-cloud file synchronization switch for an application. This AP ...@@ -36,6 +34,15 @@ Changes the device-cloud file synchronization switch for an application. This AP
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**Example** **Example**
```js ```js
...@@ -65,6 +72,15 @@ Changes the device-cloud file synchronization switch for an application. This AP ...@@ -65,6 +72,15 @@ Changes the device-cloud file synchronization switch for an application. This AP
| status | boolean | Yes | State of the cloud-device file synchronization switch to set. The value **true** means to enable this function; the value **false** means the opposite.| | status | boolean | Yes | State of the cloud-device file synchronization switch to set. The value **true** means to enable this function; the value **false** means the opposite.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**Example** **Example**
```js ```js
...@@ -78,6 +94,7 @@ Changes the device-cloud file synchronization switch for an application. This AP ...@@ -78,6 +94,7 @@ Changes the device-cloud file synchronization switch for an application. This AP
} }
}); });
``` ```
## cloudSyncManager.notifyDataChange ## cloudSyncManager.notifyDataChange
notifyDataChange(accountId: string, bundleName: string): Promise&lt;void&gt;; notifyDataChange(accountId: string, bundleName: string): Promise&lt;void&gt;;
...@@ -99,6 +116,15 @@ Notifies the cloud and device services of the application data change in the clo ...@@ -99,6 +116,15 @@ Notifies the cloud and device services of the application data change in the clo
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;void&gt; | Promise used to return the application data change in the cloud.| | Promise&lt;void&gt; | Promise used to return the application data change in the cloud.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**Example** **Example**
```js ```js
...@@ -127,6 +153,15 @@ Notifies the cloud and device services of the application data change in the clo ...@@ -127,6 +153,15 @@ Notifies the cloud and device services of the application data change in the clo
| bundleName | string | Yes | Bundle name of the application.| | bundleName | string | Yes | Bundle name of the application.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the application data change in the cloud.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the application data change in the cloud.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**Example** **Example**
```js ```js
......
# @ohos.file.environment (Directory Environment Capability) # @ohos.file.environment (Directory Environment Capability)
The **Environment** module provides APIs for obtaining the root directories of the storage and public files. The **Environment** module provides APIs for obtaining the root directories of the storage and user files.
> **NOTE** > **NOTE**
> >
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are system APIs and cannot be called by third-party applications. > - The APIs of this module are system APIs and cannot be called by third-party applications.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
...@@ -28,6 +27,15 @@ Obtains the root directory of the storage. This API uses a promise to return the ...@@ -28,6 +27,15 @@ Obtains the root directory of the storage. This API uses a promise to return the
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;string&gt; | Promise used to return the root directory of the storage.| | Promise&lt;string&gt; | Promise used to return the root directory of the storage.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 202 | The caller is not a system application |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
...@@ -52,6 +60,15 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac ...@@ -52,6 +60,15 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac
| -------- | --------------------------- | ---- | -------------------------------- | | -------- | --------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Asynchronous callback invoked to return the root directory of the storage.| | callback | AsyncCallback&lt;string&gt; | Yes | Asynchronous callback invoked to return the root directory of the storage.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 202 | The caller is not a system application |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
...@@ -68,7 +85,7 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac ...@@ -68,7 +85,7 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac
getUserDataDir():Promise&lt;string&gt; getUserDataDir():Promise&lt;string&gt;
Obtains the root directory of public files. This API uses a promise to return the result. Obtains the root directory of user files. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.Environment **System capability**: SystemCapability.FileManagement.File.Environment
...@@ -76,7 +93,16 @@ Obtains the root directory of public files. This API uses a promise to return th ...@@ -76,7 +93,16 @@ Obtains the root directory of public files. This API uses a promise to return th
| Type | Description | | Type | Description |
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;string&gt; | Promise returned with the root directory of public files.| | Promise&lt;string&gt; | Promise used to return the root directory of user files.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 202 | The caller is not a system application |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
...@@ -92,7 +118,7 @@ Obtains the root directory of public files. This API uses a promise to return th ...@@ -92,7 +118,7 @@ Obtains the root directory of public files. This API uses a promise to return th
getUserDataDir(callback:AsyncCallback&lt;string&gt;): void getUserDataDir(callback:AsyncCallback&lt;string&gt;): void
Obtains the root directory of public files. This API uses an asynchronous callback to return the result. Obtains the root directory of user files. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.File.Environment **System capability**: SystemCapability.FileManagement.File.Environment
...@@ -100,7 +126,16 @@ Obtains the root directory of public files. This API uses an asynchronous callba ...@@ -100,7 +126,16 @@ Obtains the root directory of public files. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------- | | -------- | --------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Asynchronous callback used to return the root directory of public files.| | callback | AsyncCallback&lt;string&gt; | Yes | Asynchronous callback used to return the root directory of user files.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 202 | The caller is not a system application |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
......
...@@ -41,9 +41,9 @@ Obtains the URI of a file in synchronous mode. ...@@ -41,9 +41,9 @@ Obtains the URI of a file in synchronous mode.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| string | File URI obtained.| | string | File URI obtained.|
**Error codes** **Error codes**
...@@ -52,7 +52,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod ...@@ -52,7 +52,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| 401 | The input parameter is invalid | | 401 | The input parameter is invalid |
**Example** **Example**
```js ```js
......
...@@ -14,7 +14,7 @@ import fs from '@ohos.file.fs'; ...@@ -14,7 +14,7 @@ import fs from '@ohos.file.fs';
## Guidelines ## Guidelines
Before using the APIs provided by this module to perform operations on a file or folder, obtain the application sandbox path of the file or folder as follows: Before using the APIs provided by this module to perform operations on a file or directory, obtain the application sandbox path of the file or directory as follows:
**Stage Model** **Stage Model**
...@@ -29,7 +29,7 @@ export default class EntryAbility extends UIAbility { ...@@ -29,7 +29,7 @@ export default class EntryAbility extends UIAbility {
} }
``` ```
**FA Model** FA Model
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
...@@ -58,13 +58,13 @@ Obtains detailed file information. This API uses a promise to return the result. ...@@ -58,13 +58,13 @@ Obtains detailed file information. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise used to return the file information obtained.| | Promise&lt;[Stat](#stat)&gt; | Promise used to return the file information obtained.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -94,7 +94,7 @@ Obtains detailed file information. This API uses an asynchronous callback to ret ...@@ -94,7 +94,7 @@ Obtains detailed file information. This API uses an asynchronous callback to ret
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -120,17 +120,17 @@ Obtains detailed file information synchronously. ...@@ -120,17 +120,17 @@ Obtains detailed file information synchronously.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------- | | ------ | ------ | ---- | -------------------------- |
| file | string\|number | Yes | Application sandbox path or FD of the file.| | file | string\|number | Yes | Application sandbox path or file descriptor (FD) of the file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------- | ---------- | | ------------- | ---------- |
| [Stat](#stat) | File information obtained.| | [Stat](#stat) | File information obtained.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -155,13 +155,13 @@ Checks whether a file exists. This API uses a promise to return the result. ...@@ -155,13 +155,13 @@ Checks whether a file exists. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means the file exists; the value **false** means the opposite.| | Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means the file exists; the value **false** means the opposite.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -193,7 +193,7 @@ Checks whether a file exists. This API uses an asynchronous callback to return t ...@@ -193,7 +193,7 @@ Checks whether a file exists. This API uses an asynchronous callback to return t
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -226,13 +226,13 @@ Synchronously checks whether a file exists. ...@@ -226,13 +226,13 @@ Synchronously checks whether a file exists.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| boolean | Returns **true** if the file exists; returns **false** otherwise.| | boolean | Returns **true** if the file exists; returns **false** otherwise.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -259,19 +259,19 @@ Closes a file. This API uses a promise to return the result. ...@@ -259,19 +259,19 @@ Closes a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| file | [File](#file)\|number | Yes | File object or FD of the file to close.| | file | [File](#file)\|number | Yes | File object or FD of the file to close.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -296,14 +296,14 @@ Closes a file. This API uses an asynchronous callback to return the result. ...@@ -296,14 +296,14 @@ Closes a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------ | | -------- | ------------------------- | ---- | ------------ |
| file | [File](#file)\|number | Yes | File object or FD of the file to close.| | file | [File](#file)\|number | Yes | File object or FD of the file to close.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is closed asynchronously.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked immediately after the file is closed.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -329,13 +329,13 @@ Synchronously closes a file. ...@@ -329,13 +329,13 @@ Synchronously closes a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| file | [File](#file)\|number | Yes | File object or FD of the file to close.| | file | [File](#file)\|number | Yes | File object or FD of the file to close.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -355,21 +355,21 @@ Copies a file. This API uses a promise to return the result. ...@@ -355,21 +355,21 @@ Copies a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | -------------------------- | ---- | ---------------------------------------- | | ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or FD of the file to copy. | | src | string\|number | Yes | Path or FD of the file to copy. |
| dest | string\|number | Yes | Destination path of the file or FD of the file created. | | dest | string\|number | Yes | Destination path of the file or FD of the file created. |
| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file of the same name.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -393,16 +393,16 @@ Copies a file. This API uses an asynchronous callback to return the result. ...@@ -393,16 +393,16 @@ Copies a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ---------------------------------------- | | -------- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or FD of the file to copy. | | src | string\|number | Yes | Path or FD of the file to copy. |
| dest | string\|number | Yes | Destination path of the file or FD of the file created. | | dest | string\|number | Yes | Destination path of the file or FD of the file created. |
| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is copied asynchronously. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked immediately after the file is copied. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -429,15 +429,15 @@ Synchronously copies a file. ...@@ -429,15 +429,15 @@ Synchronously copies a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | -------------------------- | ---- | ---------------------------------------- | | ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or FD of the file to copy. | | src | string\|number | Yes | Path or FD of the file to copy. |
| dest | string\|number | Yes | Destination path of the file or FD of the file created. | | dest | string\|number | Yes | Destination path of the file or FD of the file created. |
| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -447,6 +447,93 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -447,6 +447,93 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
fs.copyFileSync(srcPath, dstPath); fs.copyFileSync(srcPath, dstPath);
``` ```
## fs.copyDir<sup>10+</sup>
copyDir(src: string, dest: string, mode?: number): Promise\<void>
Copies a directory to the specified directory. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Application sandbox path of the directory to copy.|
| dest | string | Yes | Application sandbox path of the destination directory.|
| mode | number | No | Copy mode. The default value is **0**.<br>- **0**: Throw an exception if a file conflict occurs.<br> Throw an exception if there is a directory with the same name in the destination directory and files with the same name exist in the conflicting directory. All the non-conflicting files in the source directory will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. The **data** attribute in the error returned provides information about the conflicting files in the Array\<[ConflictFiles](#conflictfiles)> format.<br>- **1**: Forcibly overwrite the files with the same name in the destination directory.<br> If there is a directory with the same name in the destination directory and files with the same name exist in the conflicting directory, all the files with the same name in the destination directory will be overwritten and the non-conflicting files will be retained.|
**Return value**
| Type | Description |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example**
```js
// Copy srcPath to destPath.
let srcPath = pathDir + "/srcDir/";
let destPath = pathDir + "/destDir/";
fs.copyDir(srcPath, destPath, 0).then(() => {
console.info("copy directory succeed");
}).catch((err) => {
if (err.code == 13900015) {
for (let i = 0; i < err.data.length; i++) {
console.info("copy directory failed with conflicting files: " + err.data[i].srcFile +
" " + err.data[i].destFile);
}
} else {
console.info("copy directory failed with error message: " + err.message + ", error code: " + err.code);
}
});
```
## fs.copyDir<sup>10+</sup>
copyDir(src: string, dest: string, mode?: number, callback: AsyncCallback\<void>): void
Copies a directory to the specified directory. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Application sandbox path of the directory to copy.|
| dest | string | Yes | Application sandbox path of the destination directory.|
| mode | number | No | Copy mode. The default value is **0**.<br>- **0**: Throw an exception if a file conflict occurs.<br> Throw an exception if there is a directory with the same name in the destination directory and files with the same name exist in the conflicting directory. All the non-conflicting files in the source directory will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. The **data** attribute in the error returned provides information about the conflicting files in the Array\<[ConflictFiles](#conflictfiles)> format.<br>- **1**: Forcibly overwrite the files with the same name in the destination directory.<br> If there is a directory with the same name in the destination directory and files with the same name exist in the conflicting directory, all the files with the same name in the destination directory will be overwritten and the non-conflicting files will be retained.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked immediately after the directory is copied. |
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example**
```js
// Copy srcPath to destPath.
let srcPath = pathDir + "/srcDir/";
let destPath = pathDir + "/destDir/";
fs.copyDir(srcPath, destPath, 0, (err) => {
if (err && err.code == 13900015) {
for (let i = 0; i < err.data.length; i++) {
console.info("copy directory failed with conflicting files: " + err.data[i].srcFile +
" " + err.data[i].destFile);
}
} else if (err) {
console.info("copy directory failed with error message: " + err.message + ", error code: " + err.code);
} else {
console.info("copy directory succeed");
}
});
```
## fs.mkdir ## fs.mkdir
mkdir(path: string): Promise&lt;void&gt; mkdir(path: string): Promise&lt;void&gt;
...@@ -463,13 +550,13 @@ Creates a directory. This API uses a promise to return the result. ...@@ -463,13 +550,13 @@ Creates a directory. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -499,7 +586,7 @@ Creates a directory. This API uses an asynchronous callback to return the result ...@@ -499,7 +586,7 @@ Creates a directory. This API uses an asynchronous callback to return the result
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -530,7 +617,7 @@ Synchronously creates a directory. ...@@ -530,7 +617,7 @@ Synchronously creates a directory.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -556,13 +643,13 @@ Opens a file. This API uses a promise to return the result. File uniform resourc ...@@ -556,13 +643,13 @@ Opens a file. This API uses a promise to return the result. File uniform resourc
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ----------- | | --------------------- | ----------- |
| Promise&lt;[File](#file)&gt; | Promise used to return the file object.| | Promise&lt;[File](#file)&gt; | Promise used to return the file object.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -593,7 +680,7 @@ Opens a file. This API uses an asynchronous callback to return the result. File ...@@ -593,7 +680,7 @@ Opens a file. This API uses an asynchronous callback to return the result. File
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -625,13 +712,13 @@ Synchronously opens a file. File URIs are supported. ...@@ -625,13 +712,13 @@ Synchronously opens a file. File URIs are supported.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ----------- | | ------ | ----------- |
| [File](#file) | File object opened.| | [File](#file) | File object opened.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -660,13 +747,13 @@ Reads data from a file. This API uses a promise to return the result. ...@@ -660,13 +747,13 @@ Reads data from a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;number&gt; | Promise used to return the data read.| | Promise&lt;number&gt; | Promise used to return the data read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -693,16 +780,16 @@ Reads data from a file. This API uses an asynchronous callback to return the res ...@@ -693,16 +780,16 @@ Reads data from a file. This API uses an asynchronous callback to return the res
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is read asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is read asynchronously. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -731,21 +818,21 @@ Synchronously reads data from a file. ...@@ -731,21 +818,21 @@ Synchronously reads data from a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data read.| | number | Length of the data read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -773,13 +860,13 @@ Deletes a directory. This API uses a promise to return the result. ...@@ -773,13 +860,13 @@ Deletes a directory. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -809,7 +896,7 @@ Deletes a directory. This API uses an asynchronous callback to return the result ...@@ -809,7 +896,7 @@ Deletes a directory. This API uses an asynchronous callback to return the result
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -840,7 +927,7 @@ Synchronously deletes a directory. ...@@ -840,7 +927,7 @@ Synchronously deletes a directory.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -865,13 +952,13 @@ Deletes a file. This API uses a promise to return the result. ...@@ -865,13 +952,13 @@ Deletes a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -897,11 +984,11 @@ Deletes a file. This API uses an asynchronous callback to return the result. ...@@ -897,11 +984,11 @@ Deletes a file. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------------- | | -------- | ------------------------- | ---- | -------------------------- |
| path | string | Yes | Application sandbox path of the file.| | path | string | Yes | Application sandbox path of the file.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is deleted asynchronously. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked immediately after the file is deleted. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -932,7 +1019,7 @@ Synchronously deletes a file. ...@@ -932,7 +1019,7 @@ Synchronously deletes a file.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -952,21 +1039,21 @@ Writes data into a file. This API uses a promise to return the result. ...@@ -952,21 +1039,21 @@ Writes data into a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------- | | --------------------- | -------- |
| Promise&lt;number&gt; | Promise used to return the length of the data written.| | Promise&lt;number&gt; | Promise used to return the length of the data written.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -991,16 +1078,16 @@ Writes data into a file. This API uses an asynchronous callback to return the re ...@@ -991,16 +1078,16 @@ Writes data into a file. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ---------------------------------------- | | -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1027,21 +1114,21 @@ Synchronously writes data into a file. ...@@ -1027,21 +1114,21 @@ Synchronously writes data into a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data written in the file.| | number | Length of the data written in the file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1070,13 +1157,13 @@ Truncates a file. This API uses a promise to return the result. ...@@ -1070,13 +1157,13 @@ Truncates a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1108,7 +1195,7 @@ Truncates a file. This API uses an asynchronous callback to return the result. ...@@ -1108,7 +1195,7 @@ Truncates a file. This API uses an asynchronous callback to return the result.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1141,7 +1228,7 @@ Synchronously truncates a file. ...@@ -1141,7 +1228,7 @@ Synchronously truncates a file.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1168,13 +1255,13 @@ Reads the text content of a file. This API uses a promise to return the result. ...@@ -1168,13 +1255,13 @@ Reads the text content of a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string&gt; | Promise used to return the content read.| | Promise&lt;string&gt; | Promise used to return the content read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1205,7 +1292,7 @@ Reads the text content of a file. This API uses an asynchronous callback to retu ...@@ -1205,7 +1292,7 @@ Reads the text content of a file. This API uses an asynchronous callback to retu
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1237,13 +1324,13 @@ Synchronously reads the text of a file. ...@@ -1237,13 +1324,13 @@ Synchronously reads the text of a file.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------------------- | | ------ | -------------------- |
| string | Promise used to return the content of the file read.| | string | Promise used to return the content of the file read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1269,13 +1356,13 @@ Obtains information about a symbolic link. This API uses a promise to return the ...@@ -1269,13 +1356,13 @@ Obtains information about a symbolic link. This API uses a promise to return the
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise used to return the symbolic link information obtained. For details, see **stat**.| | Promise&lt;[Stat](#stat)&gt; | Promise used to return the symbolic link information obtained. For details, see **stat**.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1305,7 +1392,7 @@ Obtains information about a symbolic link. This API uses an asynchronous callbac ...@@ -1305,7 +1392,7 @@ Obtains information about a symbolic link. This API uses an asynchronous callbac
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1336,13 +1423,13 @@ Obtains information about a symbolic link synchronously. ...@@ -1336,13 +1423,13 @@ Obtains information about a symbolic link synchronously.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------- | ---------- | | ------------- | ---------- |
| [Stat](#stat) | File information obtained.| | [Stat](#stat) | File information obtained.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1368,13 +1455,13 @@ Renames a file or folder. This API uses a promise to return the result. ...@@ -1368,13 +1455,13 @@ Renames a file or folder. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1406,7 +1493,7 @@ Renames a file or folder. This API uses an asynchronous callback to return the r ...@@ -1406,7 +1493,7 @@ Renames a file or folder. This API uses an asynchronous callback to return the r
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1439,7 +1526,7 @@ Renames a file or folder synchronously. ...@@ -1439,7 +1526,7 @@ Renames a file or folder synchronously.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1459,19 +1546,19 @@ Flushes data of a file to disk. This API uses a promise to return the result. ...@@ -1459,19 +1546,19 @@ Flushes data of a file to disk. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1495,14 +1582,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return ...@@ -1495,14 +1582,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | --------------- | | -------- | ------------------------- | ---- | --------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| Callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| | Callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1530,13 +1617,13 @@ Flushes data of a file to disk synchronously. ...@@ -1530,13 +1617,13 @@ Flushes data of a file to disk synchronously.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1557,19 +1644,19 @@ Flushes data of a file to disk. This API uses a promise to return the result. ** ...@@ -1557,19 +1644,19 @@ Flushes data of a file to disk. This API uses a promise to return the result. **
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1594,14 +1681,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return ...@@ -1594,14 +1681,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ----------------- | | -------- | ------------------------------- | ---- | ----------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1628,13 +1715,13 @@ Synchronizes data in a file synchronously. ...@@ -1628,13 +1715,13 @@ Synchronizes data in a file synchronously.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1662,13 +1749,13 @@ Creates a symbolic link based on a file path. This API uses a promise to return ...@@ -1662,13 +1749,13 @@ Creates a symbolic link based on a file path. This API uses a promise to return
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1700,7 +1787,7 @@ Creates a symbolic link based on a file path. This API uses an asynchronous call ...@@ -1700,7 +1787,7 @@ Creates a symbolic link based on a file path. This API uses an asynchronous call
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1733,7 +1820,7 @@ Synchronously creates a symbolic link based on a file path. ...@@ -1733,7 +1820,7 @@ Synchronously creates a symbolic link based on a file path.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1750,34 +1837,34 @@ listFile(path: string, options?: { ...@@ -1750,34 +1837,34 @@ listFile(path: string, options?: {
filter?: Filter; filter?: Filter;
}): Promise<string[]> }): Promise<string[]>
Lists all files in a directory. This API uses a promise to return the result.<br>This API supports recursive listing of all files (including files in subdirectories) and file filtering. Lists all files in a folder. This API uses a promise to return the result.<br>This API supports recursive listing of all files (including files in subfolders) and file filtering.
**System capability**: SystemCapability.FileManagement.File.FileIO **System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| path | string | Yes | Application sandbox path of the folder.| | path | string | Yes | Application sandbox path of the folder.|
| options | Object | No | File filtering options. The files are not filtered by default.| | options | Object | No | File filtering options. The files are not filtered by default.|
**options parameters** **options parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| | recursion | boolean | No | Whether to list all files in subfolders recursively. The default value is **false**.|
| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| | listNum | number | No | Number of file names to list. The default value **0** means to list all files.|
| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string[]&gt; | Promise used to return the files names listed.| | Promise&lt;string[]&gt; | Promise used to return the files names listed.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1809,27 +1896,27 @@ listFile(path: string, options?: { ...@@ -1809,27 +1896,27 @@ listFile(path: string, options?: {
filter?: Filter; filter?: Filter;
}, callback: AsyncCallback<string[]>): void }, callback: AsyncCallback<string[]>): void
Lists all files in a directory. This API uses an asynchronous callback to return the result.<br>This API supports recursive listing of all files (including files in subdirectories) and file filtering. Lists all files in a folder. This API uses an asynchronous callback to return the result.<br>This API supports recursive listing of all files (including files in subfolders) and file filtering.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| path | string | Yes | Application sandbox path of the folder.| | path | string | Yes | Application sandbox path of the folder.|
| options | Object | No | File filtering options. The files are not filtered by default.| | options | Object | No | File filtering options. The files are not filtered by default.|
| callback | AsyncCallback&lt;string[]&gt; | Yes | Callback invoked to return the file names listed. | | callback | AsyncCallback&lt;string[]&gt; | Yes | Callback invoked to return the file names listed. |
**options parameters** **options parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| | recursion | boolean | No | Whether to list all files in subfolders recursively. The default value is **false**.|
| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| | listNum | number | No | Number of file names to list. The default value **0** means to list all files.|
| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1864,32 +1951,32 @@ listFileSync(path: string, options?: { ...@@ -1864,32 +1951,32 @@ listFileSync(path: string, options?: {
filter?: Filter; filter?: Filter;
}): string[] }): string[]
Lists all files in a directory synchronously. This API supports recursive listing of all files (including files in subdirectories) and file filtering. Lists all files in a folder synchronously. This API supports recursive listing of all files (including files in subfolders) and file filtering.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| path | string | Yes | Application sandbox path of the folder.| | path | string | Yes | Application sandbox path of the folder.|
| options | Object | No | File filtering options. The files are not filtered by default.| | options | Object | No | File filtering options. The files are not filtered by default.|
**options parameters** **options parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| | recursion | boolean | No | Whether to list all files in subfolders recursively. The default value is **false**.|
| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| | listNum | number | No | Number of file names to list. The default value **0** means to list all files.|
| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| string[] | File names listed.| | string[] | File names listed.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1915,32 +2002,32 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -1915,32 +2002,32 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
moveDir(src: string, dest: string, mode?: number): Promise\<void> moveDir(src: string, dest: string, mode?: number): Promise\<void>
Moves a folder. This API uses a promise to return the result. Moves a directory. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO **System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Application sandbox path of the source folder.| | src | string | Yes | Application sandbox path of the directory to move.|
| dest | string | Yes | Application sandbox path of the destination folder.| | dest | string | Yes | Application sandbox path of the destination directory.|
| mode | number | No | Mode for moving the folder. The default value is **0**.<br>- **0**: Throw an exception if the destination directory has folders of the same names with the source folder.<br>- **1**: Throw an exception if the destination directory has files of the same names with the source folder. All files without conflicts in the source folder are moved to the destination folder, and all files without conflicts in the destination folder are retained. The **data** in the error thrown provides information about the conflict files.<br>- **2**: Forcibly overwrite the files with the same names in the destination folder. The files with the the same names in the destination folder are overwritten forcibly; the files without conflicts in the destination folder are retained.<br>- **3**: Forcibly overwrite the destination folder. Move the source folder to the destination directory and make the destination folder completely the same as the source folder. All the original files in the destination folder are not retained.| | mode | number | No | Mode for moving the directory. The default value is **0**.<br>- **0**: Throw an exception if a directory conflict occurs.<br> Throw an exception if there is a directory with the same name in the destination directory.<br>- **1**: Throw an exception if a file conflict occurs.<br> Throw an exception if there is a directory with the same name in the destination directory and files with the same name exist in the conflicting directory. All the non-conflicting files in the source directory will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. The **data** attribute in the error returned provides information about the conflicting files in the Array\<[ConflictFiles](#conflictfiles)> format.<br>- **2**: Forcibly overwrite the conflicting files in the destination directory.<br> If there is a directory with the same name in the destination directory and files with the same name exist in the conflicting directory, all the files with the same name in the destination directory will be overwritten and the non-conflicting files will be retained.<br>- **3**: Forcibly overwrite the conflicting directory.<br> Move the source directory to the destination directory and overwrite the conflicting directory completely. That is, if there is a directory with the same name in the destination directory, all the original files in that directory will not be retained.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
```js ```js
// move directory from srcPath to destPath/srcPath // move directory from srcPath to destPath
let srcPath = pathDir + "/srcDir/"; let srcPath = pathDir + "/srcDir/";
let destPath = pathDir + "/destDir/"; let destPath = pathDir + "/destDir/";
fs.moveDir(srcPath, destPath, 1).then(() => { fs.moveDir(srcPath, destPath, 1).then(() => {
...@@ -1961,27 +2048,27 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -1961,27 +2048,27 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
moveDir(src: string, dest: string, mode?: number, callback: AsyncCallback\<void>): void moveDir(src: string, dest: string, mode?: number, callback: AsyncCallback\<void>): void
Moves a folder. This API uses an asynchronous callback to return the result. Moves a directory. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO **System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Application sandbox path of the source folder.| | src | string | Yes | Application sandbox path of the source directory.|
| dest | string | Yes | Application sandbox path of the destination folder.| | dest | string | Yes | Application sandbox path of the destination directory.|
| mode | number | No | Mode for moving the folder. The default value is **0**.<br>- **0**: Throw an exception if the destination directory has folders of the same names with the source folder.<br>- **1**: Throw an exception if the destination directory has files of the same names with the source folder. All files without conflicts in the source folder are moved to the destination folder, and all files without conflicts in the destination folder are retained. The **data** in the error thrown provides information about the conflict files.<br>- **2**: Forcibly overwrite the files with the same names in the destination folder. The files with the the same names in the destination folder are overwritten forcibly; the files without conflicts in the destination folder are retained.<br>- **3**: Forcibly overwrite the destination folder. Move the source folder to the destination directory and make the destination folder completely the same as the source folder. All the original files in the destination folder are not retained.| | mode | number | No | Mode for moving the directory. The default value is **0**.<br>- **0**: Throw an exception if a directory conflict occurs.<br> Throw an exception if there is a directory with the same name in the destination directory.<br>- **1**: Throw an exception if a file conflict occurs.<br> Throw an exception if there is a directory with the same name in the destination directory and files with the same name exist in the conflicting directory. All the non-conflicting files in the source directory will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. The **data** attribute in the error returned provides information about the conflicting files in the Array\<[ConflictFiles](#conflictfiles)> format.<br>- **2**: Forcibly overwrite the conflicting files in the destination directory.<br> If there is a directory with the same name in the destination directory and files with the same name exist in the conflicting directory, all the files with the same name in the destination directory will be overwritten and the non-conflicting files will be retained.<br>- **3**: Forcibly overwrite the conflicting directory.<br> Move the source directory to the destination directory and overwrite the conflicting directory completely. That is, if there is a directory with the same name in the destination directory, all the original files in that directory will not be retained.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the folder is moved. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the directory is moved. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
```js ```js
// move directory from srcPath to destPath/srcPath // move directory from srcPath to destPath
let srcPath = pathDir + "/srcDir/"; let srcPath = pathDir + "/srcDir/";
let destPath = pathDir + "/destDir/"; let destPath = pathDir + "/destDir/";
fs.moveDir(srcPath, destPath, 1, (err) => { fs.moveDir(srcPath, destPath, 1, (err) => {
...@@ -2008,21 +2095,21 @@ Moves a file. This API uses a promise to return the result. ...@@ -2008,21 +2095,21 @@ Moves a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Application sandbox path of the source file.| | src | string | Yes | Application sandbox path of the source file.|
| dest | string | Yes | Application sandbox path of the destination file.| | dest | string | Yes | Application sandbox path of the destination file.|
| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory.<br>The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception.<br>The default value is **0**.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2046,16 +2133,16 @@ Moves a file. This API uses an asynchronous callback to return the result. ...@@ -2046,16 +2133,16 @@ Moves a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Application sandbox path of the source file.| | src | string | Yes | Application sandbox path of the source file.|
| dest | string | Yes | Application sandbox path of the destination file.| | dest | string | Yes | Application sandbox path of the destination file.|
| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory.<br>The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception. <br>The default value is **0**.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is moved. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is moved. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2081,15 +2168,15 @@ Moves a file synchronously. ...@@ -2081,15 +2168,15 @@ Moves a file synchronously.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Application sandbox path of the source file.| | src | string | Yes | Application sandbox path of the source file.|
| dest | string | Yes | Application sandbox path of the destination file.| | dest | string | Yes | Application sandbox path of the destination file.|
| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory.<br>The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception. <br>The default value is **0**.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2110,19 +2197,19 @@ Creates a temporary directory. This API uses a promise to return the result. ...@@ -2110,19 +2197,19 @@ Creates a temporary directory. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string&gt; | Promise used to return the unique directory generated.| | Promise&lt;string&gt; | Promise used to return the unique directory generated.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2144,14 +2231,14 @@ Creates a temporary directory. This API uses an asynchronous callback to return ...@@ -2144,14 +2231,14 @@ Creates a temporary directory. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | --------------------------- | | -------- | --------------------------- | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked when a temporary directory is created asynchronously. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked when a temporary directory is created asynchronously. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2175,25 +2262,25 @@ Synchronously creates a temporary directory. ...@@ -2175,25 +2262,25 @@ Synchronously creates a temporary directory.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ---------- | | ------ | ---------- |
| string | Unique path generated.| | string | Unique path generated.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
```js ```js
let res = fs.mkdtempSync(pathDir + "/XXXXXX"); let res = fs.mkdtempSync(pathDir + "/XXXXXX");
``` ```
## fs.createStream ## fs.createStream
...@@ -2212,13 +2299,13 @@ Creates a stream based on the file path. This API uses a promise to return the r ...@@ -2212,13 +2299,13 @@ Creates a stream based on the file path. This API uses a promise to return the r
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------- | --------- | | --------------------------------- | --------- |
| Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.| | Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2250,7 +2337,7 @@ Creates a stream based on the file path. This API uses an asynchronous callback ...@@ -2250,7 +2337,7 @@ Creates a stream based on the file path. This API uses an asynchronous callback
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2282,13 +2369,13 @@ Synchronously creates a stream based on the file path. ...@@ -2282,13 +2369,13 @@ Synchronously creates a stream based on the file path.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | --------- | | ------------------ | --------- |
| [Stream](#stream) | Stream opened.| | [Stream](#stream) | Stream opened.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2302,26 +2389,26 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -2302,26 +2389,26 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
fdopenStream(fd: number, mode: string): Promise&lt;Stream&gt; fdopenStream(fd: number, mode: string): Promise&lt;Stream&gt;
Opens a stream based on the FD. This API uses a promise to return the result. Opens a stream based on the file descriptor. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO **System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------- | --------- | | --------------------------------- | --------- |
| Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.| | Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2340,21 +2427,21 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -2340,21 +2427,21 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
fdopenStream(fd: number, mode: string, callback: AsyncCallback&lt;Stream&gt;): void fdopenStream(fd: number, mode: string, callback: AsyncCallback&lt;Stream&gt;): void
Opens a stream based on the FD. This API uses an asynchronous callback to return the result. Opens a stream based on the file descriptor. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO **System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
| callback | AsyncCallback&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is open asynchronously. | | callback | AsyncCallback&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is opened. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2375,26 +2462,26 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -2375,26 +2462,26 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
fdopenStreamSync(fd: number, mode: string): Stream fdopenStreamSync(fd: number, mode: string): Stream
Synchronously opens a stream based on the FD. Synchronously opens a stream based on the file descriptor.
**System capability**: SystemCapability.FileManagement.File.FileIO **System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | --------- | | ------------------ | --------- |
| [Stream](#stream) | Stream opened.| | [Stream](#stream) | Stream opened.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2417,21 +2504,21 @@ Creates a **Watcher** object to observe file or directory changes. ...@@ -2417,21 +2504,21 @@ Creates a **Watcher** object to observe file or directory changes.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| path | string | Yes | Application sandbox path of the file or directory to observe. | | path | string | Yes | Application sandbox path of the file or directory to observe. |
| events | number | Yes | Events to observe. Multiple events can be separated by a bitwise OR operator (&#124;)|.<br>- **0x1: IN_ACCESS**: A file is accessed.<br>- **0x2: IN_MODIFY**: The file content is modified.<br>- **0x4: IN_ATTRIB**: Metadata is changed.<br>- **0x8: IN_CLOSE_WRITE**: The file opened for writing is closed.<br>- **0x10: IN_CLOSE_NOWRITE**: The file or directory not opened for writing is closed.<br>- **0x20: IN_OPEN**: A file or directory is opened.<br>- **0x40: IN_MOVED_FROM**: A file in the observed directory is moved.<br>- **0x80: IN_MOVED_TO**: A file is moved to the observed directory.<br>- **0x100: IN_CREATE**: A file or directory is created in the observed directory.<br>- **0x200: IN_DELETE**: A file or directory is deleted from the observed directory.<br>- **0x400: IN_DELETE_SELF**: The observed directory is deleted. After the directory is deleted, the listening stops.<br>- **0x800: IN_MOVE_SELF**: The observed file or directory is moved. After the file or directory is moved, the listening continues.<br>- **0xfff: IN_ALL_EVENTS**: All events.| | events | number | Yes | Events to observe. Multiple events can be separated by a bitwise OR operator (&#124;)|.<br>- **0x1: IN_ACCESS**: A file is accessed.<br>- **0x2: IN_MODIFY**: The file content is modified.<br>- **0x4: IN_ATTRIB**: Metadata is changed.<br>- **0x8: IN_CLOSE_WRITE**: The file opened for writing is closed.<br>- **0x10: IN_CLOSE_NOWRITE**: The file or directory not opened for writing is closed.<br>- **0x20: IN_OPEN**: A file or directory is opened.<br>- **0x40: IN_MOVED_FROM**: A file in the observed directory is moved.<br>- **0x80: IN_MOVED_TO**: A file is moved to the observed directory.<br>- **0x100: IN_CREATE**: A file or directory is created in the observed directory.<br>- **0x200: IN_DELETE**: A file or directory is deleted from the observed directory.<br>- **0x400: IN_DELETE_SELF**: The observed directory is deleted. After the directory is deleted, the listening stops.<br>- **0x800: IN_MOVE_SELF**: The observed file or directory is moved. After the file or directory is moved, the listening continues.<br>- **0xfff: IN_ALL_EVENTS**: All events.|
| listener | WatchEventListener | Yes | Callback invoked when an observed event occurs. The callback will be invoked each time an observed event occurs. | | listener | WatchEventListener | Yes | Callback invoked when an observed event occurs. The callback will be invoked each time an observed event occurs. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | --------- | | ------------------ | --------- |
| [Watcher](#watcher10) | **Watcher** object created.| | [Watcher](#watcher10) | **Watcher** object created.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2463,10 +2550,10 @@ Called when an observed event occurs. ...@@ -2463,10 +2550,10 @@ Called when an observed event occurs.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| event | WatchEvent | Yes | Event for the callback to invoke. | | event | WatchEvent | Yes | Event for the callback to invoke. |
## WatchEvent<sup>10+</sup> ## WatchEvent<sup>10+</sup>
Defines the event to observe. Defines the event to observe.
...@@ -2490,7 +2577,7 @@ Represents detailed file information. Before calling any API of the **Stat()** c ...@@ -2490,7 +2577,7 @@ Represents detailed file information. Before calling any API of the **Stat()** c
### Attributes ### Attributes
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| ------ | ------ | ---- | ---- | ---------------------------------------- | | ------ | ------ | ---- | ---- | ---------------------------------------- |
| ino | number | Yes | No | File ID. Different files on the same device have different **ino**s.| | | ino | number | Yes | No | File ID. Different files on the same device have different **ino**s.| |
| mode | number | Yes | No | File permissions. The meaning of each bit is as follows:<br>- **0o400**: The owner has the read permission on a regular file or a directory entry.<br>- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.<br>- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o040**: The user group has the read permission on a regular file or a directory entry.<br>- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.<br>- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o004**: Other users have the permission to read a regular file or read a directory entry.<br>- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.<br>- **0o001**: Other users have the permission to execute a regular file or search for the specified path in a directory.| | mode | number | Yes | No | File permissions. The meaning of each bit is as follows:<br>- **0o400**: The owner has the read permission on a regular file or a directory entry.<br>- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.<br>- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o040**: The user group has the read permission on a regular file or a directory entry.<br>- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.<br>- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o004**: Other users have the permission to read a regular file or read a directory entry.<br>- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.<br>- **0o001**: Other users have the permission to execute a regular file or search for the specified path in a directory.|
| uid | number | Yes | No | ID of the file owner.| | uid | number | Yes | No | ID of the file owner.|
...@@ -2510,13 +2597,13 @@ Checks whether this file is a block special file. A block special file supports ...@@ -2510,13 +2597,13 @@ Checks whether this file is a block special file. A block special file supports
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ---------------- | | ------- | ---------------- |
| boolean | Whether the file is a block special file.| | boolean | Whether the file is a block special file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2535,13 +2622,13 @@ Checks whether this file is a character special file. A character special file s ...@@ -2535,13 +2622,13 @@ Checks whether this file is a character special file. A character special file s
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------- | | ------- | ----------------- |
| boolean | Whether the file is a character special file.| | boolean | Whether the file is a character special file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2560,13 +2647,13 @@ Checks whether this file is a directory. ...@@ -2560,13 +2647,13 @@ Checks whether this file is a directory.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------- | | ------- | ------------- |
| boolean | Whether the file is a directory.| | boolean | Whether the file is a directory.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2585,13 +2672,13 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int ...@@ -2585,13 +2672,13 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------- | | ------- | --------------------- |
| boolean | Whether the file is a FIFO.| | boolean | Whether the file is a FIFO.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2610,13 +2697,13 @@ Checks whether this file is a regular file. ...@@ -2610,13 +2697,13 @@ Checks whether this file is a regular file.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the file is a regular file.| | boolean | Whether the file is a regular file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2635,13 +2722,13 @@ Checks whether this file is a socket. ...@@ -2635,13 +2722,13 @@ Checks whether this file is a socket.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | -------------- | | ------- | -------------- |
| boolean | Whether the file is a socket.| | boolean | Whether the file is a socket.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2660,13 +2747,13 @@ Checks whether this file is a symbolic link. ...@@ -2660,13 +2747,13 @@ Checks whether this file is a symbolic link.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the file is a symbolic link.| | boolean | Whether the file is a symbolic link.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2689,13 +2776,13 @@ Closes the stream. This API uses a promise to return the result. ...@@ -2689,13 +2776,13 @@ Closes the stream. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------- | | ------------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the stream close result.| | Promise&lt;void&gt; | Promise used to return the stream close result.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2719,13 +2806,13 @@ Closes the stream. This API uses an asynchronous callback to return the result. ...@@ -2719,13 +2806,13 @@ Closes the stream. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------- | | -------- | ------------------------- | ---- | ------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is closed asynchronously.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked immediately after the stream is closed.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2736,7 +2823,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -2736,7 +2823,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
if (err) { if (err) {
console.info("close stream failed with error message: " + err.message + ", error code: " + err.code); console.info("close stream failed with error message: " + err.message + ", error code: " + err.code);
} else { } else {
console.info("close stream success"): console.info("close stream success");
} }
}); });
``` ```
...@@ -2751,7 +2838,7 @@ Synchronously closes the stream. ...@@ -2751,7 +2838,7 @@ Synchronously closes the stream.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2771,13 +2858,13 @@ Flushes the stream. This API uses a promise to return the result. ...@@ -2771,13 +2858,13 @@ Flushes the stream. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------- | | ------------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the stream flushing result.| | Promise&lt;void&gt; | Promise used to return the stream flushing result.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2801,13 +2888,13 @@ Flushes the stream. This API uses an asynchronous callback to return the result. ...@@ -2801,13 +2888,13 @@ Flushes the stream. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | -------------- | | -------- | ------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is asynchronously flushed.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is asynchronously flushed.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2833,7 +2920,7 @@ Synchronously flushes the stream. ...@@ -2833,7 +2920,7 @@ Synchronously flushes the stream.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2853,20 +2940,20 @@ Writes data into the stream. This API uses a promise to return the result. ...@@ -2853,20 +2940,20 @@ Writes data into the stream. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------- | | --------------------- | -------- |
| Promise&lt;number&gt; | Promise used to return the length of the data written.| | Promise&lt;number&gt; | Promise used to return the length of the data written.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2890,15 +2977,15 @@ Writes data into the stream. This API uses an asynchronous callback to return th ...@@ -2890,15 +2977,15 @@ Writes data into the stream. This API uses an asynchronous callback to return th
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2926,20 +3013,20 @@ Synchronously writes data into the stream. ...@@ -2926,20 +3013,20 @@ Synchronously writes data into the stream.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data written in the file.| | number | Length of the data written in the file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2959,20 +3046,20 @@ Reads data from the stream. This API uses a promise to return the result. ...@@ -2959,20 +3046,20 @@ Reads data from the stream. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. By default, data is read from the current position.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. By default, data is read from the current position.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;number&gt; | Promise used to return the data read.| | Promise&lt;number&gt; | Promise used to return the data read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2998,15 +3085,15 @@ Reads data from the stream. This API uses an asynchronous callback to return the ...@@ -2998,15 +3085,15 @@ Reads data from the stream. This API uses an asynchronous callback to return the
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when data is read asynchronously from the stream. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when data is read asynchronously from the stream. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -3034,20 +3121,20 @@ Synchronously reads data from the stream. ...@@ -3034,20 +3121,20 @@ Synchronously reads data from the stream.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. By default, data is read from the current position.<br> | | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. By default, data is read from the current position.<br> |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data read.| | number | Length of the data read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -3079,19 +3166,19 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A ...@@ -3079,19 +3166,19 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -3114,14 +3201,14 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A ...@@ -3114,14 +3201,14 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is locked. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is locked. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -3146,13 +3233,13 @@ Applies an exclusive lock or a shared lock on this file in non-blocking mode. ...@@ -3146,13 +3233,13 @@ Applies an exclusive lock or a shared lock on this file in non-blocking mode.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -3172,7 +3259,7 @@ Unlocks this file synchronously. ...@@ -3172,7 +3259,7 @@ Unlocks this file synchronously.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -3199,7 +3286,7 @@ Starts listening. ...@@ -3199,7 +3286,7 @@ Starts listening.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -3222,7 +3309,7 @@ Stops listening. ...@@ -3222,7 +3309,7 @@ Stops listening.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -3266,3 +3353,14 @@ Defines the file filtering configuration, which can be used by **listFile()**. ...@@ -3266,3 +3353,14 @@ Defines the file filtering configuration, which can be used by **listFile()**.
| fileSizeOver | number | Locate files that are greater than or equal to the specified size. | | fileSizeOver | number | Locate files that are greater than or equal to the specified size. |
| lastModifiedAfter | number | Locate files whose last modification time is the same or later than the specified time. | | lastModifiedAfter | number | Locate files whose last modification time is the same or later than the specified time. |
| excludeMedia | boolean | Whether to exclude the files already in **Media**. | | excludeMedia | boolean | Whether to exclude the files already in **Media**. |
## ConflictFiles
**System capability**: SystemCapability.FileManagement.File.FileIO
Defines information about the conflicting files. It is used the **copyDir()** and **moveDir()**.
| Name | Type | Description |
| ----------- | --------------- | ------------------ |
| srcFile | string | Path of the source file. |
| destFile | string | Path of the destination file.|
# @ohos.file.hash (File Hash Processing) # @ohos.file.hash (File Hash Processing)
The **fileHash** module implements hash processing on files. The **FileHash** module implements hash processing on files.
> **NOTE** > **NOTE**
> >
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
...@@ -17,7 +16,7 @@ import Hash from '@ohos.file.hash'; ...@@ -17,7 +16,7 @@ import Hash from '@ohos.file.hash';
Before using the APIs provided by this module to perform operations on a file or directory, obtain the path of the file or directory in the application sandbox as follows: Before using the APIs provided by this module to perform operations on a file or directory, obtain the path of the file or directory in the application sandbox as follows:
**Stage Model** Stage Model
```js ```js
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
...@@ -30,7 +29,7 @@ export default class EntryAbility extends UIAbility { ...@@ -30,7 +29,7 @@ export default class EntryAbility extends UIAbility {
} }
``` ```
**FA Model** FA Model
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
...@@ -64,6 +63,15 @@ Calculates a hash value for a file. This API uses a promise to return the result ...@@ -64,6 +63,15 @@ Calculates a hash value for a file. This API uses a promise to return the result
| --------------------- | -------------------------- | | --------------------- | -------------------------- |
| Promise&lt;string&gt; | Promise used to return the hash value. The hash value is a hexadecimal string consisting of digits and uppercase letters.| | Promise&lt;string&gt; | Promise used to return the hash value. The hash value is a hexadecimal string consisting of digits and uppercase letters.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
...@@ -89,9 +97,19 @@ Calculates a hash value for a file. This API uses an asynchronous callback to re ...@@ -89,9 +97,19 @@ Calculates a hash value for a file. This API uses an asynchronous callback to re
| --------- | --------------------------- | ---- | ------------------------------------------------------------ | | --------- | --------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | Path of the file in the application sandbox. | | path | string | Yes | Path of the file in the application sandbox. |
| algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**. **sha256** is recommended for security purposes.| | 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&lt;string&gt; | Yes | Callback used to return the hash value obtained. The hash value is a hexadecimal string consisting of digits and uppercase letters.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the hash value obtained. The hash value is a hexadecimal string consisting of digits and uppercase letters.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
let filePath = pathDir + "/test.txt"; let filePath = pathDir + "/test.txt";
Hash.hash(filePath, "sha256", (err, str) => { Hash.hash(filePath, "sha256", (err, str) => {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
```js ```js
import picker from '@ohos.file.picker'; import picker from '@ohos.file.picker';
``` ```
......
...@@ -4,8 +4,7 @@ The **securityLabel** module provides APIs for managing data security levels of ...@@ -4,8 +4,7 @@ The **securityLabel** module provides APIs for managing data security levels of
> **NOTE** > **NOTE**
> >
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
...@@ -60,9 +59,24 @@ Sets a security label for a file in asynchronous mode. This API uses a promise t ...@@ -60,9 +59,24 @@ Sets a security label for a file in asynchronous mode. This API uses a promise t
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------- | | ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
...@@ -91,6 +105,21 @@ Sets a security label for a file in asynchronous mode. This API uses an asynchro ...@@ -91,6 +105,21 @@ Sets a security label for a file in asynchronous mode. This API uses an asynchro
| type | DataLevel | Yes | File security level to set, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.| | type | DataLevel | Yes | File security level to set, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
...@@ -119,6 +148,21 @@ Sets a security label for a file in synchronous mode. ...@@ -119,6 +148,21 @@ Sets a security label for a file in synchronous mode.
| path | string | Yes | Path of the target file. | | path | string | Yes | Path of the target file. |
| type | DataLevel | Yes | File security level to set, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.| | type | DataLevel | Yes | File security level to set, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
...@@ -136,15 +180,30 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi ...@@ -136,15 +180,30 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- | | ------ | ------ | ---- | -------- |
| path | string | Yes | Path of the target file.| | path | string | Yes | Path of the target file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------ | | --------------------- | ------------ |
| Promise&lt;string&gt; | Security label obtained.| | Promise&lt;string&gt; | Security label obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
...@@ -167,10 +226,25 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb ...@@ -167,10 +226,25 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------- | | -------- | --------------------------- | ---- | -------------------------- |
| path | string | Yes | Path of the target file. | | path | string | Yes | Path of the target file. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the security label obtained.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the security label obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
...@@ -184,6 +258,7 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb ...@@ -184,6 +258,7 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb
} }
}); });
``` ```
## securityLabel.getSecurityLabelSync ## securityLabel.getSecurityLabelSync
getSecurityLabelSync(path:string):string getSecurityLabelSync(path:string):string
...@@ -204,6 +279,21 @@ Obtains the security label of a file in synchronous mode. ...@@ -204,6 +279,21 @@ Obtains the security label of a file in synchronous mode.
| ------ | ------------ | | ------ | ------------ |
| string | Security label obtained.| | string | Security label obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
......
...@@ -4,14 +4,14 @@ The **statfs** module provides APIs for obtaining file system information, inclu ...@@ -4,14 +4,14 @@ The **statfs** module provides APIs for obtaining file system information, inclu
> **NOTE** > **NOTE**
> >
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
```js ```js
import statvfs from '@ohos.file.statvfs'; import statvfs from '@ohos.file.statvfs';
``` ```
## statvfs.getFreeSize ## statvfs.getFreeSize
getFreeSize(path:string):Promise&lt;number&gt; getFreeSize(path:string):Promise&lt;number&gt;
...@@ -32,6 +32,10 @@ Obtains the number of free bytes of the specified file system in asynchronous mo ...@@ -32,6 +32,10 @@ Obtains the number of free bytes of the specified file system in asynchronous mo
| --------------------- | -------------- | | --------------------- | -------------- |
| Promise&lt;number&gt; | Promise used to return the number of free bytes obtained.| | Promise&lt;number&gt; | Promise used to return the number of free bytes obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
```js ```js
...@@ -58,6 +62,10 @@ Obtains the number of free bytes of the specified file system in asynchronous mo ...@@ -58,6 +62,10 @@ Obtains the number of free bytes of the specified file system in asynchronous mo
| path | string | Yes | File path of the file system.| | path | string | Yes | File path of the file system.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of free bytes obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of free bytes obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
```js ```js
...@@ -91,6 +99,10 @@ Obtains the total number of bytes of the specified file system in asynchronous m ...@@ -91,6 +99,10 @@ Obtains the total number of bytes of the specified file system in asynchronous m
| --------------------- | ------------ | | --------------------- | ------------ |
| Promise&lt;number&gt; | Promise used to return the total number of bytes obtained.| | Promise&lt;number&gt; | Promise used to return the total number of bytes obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
```js ```js
...@@ -117,6 +129,10 @@ Obtains the total number of bytes of the specified file system in asynchronous m ...@@ -117,6 +129,10 @@ Obtains the total number of bytes of the specified file system in asynchronous m
| path | string | Yes | File path of the file system.| | path | string | Yes | File path of the file system.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total number of bytes obtained. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total number of bytes obtained. |
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
```js ```js
......
...@@ -4,8 +4,8 @@ The **storageStatistics** module provides APIs for obtaining storage space infor ...@@ -4,8 +4,8 @@ The **storageStatistics** module provides APIs for obtaining storage space infor
> **NOTE** > **NOTE**
> >
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
```js ```js
...@@ -24,7 +24,6 @@ Obtains the total size (in bytes) of the specified volume in an external storage ...@@ -24,7 +24,6 @@ Obtains the total size (in bytes) of the specified volume in an external storage
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
...@@ -37,6 +36,19 @@ Obtains the total size (in bytes) of the specified volume in an external storage ...@@ -37,6 +36,19 @@ Obtains the total size (in bytes) of the specified volume in an external storage
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the total volume size obtained.| | Promise&lt;number&gt; | Promise used to return the total volume size obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -60,7 +72,6 @@ Obtains the total size (in bytes) of the specified volume in an external storage ...@@ -60,7 +72,6 @@ Obtains the total size (in bytes) of the specified volume in an external storage
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -68,6 +79,19 @@ Obtains the total size (in bytes) of the specified volume in an external storage ...@@ -68,6 +79,19 @@ Obtains the total size (in bytes) of the specified volume in an external storage
| volumeUuid | string | Yes | UUID of the volume. | | volumeUuid | string | Yes | UUID of the volume. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total volume size obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total volume size obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -90,7 +114,6 @@ Obtains the available space (in bytes) of the specified volume in an external st ...@@ -90,7 +114,6 @@ Obtains the available space (in bytes) of the specified volume in an external st
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
...@@ -103,6 +126,19 @@ Obtains the available space (in bytes) of the specified volume in an external st ...@@ -103,6 +126,19 @@ Obtains the available space (in bytes) of the specified volume in an external st
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available volume space obtained.| | Promise&lt;number&gt; | Promise used to return the available volume space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -127,7 +163,6 @@ Obtains the available space (in bytes) of the specified volume in an external st ...@@ -127,7 +163,6 @@ Obtains the available space (in bytes) of the specified volume in an external st
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -135,6 +170,19 @@ Obtains the available space (in bytes) of the specified volume in an external st ...@@ -135,6 +170,19 @@ Obtains the available space (in bytes) of the specified volume in an external st
| volumeUuid | string | Yes | UUID of the volume. | | volumeUuid | string | Yes | UUID of the volume. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available volume space obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available volume space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -157,7 +205,6 @@ Obtains the space (in bytes) of an application. This API uses a promise to retur ...@@ -157,7 +205,6 @@ Obtains the space (in bytes) of an application. This API uses a promise to retur
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -170,6 +217,19 @@ Obtains the space (in bytes) of an application. This API uses a promise to retur ...@@ -170,6 +217,19 @@ Obtains the space (in bytes) of an application. This API uses a promise to retur
| ------------------------------------------ | -------------------------- | | ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats9)&gt; | Promise used to return the application space obtained.| | Promise&lt;[Bundlestats](#bundlestats9)&gt; | Promise used to return the application space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -193,7 +253,6 @@ Obtains the space (in bytes) of an application. This API uses an asynchronous ca ...@@ -193,7 +253,6 @@ Obtains the space (in bytes) of an application. This API uses an asynchronous ca
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -201,6 +260,19 @@ Obtains the space (in bytes) of an application. This API uses an asynchronous ca ...@@ -201,6 +260,19 @@ Obtains the space (in bytes) of an application. This API uses an asynchronous ca
| packageName | string | Yes | Bundle name of the application.| | packageName | string | Yes | Bundle name of the application.|
| callback | AsyncCallback&lt;[Bundlestats](#bundlestats9)&gt; | Yes | Callback invoked to return the application space obtained.| | callback | AsyncCallback&lt;[Bundlestats](#bundlestats9)&gt; | Yes | Callback invoked to return the application space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -225,6 +297,16 @@ Obtains the space (in bytes) of this third-party application. This API uses a pr ...@@ -225,6 +297,16 @@ Obtains the space (in bytes) of this third-party application. This API uses a pr
| ------------------------------------------ | -------------------------- | | ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats9)&gt; | Promise used to return the application space obtained. | | Promise&lt;[Bundlestats](#bundlestats9)&gt; | Promise used to return the application space obtained. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -246,6 +328,16 @@ Obtains the space (in bytes) of this third-party application. This API uses an a ...@@ -246,6 +328,16 @@ Obtains the space (in bytes) of this third-party application. This API uses an a
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback&lt;[BundleStats](#bundlestats9)&gt; | Yes | Callback invoked to return the application space obtained. | | callback | AsyncCallback&lt;[BundleStats](#bundlestats9)&gt; | Yes | Callback invoked to return the application space obtained. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -265,7 +357,6 @@ Obtains the space (in bytes) of this third-party application. This API uses an a ...@@ -265,7 +357,6 @@ Obtains the space (in bytes) of this third-party application. This API uses an a
| cacheSize | number | Yes| No| Cache size of the application, in bytes. | | cacheSize | number | Yes| No| Cache size of the application, in bytes. |
| dataSize | number | Yes| No| Total data size of the application, in bytes.| | dataSize | number | Yes| No| Total data size of the application, in bytes.|
## storageStatistics.getTotalSize<sup>9+</sup> ## storageStatistics.getTotalSize<sup>9+</sup>
getTotalSize(): Promise&lt;number&gt; getTotalSize(): Promise&lt;number&gt;
...@@ -284,6 +375,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses a promi ...@@ -284,6 +375,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses a promi
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the built-in storage size obtained. | | Promise&lt;number&gt; | Promise used to return the built-in storage size obtained. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -309,6 +412,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn ...@@ -309,6 +412,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn
| -------- | ------------------------------------ | ---- | ------------------------ | | -------- | ------------------------------------ | ---- | ------------------------ |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the built-in storage size obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the built-in storage size obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -318,7 +433,6 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn ...@@ -318,7 +433,6 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn
}); });
``` ```
## storageStatistics.getFreeSize<sup>9+</sup> ## storageStatistics.getFreeSize<sup>9+</sup>
getFreeSize(): Promise&lt;number&gt; getFreeSize(): Promise&lt;number&gt;
...@@ -337,6 +451,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a ...@@ -337,6 +451,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available space of the built-in storage obtained.| | Promise&lt;number&gt; | Promise used to return the available space of the built-in storage obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -344,7 +470,6 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a ...@@ -344,7 +470,6 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a
console.info("getFreeSize successfully:"+ JSON.stringify(number)); console.info("getFreeSize successfully:"+ JSON.stringify(number));
``` ```
## storageStatistics.getFreeSize<sup>9+</sup> ## storageStatistics.getFreeSize<sup>9+</sup>
getFreeSize(callback: AsyncCallback&lt;number&gt;): void getFreeSize(callback: AsyncCallback&lt;number&gt;): void
...@@ -363,6 +488,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses an ...@@ -363,6 +488,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses an
| -------- | ------------------------------------ | ---- | ------------------------- | | -------- | ------------------------------------ | ---- | ------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in storage obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in storage obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -384,13 +521,24 @@ Obtains the system data space, in bytes. This API uses a promise to return the r ...@@ -384,13 +521,24 @@ Obtains the system data space, in bytes. This API uses a promise to return the r
**System API**: This is a system API. **System API**: This is a system API.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the system data space obtained.| | Promise&lt;number&gt; | Promise used to return the system data space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -419,6 +567,18 @@ Obtains the system data space, in bytes. This API uses an asynchronous callback ...@@ -419,6 +567,18 @@ Obtains the system data space, in bytes. This API uses an asynchronous callback
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the system data space obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the system data space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -446,6 +606,18 @@ Obtains the storage statistics (in bytes) of this user. This API uses a promise ...@@ -446,6 +606,18 @@ Obtains the storage statistics (in bytes) of this user. This API uses a promise
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the information obtained.| | Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -474,6 +646,18 @@ Obtains the storage statistics (in bytes) of this user. This API uses an asynchr ...@@ -474,6 +646,18 @@ Obtains the storage statistics (in bytes) of this user. This API uses an asynchr
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes | Callback invoked to return the information obtained.| | callback | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes | Callback invoked to return the information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -482,6 +666,9 @@ Obtains the storage statistics (in bytes) of this user. This API uses an asynchr ...@@ -482,6 +666,9 @@ Obtains the storage statistics (in bytes) of this user. This API uses an asynchr
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
}); });
``` ```
## storageStatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId: number): Promise&lt;StorageStats&gt; getUserStorageStats(userId: number): Promise&lt;StorageStats&gt;
Obtains the storage statistics (in bytes) of the specified user. This API uses a promise to return the result. Obtains the storage statistics (in bytes) of the specified user. This API uses a promise to return the result.
...@@ -504,6 +691,19 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a ...@@ -504,6 +691,19 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the information obtained.| | Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600009 | User if out of range. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -534,6 +734,19 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a ...@@ -534,6 +734,19 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a
| userId | number | Yes | User ID.| | userId | number | Yes | User ID.|
| callback | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes | Callback invoked to return the information obtained.| | callback | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes | Callback invoked to return the information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600009 | User if out of range. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -544,7 +757,6 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a ...@@ -544,7 +757,6 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a
}); });
``` ```
## StorageStats<sup>9+</sup> ## StorageStats<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
......
...@@ -6,7 +6,6 @@ The **volumeManager** module provides APIs for volume and disk management, inclu ...@@ -6,7 +6,6 @@ The **volumeManager** module provides APIs for volume and disk management, inclu
> >
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs. > - The APIs provided by this module are system APIs.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
...@@ -26,9 +25,21 @@ Obtains information about all volumes of this external storage device. This API ...@@ -26,9 +25,21 @@ Obtains information about all volumes of this external storage device. This API
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | -------------------------- | | ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)[]&gt; | Promise used to return information about all available volumes.| | Promise&lt;[Volume](#volume)[]&gt; | Promise used to return information about all available volumes.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -52,9 +63,21 @@ Obtains information about all volumes of this external storage device. This API ...@@ -52,9 +63,21 @@ Obtains information about all volumes of this external storage device. This API
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------------------------ | | -------- | ------------------------------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback&lt;[Volume](#volume)[]&gt; | Yes | Callback invoked to return information about all available volumes.| | callback | AsyncCallback&lt;[Volume](#volume)[]&gt; | Yes | Callback invoked to return information about all available volumes.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -65,7 +88,6 @@ Obtains information about all volumes of this external storage device. This API ...@@ -65,7 +88,6 @@ Obtains information about all volumes of this external storage device. This API
}); });
``` ```
## volumemanager.mount ## volumemanager.mount
mount(volumeId: string): Promise&lt;void&gt; mount(volumeId: string): Promise&lt;void&gt;
...@@ -78,15 +100,31 @@ Asynchronously mounts a volume. This API uses a promise to return the result. Cu ...@@ -78,15 +100,31 @@ Asynchronously mounts a volume. This API uses a promise to return the result. Cu
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.| | volumeId | string | Yes | Volume ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | ---------- | | ---------------------- | ---------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600003 | Failed to mount. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -111,10 +149,26 @@ Asynchronously mounts a volume. This API uses an asynchronous callback to return ...@@ -111,10 +149,26 @@ Asynchronously mounts a volume. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- | | -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | Yes | Volume ID. | | volumeId | string | Yes | Volume ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600003 | Failed to mount. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -137,15 +191,31 @@ Asynchronously unmounts a volume. This API uses a promise to return the result. ...@@ -137,15 +191,31 @@ Asynchronously unmounts a volume. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.| | volumeId | string | Yes | Volume ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | ---------- | | ---------------------- | ---------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600004 | Failed to unmount. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -170,10 +240,26 @@ Asynchronously unmounts a volume. This API uses an asynchronous callback to retu ...@@ -170,10 +240,26 @@ Asynchronously unmounts a volume. This API uses an asynchronous callback to retu
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- | | -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | Yes | Volume ID. | | volumeId | string | Yes | Volume ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600004 | Failed to unmount. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -196,15 +282,28 @@ Obtains information about a volume based on the universally unique identifier (U ...@@ -196,15 +282,28 @@ Obtains information about a volume based on the universally unique identifier (U
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| uuid | string | Yes | UUID of the volume.| | uuid | string | Yes | UUID of the volume.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | -------------------------- | | ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)&gt; | Promise used to return the volume information obtained.| | Promise&lt;[Volume](#volume)&gt; | Promise used to return the volume information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -229,10 +328,23 @@ Obtains information about a volume based on the UUID. This API uses an asynchron ...@@ -229,10 +328,23 @@ Obtains information about a volume based on the UUID. This API uses an asynchron
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------- | | -------- | ------------------------------------------------ | ---- | -------------------- |
| uuid | string | Yes | UUID of the volume. | | uuid | string | Yes | UUID of the volume. |
| callback | AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained.| | callback | AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -255,15 +367,28 @@ Obtains information about a volume based on the volume ID. This API uses a promi ...@@ -255,15 +367,28 @@ Obtains information about a volume based on the volume ID. This API uses a promi
**Parameters** **Parameters**
| Name | Type | Mandatory | Description| | Name | Type | Mandatory | Description|
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.| | volumeId | string | Yes | Volume ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | -------------------------- | | ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)&gt; | Promise used to return the volume information obtained.| | Promise&lt;[Volume](#volume)&gt; | Promise used to return the volume information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -288,10 +413,23 @@ Obtains information about a volume based on the volume ID. This API uses an asyn ...@@ -288,10 +413,23 @@ Obtains information about a volume based on the volume ID. This API uses an asyn
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- | | -------- | ------------------------- | ---- | ----------------------------- |
| volumeId | string | Yes | Volume ID. | | volumeId | string | Yes | Volume ID. |
| callback | AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained. | | callback | AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -314,16 +452,31 @@ Sets volume description. This API uses a promise to return the result. ...@@ -314,16 +452,31 @@ Sets volume description. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| --------- | ------ | ---- | ---- | | --------- | ------ | ---- | ---- |
| uuid | string | Yes | UUID of the volume.| | uuid | string | Yes | UUID of the volume.|
| description | string | Yes | Volume description to set.| | description | string | Yes | Volume description to set.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | -------------------------- | | ---------------------- | -------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. | | Promise&lt;void&gt; | Promise that returns no value. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -349,11 +502,26 @@ Sets volume description. This API uses an asynchronous callback to return the re ...@@ -349,11 +502,26 @@ Sets volume description. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ---------------- | | ---------- | --------------------------------------- | ---- | ---------------- |
| uuid | string | Yes | UUID of the volume. | | uuid | string | Yes | UUID of the volume. |
| description | string | Yes | Volume description to set. | | description | string | Yes | Volume description to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -377,16 +545,31 @@ Formats a volume. This API uses a promise to return the result. Currently, only ...@@ -377,16 +545,31 @@ Formats a volume. This API uses a promise to return the result. Currently, only
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| ----------- | ------ | ---- | ---- | | ----------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.| | volumeId | string | Yes | Volume ID.|
| fsType | string | Yes | File system type, which can be VFAT or exFAT.| | fsType | string | Yes | File system type, which can be VFAT or exFAT.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | ---------- | | ---------------------- | ---------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -412,11 +595,26 @@ Formats a volume. This API uses an asynchronous callback to return the result. C ...@@ -412,11 +595,26 @@ Formats a volume. This API uses an asynchronous callback to return the result. C
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- | | -------- | ------------------------- | ---- | ----------------------------- |
| volumeId | string | Yes | Volume ID. | | volumeId | string | Yes | Volume ID. |
| fsType | string | Yes | File system type, which can be VFAT or exFAT.| | fsType | string | Yes | File system type, which can be VFAT or exFAT.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -440,16 +638,29 @@ Partitions a disk. This API uses a promise to return the result. The system supp ...@@ -440,16 +638,29 @@ Partitions a disk. This API uses a promise to return the result. The system supp
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| ----------- | ------ | ---- | ---- | | ----------- | ------ | ---- | ---- |
| diskId | string | Yes | ID of the disk to partition.| | diskId | string | Yes | ID of the disk to partition.|
| type | number | Yes | Partition type. | | type | number | Yes | Partition type. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ----------------------- | | --------------------- | ----------------------- |
| Promise&lt;void&gt; | Promise used to return the result. | | Promise&lt;void&gt; | Promise used to return the result. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -475,11 +686,24 @@ Asynchronously partitions a disk. This API uses a callback to return the result. ...@@ -475,11 +686,24 @@ Asynchronously partitions a disk. This API uses a callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ---------------- | | -------- | --------------------------------------- | ---- | ---------------- |
| diskId | string | Yes | ID of the disk to partition. | | diskId | string | Yes | ID of the disk to partition. |
| type | number | Yes | Partition type. | | type | number | Yes | Partition type. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
......
# @ohos.fileShare (File Sharing) # @ohos.fileshare (File Sharing)
The **fileShare** module provides APIs for granting the access permissions on a user file to another application by the Uniform Resource Identifier (URI). Then, the authorized application can access the file by using the APIs provided by [@ohos.file.fs](js-apis-file-fs.md). The **fileshare** module provides APIs for granting the access permissions on a user file to another application by the Uniform Resource Identifier (URI). Then, the authorized application can access the file by using the APIs provided by [@ohos.file.fs](js-apis-file-fs.md).
> **NOTE** > **NOTE**
> >
...@@ -9,7 +9,7 @@ The **fileShare** module provides APIs for granting the access permissions on a ...@@ -9,7 +9,7 @@ The **fileShare** module provides APIs for granting the access permissions on a
## Modules to Import ## Modules to Import
```js ```js
import fileShare from '@ohos.fileShare'; import fileShare from '@ohos.fileshare';
``` ```
## fileShare.grantUriPermission ## fileShare.grantUriPermission
...@@ -31,7 +31,7 @@ Grants permissions on a user file by the URI to an application. This API uses an ...@@ -31,7 +31,7 @@ Grants permissions on a user file by the URI to an application. This API uses an
| uri | string | Yes | URI of a user file.| | uri | string | Yes | URI of a user file.|
| bundleName | string | Yes | Bundle name of the application to be grated with the permissions.| | bundleName | string | Yes | Bundle name of the application to be grated with the permissions.|
| mode | number | Yes | Permissions to grant. For details, see [wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags).<br>**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file. <br>**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.| | mode | number | Yes | Permissions to grant. For details, see [wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags).<br>**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file. <br>**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Error codes** **Error codes**
...@@ -44,7 +44,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod ...@@ -44,7 +44,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod
| 401 | The input parameter is invalid | | 401 | The input parameter is invalid |
| 143000001 | IPC error | | 143000001 | IPC error |
**Example** **Example**
```js ```js
...@@ -66,7 +65,6 @@ try { ...@@ -66,7 +65,6 @@ try {
} }
``` ```
## fileShare.grantUriPermission ## fileShare.grantUriPermission
grantUriPermission(uri: string, bundleName: string, mode: number): Promise&lt;void&gt; grantUriPermission(uri: string, bundleName: string, mode: number): Promise&lt;void&gt;
...@@ -89,10 +87,9 @@ Grants permissions on a user file by the URI to an application. This API uses a ...@@ -89,10 +87,9 @@ Grants permissions on a user file by the URI to an application. This API uses a
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
...@@ -105,7 +102,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod ...@@ -105,7 +102,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod
| 401 | The input parameter is invalid | | 401 | The input parameter is invalid |
| 143000001 | IPC error | | 143000001 | IPC error |
**Example** **Example**
```js ```js
......
...@@ -4,8 +4,8 @@ The **userFileManager** module provides user data management capabilities, inclu ...@@ -4,8 +4,8 @@ The **userFileManager** module provides user data management capabilities, inclu
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs provided by this module are system APIs. > - The APIs provided by this module are system APIs.
## Modules to Import ## Modules to Import
...@@ -49,11 +49,8 @@ let mgr = userFileManager.getUserFileMgr(context); ...@@ -49,11 +49,8 @@ let mgr = userFileManager.getUserFileMgr(context);
getPhotoAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void; getPhotoAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void;
Obtains image and video assets. This API uses an asynchronous callback to return the result. Obtains image and video assets. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
**Required permissions**: ohos.permission.READ_IMAGEVIDEO **Required permissions**: ohos.permission.READ_IMAGEVIDEO
...@@ -92,7 +89,6 @@ async function example() { ...@@ -92,7 +89,6 @@ async function example() {
} }
``` ```
### getPhotoAssets ### getPhotoAssets
getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;; getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
...@@ -141,6 +137,7 @@ async function example() { ...@@ -141,6 +137,7 @@ async function example() {
} }
} }
``` ```
### createPhotoAsset ### createPhotoAsset
createPhotoAsset(displayName: string, albumUri: string, callback: AsyncCallback&lt;FileAsset&gt;): void; createPhotoAsset(displayName: string, albumUri: string, callback: AsyncCallback&lt;FileAsset&gt;): void;
...@@ -261,7 +258,6 @@ async function example() { ...@@ -261,7 +258,6 @@ async function example() {
getPhotoAlbums(options: AlbumFetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void; getPhotoAlbums(options: AlbumFetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void;
Obtains image and video albums. This API uses an asynchronous callback to return the result. Obtains image and video albums. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
...@@ -352,7 +348,6 @@ async function example() { ...@@ -352,7 +348,6 @@ async function example() {
getPrivateAlbum(type: PrivateAlbumType, callback: AsyncCallback&lt;FetchResult&lt;PrivateAlbum&gt;&gt;): void; getPrivateAlbum(type: PrivateAlbumType, callback: AsyncCallback&lt;FetchResult&lt;PrivateAlbum&gt;&gt;): void;
Obtains the system album. This API uses an asynchronous callback to return the result. Obtains the system album. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
...@@ -424,7 +419,6 @@ async function example() { ...@@ -424,7 +419,6 @@ async function example() {
getAudioAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void; getAudioAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void;
Obtains audio assets. This API uses an asynchronous callback to return the result. Obtains audio assets. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
...@@ -469,7 +463,6 @@ async function example() { ...@@ -469,7 +463,6 @@ async function example() {
getAudioAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;; getAudioAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
Obtains audio assets. This API uses a promise to return the result. Obtains audio assets. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
...@@ -515,6 +508,7 @@ async function example() { ...@@ -515,6 +508,7 @@ async function example() {
} }
} }
``` ```
### delete ### delete
delete(uri: string, callback: AsyncCallback&lt;void&gt;): void; delete(uri: string, callback: AsyncCallback&lt;void&gt;): void;
...@@ -564,6 +558,7 @@ async function example() { ...@@ -564,6 +558,7 @@ async function example() {
}); });
} }
``` ```
### delete ### delete
delete(uri: string): Promise&lt;void&gt;; delete(uri: string): Promise&lt;void&gt;;
...@@ -1093,7 +1088,6 @@ Opens this file asset. This API uses an asynchronous callback to return the resu ...@@ -1093,7 +1088,6 @@ Opens this file asset. This API uses an asynchronous callback to return the resu
**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO **Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
**Parameters** **Parameters**
...@@ -1923,6 +1917,7 @@ async function example() { ...@@ -1923,6 +1917,7 @@ async function example() {
}); });
} }
``` ```
### getPhotoAssets ### getPhotoAssets
getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;; getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
...@@ -2106,6 +2101,7 @@ async function example() { ...@@ -2106,6 +2101,7 @@ async function example() {
} }
``` ```
### getPhotoAssets ### getPhotoAssets
getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;; getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
...@@ -2147,6 +2143,7 @@ async function example() { ...@@ -2147,6 +2143,7 @@ async function example() {
console.info('fetchResult.count = ', count); console.info('fetchResult.count = ', count);
} }
``` ```
### delete ### delete
delete(uri: string, callback: AsyncCallback&lt;void&gt;): void; delete(uri: string, callback: AsyncCallback&lt;void&gt;): void;
...@@ -2190,6 +2187,7 @@ async function example() { ...@@ -2190,6 +2187,7 @@ async function example() {
}); });
} }
``` ```
### delete ### delete
delete(uri: string): Promise&lt;void&gt;; delete(uri: string): Promise&lt;void&gt;;
...@@ -2280,6 +2278,7 @@ async function example() { ...@@ -2280,6 +2278,7 @@ async function example() {
}); });
} }
``` ```
### recover ### recover
recover(uri: string): Promise&lt;void&gt;; recover(uri: string): Promise&lt;void&gt;;
...@@ -2335,9 +2334,9 @@ Enumerates the member types. ...@@ -2335,9 +2334,9 @@ Enumerates the member types.
| Name | Type| Readable | Writable | Description | | Name | Type| Readable | Writable | Description |
| ----- | ---- | ---- | ---- | ---- | | ----- | ---- | ---- | ---- | ---- |
| number | number | Yes| Yes| The member is a number.| | number | number | Yes| Yes| The member is a number.|
| string | string | Yes| Yes| The member is a string.| | string | string | Yes| Yes| The member is a string.|
| boolean | boolean | Yes| Yes| The member is a Boolean value.| | boolean | boolean | Yes| Yes| The member is a Boolean value.|
## ChangeEvent ## ChangeEvent
...@@ -2366,7 +2365,6 @@ Defines information about a registered device. ...@@ -2366,7 +2365,6 @@ Defines information about a registered device.
| networkId | string | Yes | No | Network ID of the registered device.| | networkId | string | Yes | No | Network ID of the registered device.|
| isOnline | boolean | Yes | No | Whether the registered device is online. | | isOnline | boolean | Yes | No | Whether the registered device is online. |
## FileType ## FileType
Enumerates media file types. Enumerates media file types.
...@@ -2390,8 +2388,6 @@ Enumerates the system album types. ...@@ -2390,8 +2388,6 @@ Enumerates the system album types.
| TYPE_FAVORITE | 0 | Favorites.| | TYPE_FAVORITE | 0 | Favorites.|
| TYPE_TRASH | 1 | Recycle bin.| | TYPE_TRASH | 1 | Recycle bin.|
## AudioKey ## AudioKey
Defines the key information about an audio file. Defines the key information about an audio file.
...@@ -2445,7 +2441,6 @@ Defines the key album information. ...@@ -2445,7 +2441,6 @@ Defines the key album information.
| DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. | | DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. |
| DATE_MODIFIED | date_modified | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.| | DATE_MODIFIED | date_modified | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
## FetchOptions ## FetchOptions
Defines the options for fetching media files. Defines the options for fetching media files.
......
...@@ -4,9 +4,14 @@ ...@@ -4,9 +4,14 @@
> >
> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). > This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md).
The error codes of the file management subsystem consist of the following:<br>- Basic file I/O error codes<br>- User data management error codes<br>- User file access error codes<br>- Spatial statistics error codes The error codes of the file management subsystem include the following:
## Basic File I/O Error Codes - [Basic File IO Error Codes](#basic-file-io-error-codes)
- [User Data Management Error Codes](#user-data-management-error-code)
- [User File Access Error Codes](#user-file-access-error-codes)
- [Space Statistics Error Codes](#space-statistics-error-codes)
## Basic File IO Error Codes
### 13900001 Operation Not Permitted ### 13900001 Operation Not Permitted
...@@ -49,6 +54,7 @@ The process does not exist. ...@@ -49,6 +54,7 @@ The process does not exist.
**Solution** **Solution**
1. Check whether the process is killed unexpectedly. 1. Check whether the process is killed unexpectedly.
2. Check whether the service related to the process has started. 2. Check whether the service related to the process has started.
### 13900004 System Call Interrupted ### 13900004 System Call Interrupted
...@@ -64,6 +70,7 @@ The system call is interrupted by another thread. ...@@ -64,6 +70,7 @@ The system call is interrupted by another thread.
**Solution** **Solution**
1. Check the multi-thread code logic. 1. Check the multi-thread code logic.
2. Invoke the system call again. 2. Invoke the system call again.
### 13900005 I/O Error ### 13900005 I/O Error
...@@ -161,7 +168,9 @@ Out of memory ...@@ -161,7 +168,9 @@ Out of memory
A memory overflow occurs. A memory overflow occurs.
**Solution** **Solution**
1. Check the memory overhead. 1. Check the memory overhead.
2. Control the memory overhead. 2. Control the memory overhead.
### 13900012 Permission Denied ### 13900012 Permission Denied
...@@ -172,13 +181,14 @@ Permission denied ...@@ -172,13 +181,14 @@ Permission denied
**Possible Causes** **Possible Causes**
1. You do not have the permission to operate the file. 1. You do not have the permission to operate the file.
2. The file sandbox path is incorrect. 2. The file sandbox path is incorrect.
**Solution** **Solution**
1. Check that you have the permission to operate the file.
1. Check that the required permission is available.
2. Check that the file sandbox path is correct. 2. Check that the file sandbox path is correct.
### 13900013 Incorrect Address ### 13900013 Incorrect Address
...@@ -375,7 +385,7 @@ Seek is used in pipe or FIFO. ...@@ -375,7 +385,7 @@ Seek is used in pipe or FIFO.
**Solution** **Solution**
Check the use of seek. Check the use of **seek()**.
### 13900027 Read-Only File System ### 13900027 Read-Only File System
...@@ -460,6 +470,7 @@ The specified directory is not empty. ...@@ -460,6 +470,7 @@ The specified directory is not empty.
**Solution** **Solution**
1. Check the directory. 1. Check the directory.
2. Ensure that the directory is empty. 2. Ensure that the directory is empty.
### 13900033 Too Many Symbol Links ### 13900033 Too Many Symbol Links
...@@ -516,7 +527,7 @@ The device pointed to by the file descriptor is not a character stream device. ...@@ -516,7 +527,7 @@ The device pointed to by the file descriptor is not a character stream device.
**Solution** **Solution**
Check whether the file descriptor points to a stream device. Check whether the file descriptor points to a stream.
### 13900037 No Data Available ### 13900037 No Data Available
...@@ -599,7 +610,9 @@ Unknown error ...@@ -599,7 +610,9 @@ Unknown error
The error is unidentified. The error is unidentified.
**Solution** **Solution**
1. Call the API again. 1. Call the API again.
2. Restart the service. 2. Restart the service.
## User Data Management Error Codes ## User Data Management Error Codes
...@@ -636,7 +649,7 @@ Use the obtained URI. ...@@ -636,7 +649,7 @@ Use the obtained URI.
**Error Message** **Error Message**
Invalid file extension Invalid file name extension
**Possible Causes** **Possible Causes**
...@@ -660,7 +673,7 @@ The file is moved to the Recycle Bin. ...@@ -660,7 +673,7 @@ The file is moved to the Recycle Bin.
Check whether the file is in the Recycle Bin. Check whether the file is in the Recycle Bin.
## Spatial Statistics Error Codes ## Space Statistics Error Codes
### 13600001 IPC Failed ### 13600001 IPC Failed
...@@ -680,7 +693,7 @@ Check whether the service is started. ...@@ -680,7 +693,7 @@ Check whether the service is started.
**Error Message** **Error Message**
Not supported file system Not supported filesystem
**Possible Causes** **Possible Causes**
...@@ -767,11 +780,15 @@ Check whether the specified directory or node exists. ...@@ -767,11 +780,15 @@ Check whether the specified directory or node exists.
No such object No such object
**Possible Causes** **Possible Causes**
1. The specified volume ID is incorrect. 1. The specified volume ID is incorrect.
2. The specified bundle name is incorrect. 2. The specified bundle name is incorrect.
**Solution** **Solution**
1. Check whether the specified volume exists. 1. Check whether the specified volume exists.
2. Check whether the specified bundle name exists. 2. Check whether the specified bundle name exists.
### 13600009 Invalid User ID ### 13600009 Invalid User ID
...@@ -799,6 +816,7 @@ IPC error ...@@ -799,6 +816,7 @@ IPC error
**Possible Causes** **Possible Causes**
1. The server service does not exist. 1. The server service does not exist.
2. The extension mechanism is abnormal. 2. The extension mechanism is abnormal.
**Solution** **Solution**
...@@ -854,7 +872,9 @@ Check the data returned by the server. ...@@ -854,7 +872,9 @@ Check the data returned by the server.
Fail to register notification Fail to register notification
**Possible Causes** **Possible Causes**
1. The server service does not exist. 1. The server service does not exist.
2. The extension mechanism is abnormal. 2. The extension mechanism is abnormal.
**Solution** **Solution**
...@@ -868,7 +888,9 @@ Check that the server service exists. ...@@ -868,7 +888,9 @@ Check that the server service exists.
Fail to remove notification Fail to remove notification
**Possible Causes** **Possible Causes**
1. The server service does not exist. 1. The server service does not exist.
2. The extension mechanism is abnormal. 2. The extension mechanism is abnormal.
**Solution** **Solution**
...@@ -896,47 +918,11 @@ Check whether the specified Notify agent is registered. ...@@ -896,47 +918,11 @@ Check whether the specified Notify agent is registered.
Fail to notify agent Fail to notify agent
**Possible Causes** **Possible Causes**
1. The service does not exist. 1. The service does not exist.
2. The extension mechanism is abnormal. 2. The extension mechanism is abnormal.
**Solution** **Solution**
Check whether the client is normal. Check whether the client is normal.
## Error Code Adaptation
The APIs provided by the file management subsystem support exception handling.
Sample code for exception handling in a synchronous API:
```js
import fs from '@ohos.file.fs'
try {
let file = fs.openSync(path, fs.OpenMode.READ_ONLY);
} catch (err) {
console.error("openSync errCode:" + err.code + ", errMessage:" + err.message);
}
```
Sample code for exception handling in an asynchronous API (promise):
```js
import fs from '@ohos.file.fs'
try {
let file = await fs.open(path, fs.OpenMode.READ_ONLY);
} catch (err) {
console.error("open promise errCode:" + err.code + ", errMessage:" + err.message);
}
```
Sample code for exception handling in an asynchronous API (callback):
```js
import fs from '@ohos.file.fs'
try {
fs.open(path, fs.OpenMode.READ_ONLY, function(e, file){ // Asynchronous thread (such as the system call) errors are obtained via a callback.
if (e) {
console.error("open in async errCode:" + e.code + ", errMessage:" + e.message);
}
});
} catch (err) {// Main thread errors (such as invalid parameters) are obtained by try catch.
console.error("open callback errCode:" + err.code + ", errMessage:" + err.message);
}
```
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
## cl.filemanagement.1 environment Module Change ## cl.filemanagement.1 environment Module Change
The file management subsystem **d.ts** file has been archived and moved to the **file** directory. The **environment** module supports error code handling. The file management subsystem **d.ts** file has been archived and moved to the **file** directory. The **environment** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **environment** module supports error code handling. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **environment** module supports error code processing. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
...@@ -24,11 +24,11 @@ import environment from '@ohos.file.environment'; ...@@ -24,11 +24,11 @@ import environment from '@ohos.file.environment';
## cl.filemanagement.2 securityLabel Change ## cl.filemanagement.2 securityLabel Change
Moved the file management subsystem **d.ts** file to the **file** directory. The **securityLabel** module supports error code handling. Moved the file management subsystem **d.ts** file to the **file** directory. The **securityLabel** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **securityLabel** module supports error code handling. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **securityLabel** module supports error code processing. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
...@@ -58,11 +58,11 @@ The type of the **ino** attribute of **Stat** is changed from number to BigInt. ...@@ -58,11 +58,11 @@ The type of the **ino** attribute of **Stat** is changed from number to BigInt.
## cl.filemanagement.4 fileAccess Change ## cl.filemanagement.4 fileAccess Change
Moved the file management subsystem **d.ts** file to the **file** directory. The **fileAccess** module supports error code handling. Moved the file management subsystem **d.ts** file to the **file** directory. The **fileAccess** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileAccess** module supports error code handling. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileAccess** module supports error code processing. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
...@@ -80,11 +80,11 @@ import fileAccess from '@ohos.file.fileAccess'; ...@@ -80,11 +80,11 @@ import fileAccess from '@ohos.file.fileAccess';
## cl.filemanagement.5 fileExtensionInfo Change ## cl.filemanagement.5 fileExtensionInfo Change
Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code handling. Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileExtensionInfo** module supports error code handling. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileExtensionInfo** module supports error code processing. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
...@@ -102,11 +102,11 @@ import fileExtensionInfo from '@ohos.file.fileExtensionInfo'; ...@@ -102,11 +102,11 @@ import fileExtensionInfo from '@ohos.file.fileExtensionInfo';
## cl.filemanagement.6 storageStatistics Change ## cl.filemanagement.6 storageStatistics Change
Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code handling. Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **storageStatistics** module supports error code handling. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **storageStatistics** module supports error code processing. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
...@@ -124,11 +124,11 @@ import storageStatistics from '@ohos.file.storageStatistics'; ...@@ -124,11 +124,11 @@ import storageStatistics from '@ohos.file.storageStatistics';
## cl.filemanagement.7 volumeManager Change ## cl.filemanagement.7 volumeManager Change
Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code handling. Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **volumeManager** module supports error code handling. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **volumeManager** module supports error code processing. See [Adaptation Guide](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册