From 0c1a144c76ffcd98cc52d3b6738f49df55b9378f Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Fri, 26 May 2023 11:36:29 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/Readme-EN.md | 2 +- .../apis/js-apis-file-environment.md | 47 +- .../reference/apis/js-apis-file-fileuri.md | 7 +- .../reference/apis/js-apis-file-fs.md | 854 +++++++++--------- .../reference/apis/js-apis-file-hash.md | 30 +- .../reference/apis/js-apis-file-picker.md | 1 + .../apis/js-apis-file-securityLabel.md | 120 ++- .../reference/apis/js-apis-file-statvfs.md | 60 +- .../apis/js-apis-file-storage-statistics.md | 238 ++++- .../apis/js-apis-file-volumemanager.md | 392 ++++++-- .../reference/apis/js-apis-fileShare.md | 18 +- .../reference/apis/js-apis-userFileManager.md | 29 +- .../errorcodes/errorcode-filemanagement.md | 82 +- .../v3.2-beta5/changelogs-filemanagement.md | 24 +- 14 files changed, 1238 insertions(+), 666 deletions(-) diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 7dbd01e10f..08402ed745 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -241,7 +241,7 @@ - [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md) - [@ohos.file.volumeManager (Volume Management)](js-apis-file-volumemanager.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 - [@ohos.contact (Contacts)](js-apis-contact.md) diff --git a/en/application-dev/reference/apis/js-apis-file-environment.md b/en/application-dev/reference/apis/js-apis-file-environment.md index c87c8465d7..fb48f1a410 100644 --- a/en/application-dev/reference/apis/js-apis-file-environment.md +++ b/en/application-dev/reference/apis/js-apis-file-environment.md @@ -1,12 +1,11 @@ # @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** > > - 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 support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). ## Modules to Import @@ -28,6 +27,15 @@ Obtains the root directory of the storage. This API uses a promise to return the | --------------------- | ---------------- | | Promise<string> | 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** ```js @@ -52,6 +60,15 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac | -------- | --------------------------- | ---- | -------------------------------- | | callback | AsyncCallback<string> | 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** ```js @@ -68,7 +85,7 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac getUserDataDir():Promise<string> -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 @@ -76,7 +93,16 @@ Obtains the root directory of public files. This API uses a promise to return th | Type | Description | | --------------------- | ------------------ | -| Promise<string> | Promise returned with the root directory of public files.| +| Promise<string> | 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** @@ -92,7 +118,7 @@ Obtains the root directory of public files. This API uses a promise to return th getUserDataDir(callback:AsyncCallback<string>): 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 @@ -100,7 +126,16 @@ Obtains the root directory of public files. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | -------------------------------- | -| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the root directory of public files.| +| callback | AsyncCallback<string> | 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** diff --git a/en/application-dev/reference/apis/js-apis-file-fileuri.md b/en/application-dev/reference/apis/js-apis-file-fileuri.md index f8c6717fab..1aa5fe9cf0 100644 --- a/en/application-dev/reference/apis/js-apis-file-fileuri.md +++ b/en/application-dev/reference/apis/js-apis-file-fileuri.md @@ -41,9 +41,9 @@ Obtains the URI of a file in synchronous mode. **Return value** -| Type | Description | -| ---------------------------- | ---------- | -| string | File URI obtained.| + | Type | Description | + | ---------------------------- | ---------- | + | string | File URI obtained.| **Error codes** @@ -52,7 +52,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod | ---------------------------- | ---------- | | 401 | The input parameter is invalid | - **Example** ```js diff --git a/en/application-dev/reference/apis/js-apis-file-fs.md b/en/application-dev/reference/apis/js-apis-file-fs.md index c8ed1ccd4a..7f55fb64da 100644 --- a/en/application-dev/reference/apis/js-apis-file-fs.md +++ b/en/application-dev/reference/apis/js-apis-file-fs.md @@ -14,7 +14,7 @@ import fs from '@ohos.file.fs'; ## 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** @@ -58,13 +58,13 @@ Obtains detailed file information. This API uses a promise to return the result. **Return value** -| Type | Description | -| ---------------------------- | ---------- | -| Promise<[Stat](#stat)> | Promise used to return the file information obtained.| + | Type | Description | + | ---------------------------- | ---------- | + | Promise<[Stat](#stat)> | Promise used to return the file information obtained.| **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** @@ -94,7 +94,7 @@ Obtains detailed file information. This API uses an asynchronous callback to ret **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** @@ -124,13 +124,13 @@ Obtains detailed file information synchronously. **Return value** -| Type | Description | -| ------------- | ---------- | -| [Stat](#stat) | File information obtained.| + | Type | Description | + | ------------- | ---------- | + | [Stat](#stat) | File information obtained.| **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** @@ -155,13 +155,13 @@ Checks whether a file exists. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<boolean> | Promise used to return the result. The value **true** means the file exists; the value false means the opposite.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<boolean> | Promise used to return the result. The value **true** means the file exists; the value **false** means the opposite.| **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** @@ -193,7 +193,7 @@ Checks whether a file exists. This API uses an asynchronous callback to return t **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** @@ -226,13 +226,13 @@ Synchronously checks whether a file exists. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| boolean | Returns **true** if the file exists; returns **false** otherwise.| + | Type | Description | + | ------------------- | ---------------------------- | + | boolean | Returns **true** if the file exists; returns **false** otherwise.| **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** @@ -259,19 +259,19 @@ Closes a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| file | [File](#file)\|number | Yes | File object or FD of the file to close.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | file | [File](#file)\|number | Yes | File object or FD of the file to close.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -296,14 +296,14 @@ Closes a file. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ------------ | -| file | [File](#file)\|number | Yes | File object or FD of the file to close.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is closed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------ | + | file | [File](#file)\|number | Yes | File object or FD of the file to close.| + | callback | AsyncCallback<void> | Yes | Callback invoked immediately after the file is closed.| **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** @@ -329,13 +329,13 @@ Synchronously closes a file. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| file | [File](#file)\|number | Yes | File object or FD of the file to close.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | file | [File](#file)\|number | Yes | File object or FD of the file to close.| **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** @@ -355,21 +355,21 @@ Copies a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | -------------------------- | ---- | ---------------------------------------- | -| 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. | -| 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.
**0**: overwrite the file of the same name.| + | Name | Type | Mandatory | Description | + | ---- | -------------------------- | ---- | ---------------------------------------- | + | 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. | + | 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.
**0**: overwrite the file with the same name.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -393,16 +393,16 @@ Copies a file. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------------- | ---- | ---------------------------------------- | -| 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. | -| 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.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is copied asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | -------------------------- | ---- | ---------------------------------------- | + | 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. | + | 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.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| + | callback | AsyncCallback<void> | Yes | Callback invoked immediately after the file is copied. | **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** @@ -429,15 +429,15 @@ Synchronously copies a file. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | -------------------------- | ---- | ---------------------------------------- | -| 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. | -| 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.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| + | Name | Type | Mandatory | Description | + | ---- | -------------------------- | ---- | ---------------------------------------- | + | src | string\|number | Yes | Path or FD of the file to copy. | + | dest | string\|number | Yes | Destination path of the file or FD of the file created. | + | 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.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| **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** @@ -463,13 +463,13 @@ Creates a directory. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -499,7 +499,7 @@ Creates a directory. This API uses an asynchronous callback to return the result **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** @@ -530,7 +530,7 @@ Synchronously creates a directory. **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** @@ -556,13 +556,13 @@ Opens a file. This API uses a promise to return the result. File uniform resourc **Return value** -| Type | Description | -| --------------------- | ----------- | -| Promise<[File](#file)> | Promise used to return the file object.| + | Type | Description | + | --------------------- | ----------- | + | Promise<[File](#file)> | Promise used to return the file object.| **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** @@ -593,7 +593,7 @@ Opens a file. This API uses an asynchronous callback to return the result. File **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** @@ -625,13 +625,13 @@ Synchronously opens a file. File URIs are supported. **Return value** -| Type | Description | -| ------ | ----------- | -| [File](#file) | File object opened.| + | Type | Description | + | ------ | ----------- | + | [File](#file) | File object opened.| **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** @@ -660,13 +660,13 @@ Reads data from a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| ---------------------------------- | ------ | -| Promise<number> | Promise used to return the data read.| + | Type | Description | + | ---------------------------------- | ------ | + | Promise<number> | Promise used to return the data read.| **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** @@ -693,16 +693,16 @@ Reads data from a file. This API uses an asynchronous callback to return the res **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | -| options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| -| callback | AsyncCallback<number> | Yes | Callback invoked when the data is read asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is read asynchronously. | **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** @@ -731,21 +731,21 @@ Synchronously reads data from a file. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | -| options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| **Return value** -| Type | Description | -| ------ | -------- | -| number | Length of the data read.| + | Type | Description | + | ------ | -------- | + | number | Length of the data read.| **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** @@ -773,13 +773,13 @@ Deletes a directory. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -809,7 +809,7 @@ Deletes a directory. This API uses an asynchronous callback to return the result **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** @@ -840,7 +840,7 @@ Synchronously deletes a directory. **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** @@ -865,13 +865,13 @@ Deletes a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -897,11 +897,11 @@ Deletes a file. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | -------------------------- | | path | string | Yes | Application sandbox path of the file.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is deleted asynchronously. | +| callback | AsyncCallback<void> | Yes | Callback invoked immediately after the file is deleted. | **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** @@ -932,7 +932,7 @@ Synchronously deletes a file. **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** @@ -952,21 +952,21 @@ Writes data into a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **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.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **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** -| Type | Description | -| --------------------- | -------- | -| Promise<number> | Promise used to return the length of the data written.| + | Type | Description | + | --------------------- | -------- | + | Promise<number> | Promise used to return the length of the data written.| **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** @@ -991,16 +991,16 @@ Writes data into a file. This API uses an asynchronous callback to return the re **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| -| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | **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** @@ -1027,21 +1027,21 @@ Synchronously writes data into a file. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **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.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **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** -| Type | Description | -| ------ | -------- | -| number | Length of the data written in the file.| + | Type | Description | + | ------ | -------- | + | number | Length of the data written in the file.| **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** @@ -1070,13 +1070,13 @@ Truncates a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -1108,7 +1108,7 @@ Truncates a file. This API uses an asynchronous callback to return the result. **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** @@ -1141,7 +1141,7 @@ Synchronously truncates a file. **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** @@ -1168,13 +1168,13 @@ Reads the text content of a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| --------------------- | ---------- | -| Promise<string> | Promise used to return the content read.| + | Type | Description | + | --------------------- | ---------- | + | Promise<string> | Promise used to return the content read.| **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** @@ -1205,7 +1205,7 @@ Reads the text content of a file. This API uses an asynchronous callback to retu **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** @@ -1237,13 +1237,13 @@ Synchronously reads the text of a file. **Return value** -| Type | Description | -| ------ | -------------------- | -| string | Promise used to return the content of the file read.| + | Type | Description | + | ------ | -------------------- | + | string | Promise used to return the content of the file read.| **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** @@ -1269,13 +1269,13 @@ Obtains information about a symbolic link. This API uses a promise to return the **Return value** -| Type | Description | -| ---------------------------- | ---------- | -| Promise<[Stat](#stat)> | Promise used to return the symbolic link information obtained. For details, see **stat**.| + | Type | Description | + | ---------------------------- | ---------- | + | Promise<[Stat](#stat)> | Promise used to return the symbolic link information obtained. For details, see **stat**.| **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** @@ -1305,7 +1305,7 @@ Obtains information about a symbolic link. This API uses an asynchronous callbac **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** @@ -1336,13 +1336,13 @@ Obtains information about a symbolic link synchronously. **Return value** -| Type | Description | -| ------------- | ---------- | -| [Stat](#stat) | File information obtained.| + | Type | Description | + | ------------- | ---------- | + | [Stat](#stat) | File information obtained.| **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** @@ -1355,7 +1355,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem rename(oldPath: string, newPath: string): Promise<void> -Renames a file or folder. This API uses a promise to return the result. +Renames a file or directory. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO @@ -1363,18 +1363,18 @@ Renames a file or folder. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | ------- | ------ | ---- | ---------------------------- | -| oldPath | string | Yes | Application sandbox path of the file or folder to rename.| -| newPath | string | Yes | Application sandbox path of the renamed file or folder. | +| oldPath | string | Yes | Application sandbox path of the file to rename.| +| newPath | string | Yes | Application sandbox path of the renamed file. | **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -1392,7 +1392,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): void -Renames a file or folder. This API uses an asynchronous callback to return the result. +Renames a file or directory. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO @@ -1400,13 +1400,13 @@ Renames a file or folder. This API uses an asynchronous callback to return the r | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------------------------- | -| oldPath | string | Yes | Application sandbox path of the file or folder to rename.| -| newPath | string | Yes | Application sandbox path of the renamed file or folder. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the file or folder is asynchronously renamed. | +| oldPath | string | Yes | Application sandbox path of the file to rename.| +| newPath | string | Yes | Application sandbox path of the renamed file. | +| callback | AsyncCallback<void> | Yes | Callback invoked when the file is asynchronously renamed. | **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** @@ -1426,7 +1426,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem renameSync(oldPath: string, newPath: string): void -Renames a file or folder synchronously. +Renames a file or directory synchronously. **System capability**: SystemCapability.FileManagement.File.FileIO @@ -1434,12 +1434,12 @@ Renames a file or folder synchronously. | Name | Type | Mandatory| Description | | ------- | ------ | ---- | ---------------------------- | -| oldPath | string | Yes | Application sandbox path of the file or folder to rename.| -| newPath | string | Yes | Application sandbox path of the renamed file or folder. | +| oldPath | string | Yes | Application sandbox path of the file to rename.| +| newPath | string | Yes | Application sandbox path of the renamed file. | **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** @@ -1459,19 +1459,19 @@ Flushes data of a file to disk. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -1495,14 +1495,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | --------------- | -| fd | number | Yes | FD of the file. | -| Callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | --------------- | + | fd | number | Yes | FD of the file. | + | Callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| **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** @@ -1530,13 +1530,13 @@ Flushes data of a file to disk synchronously. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **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** @@ -1557,19 +1557,19 @@ Flushes data of a file to disk. This API uses a promise to return the result. ** **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -1594,14 +1594,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | ---- | ----------------- | -| fd | number | Yes | FD of the file. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ----------------- | + | fd | number | Yes | FD of the file. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| **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** @@ -1628,13 +1628,13 @@ Synchronizes data in a file synchronously. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **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** @@ -1662,13 +1662,13 @@ Creates a symbolic link based on a file path. This API uses a promise to return **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -1700,7 +1700,7 @@ Creates a symbolic link based on a file path. This API uses an asynchronous call **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** @@ -1733,7 +1733,7 @@ Synchronously creates a symbolic link based on a file path. **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** @@ -1756,28 +1756,28 @@ Lists all files in a directory. This API uses a promise to return the result.
The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception.
The default value is **0**.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **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** @@ -1959,16 +1959,16 @@ Moves a file. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| src | string | Yes | Application sandbox path of the source 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**.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is moved. | + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | src | string | Yes | Application sandbox path of the source file.| + | dest | string | Yes | Application sandbox path of the destination file.| + | mode | number | No | Whether to overwrite the file with the same name in the destination directory.
The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception.
The default value is **0**.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is moved. | **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** @@ -1994,15 +1994,15 @@ Moves a file synchronously. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| src | string | Yes | Application sandbox path of the source 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**.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | src | string | Yes | Application sandbox path of the source file.| + | dest | string | Yes | Application sandbox path of the destination file.| + | mode | number | No | Whether to overwrite the file with the same name in the destination directory.
The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception.
The default value is **0**.| **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** @@ -2023,19 +2023,19 @@ Creates a temporary directory. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| **Return value** -| Type | Description | -| --------------------- | ---------- | -| Promise<string> | Promise used to return the unique directory generated.| + | Type | Description | + | --------------------- | ---------- | + | Promise<string> | Promise used to return the unique directory generated.| **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** @@ -2057,14 +2057,14 @@ Creates a temporary directory. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | --------------------------- | -| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| -| callback | AsyncCallback<string> | Yes | Callback invoked when a temporary directory is created asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| + | callback | AsyncCallback<string> | Yes | Callback invoked when a temporary directory is created asynchronously. | **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** @@ -2088,25 +2088,25 @@ Synchronously creates a temporary directory. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| **Return value** -| Type | Description | -| ------ | ---------- | -| string | Unique path generated.| + | Type | Description | + | ------ | ---------- | + | string | Unique path generated.| **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** ```js let res = fs.mkdtempSync(pathDir + "/XXXXXX"); - ``` + ``` ## fs.createStream @@ -2125,13 +2125,13 @@ Creates a stream based on the file path. This API uses a promise to return the r **Return value** -| Type | Description | -| --------------------------------- | --------- | -| Promise<[Stream](#stream)> | Promise used to return the result.| + | Type | Description | + | --------------------------------- | --------- | + | Promise<[Stream](#stream)> | Promise used to return the result.| **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** @@ -2163,7 +2163,7 @@ Creates a stream based on the file path. This API uses an asynchronous callback **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** @@ -2195,13 +2195,13 @@ Synchronously creates a stream based on the file path. **Return value** -| Type | Description | -| ------------------ | --------- | -| [Stream](#stream) | Stream opened.| + | Type | Description | + | ------------------ | --------- | + | [Stream](#stream) | Stream opened.| **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** @@ -2221,20 +2221,20 @@ Opens a stream based on the file descriptor. This API uses a promise to return t **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| **Return value** -| Type | Description | -| --------------------------------- | --------- | -| Promise<[Stream](#stream)> | Promise used to return the result.| + | Type | Description | + | --------------------------------- | --------- | + | Promise<[Stream](#stream)> | Promise used to return the result.| **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** @@ -2259,15 +2259,15 @@ Opens a stream based on the file descriptor. This API uses an asynchronous callb **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -| callback | AsyncCallback<[Stream](#stream)> | Yes | Callback invoked when the stream is open asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| + | callback | AsyncCallback<[Stream](#stream)> | Yes | Callback invoked when the stream is opened. | **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** @@ -2294,20 +2294,20 @@ Synchronously opens a stream based on the file descriptor. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| **Return value** -| Type | Description | -| ------------------ | --------- | -| [Stream](#stream) | Stream opened.| + | Type | Description | + | ------------------ | --------- | + | [Stream](#stream) | Stream opened.| **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** @@ -2327,7 +2327,7 @@ Represents detailed file information. Before calling any API of the **Stat()** c ### Attributes | Name | Type | Readable | Writable | Description | -| ------ | ------ | ---- | ---- | ---------------------------------------- | +| ------ | ------ | ---- | ---- | ---------------------------------------- | | 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:
- **0o400**: The owner has the read permission on a regular file or a directory entry.
- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.
- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.
- **0o040**: The user group has the read permission on a regular file or a directory entry.
- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.
- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.
- **0o004**: Other users have the permission to read a regular file or read a directory entry.
- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.
- **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.| @@ -2347,13 +2347,13 @@ Checks whether this file is a block special file. A block special file supports **Return value** -| Type | Description | -| ------- | ---------------- | -| boolean | Whether the file is a block special file.| + | Type | Description | + | ------- | ---------------- | + | boolean | Whether the file is a block special file.| **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** @@ -2372,13 +2372,13 @@ Checks whether this file is a character special file. A character special file s **Return value** -| Type | Description | -| ------- | ----------------- | -| boolean | Whether the file is a character special file.| + | Type | Description | + | ------- | ----------------- | + | boolean | Whether the file is a character special file.| **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** @@ -2397,13 +2397,13 @@ Checks whether this file is a directory. **Return value** -| Type | Description | -| ------- | ------------- | -| boolean | Whether the file is a directory.| + | Type | Description | + | ------- | ------------- | + | boolean | Whether the file is a directory.| **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** @@ -2422,13 +2422,13 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int **Return value** -| Type | Description | -| ------- | --------------------- | -| boolean | Whether the file is a FIFO.| + | Type | Description | + | ------- | --------------------- | + | boolean | Whether the file is a FIFO.| **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** @@ -2447,13 +2447,13 @@ Checks whether this file is a regular file. **Return value** -| Type | Description | -| ------- | --------------- | -| boolean | Whether the file is a regular file.| + | Type | Description | + | ------- | --------------- | + | boolean | Whether the file is a regular file.| **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** @@ -2472,13 +2472,13 @@ Checks whether this file is a socket. **Return value** -| Type | Description | -| ------- | -------------- | -| boolean | Whether the file is a socket.| + | Type | Description | + | ------- | -------------- | + | boolean | Whether the file is a socket.| **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** @@ -2497,13 +2497,13 @@ Checks whether this file is a symbolic link. **Return value** -| Type | Description | -| ------- | --------------- | -| boolean | Whether the file is a symbolic link.| + | Type | Description | + | ------- | --------------- | + | boolean | Whether the file is a symbolic link.| **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** @@ -2526,13 +2526,13 @@ Closes the stream. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ------------- | -| Promise<void> | Promise used to return the stream close result.| + | Type | Description | + | ------------------- | ------------- | + | Promise<void> | Promise used to return the stream close result.| **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** @@ -2556,13 +2556,13 @@ Closes the stream. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ------------- | -| callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------- | + | callback | AsyncCallback<void> | Yes | Callback invoked immediately after the stream is closed.| **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** @@ -2573,7 +2573,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem if (err) { console.info("close stream failed with error message: " + err.message + ", error code: " + err.code); } else { - console.info("close stream success"): + console.info("close stream success"); } }); ``` @@ -2588,7 +2588,7 @@ Synchronously closes the stream. **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** @@ -2608,13 +2608,13 @@ Flushes the stream. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ------------- | -| Promise<void> | Promise used to return the stream flushing result.| + | Type | Description | + | ------------------- | ------------- | + | Promise<void> | Promise used to return the stream flushing result.| **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** @@ -2638,13 +2638,13 @@ Flushes the stream. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | -------------- | -| callback | AsyncCallback<void> | Yes | Callback invoked when the stream is asynchronously flushed.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | -------------- | + | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is asynchronously flushed.| **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** @@ -2670,7 +2670,7 @@ Synchronously flushes the stream. **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** @@ -2690,20 +2690,20 @@ Writes data into the stream. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to write. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **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.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to write. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **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** -| Type | Description | -| --------------------- | -------- | -| Promise<number> | Promise used to return the length of the data written.| + | Type | Description | + | --------------------- | -------- | + | Promise<number> | Promise used to return the length of the data written.| **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** @@ -2727,15 +2727,15 @@ Writes data into the stream. This API uses an asynchronous callback to return th **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| -| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | + | Name | Type | Mandatory| Description | + | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | **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** @@ -2763,20 +2763,20 @@ Synchronously writes data into the stream. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **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.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **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** -| Type | Description | -| ------ | -------- | -| number | Length of the data written in the file.| + | Type | Description | + | ------ | -------- | + | number | Length of the data written in the file.| **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** @@ -2796,20 +2796,20 @@ Reads data from the stream. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. By default, data is read from the current position.| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. By default, data is read from the current position.| **Return value** -| Type | Description | -| ---------------------------------- | ------ | -| Promise<number> | Promise used to return the data read.| + | Type | Description | + | ---------------------------------- | ------ | + | Promise<number> | Promise used to return the data read.| **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** @@ -2835,15 +2835,15 @@ Reads data from the stream. This API uses an asynchronous callback to return the **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.| -| callback | AsyncCallback<number> | Yes | Callback invoked when data is read asynchronously from the stream. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.| + | callback | AsyncCallback<number> | Yes | Callback invoked when data is read asynchronously from the stream. | **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** @@ -2871,20 +2871,20 @@ Synchronously reads data from the stream. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. By default, data is read from the current position.
| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. By default, data is read from the current position.
| **Return value** -| Type | Description | -| ------ | -------- | -| number | Length of the data read.| + | Type | Description | + | ------ | -------- | + | number | Length of the data read.| **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** @@ -2916,19 +2916,19 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A **Parameters** -| 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. | + | 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. | **Return value** -| Type | Description | -| ---------------------------------- | ------ | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ---------------------------------- | ------ | + | Promise<void> | Promise that returns no value.| **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** @@ -2951,14 +2951,14 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A **Parameters** -| 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. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is locked. | + | 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. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is locked. | **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** @@ -2983,13 +2983,13 @@ Applies an exclusive lock or a shared lock on this file in non-blocking mode. **Parameters** -| 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. | + | 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. | **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** @@ -3009,7 +3009,7 @@ Unlocks this file synchronously. **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** diff --git a/en/application-dev/reference/apis/js-apis-file-hash.md b/en/application-dev/reference/apis/js-apis-file-hash.md index eb9247ab3c..87592b5b9f 100644 --- a/en/application-dev/reference/apis/js-apis-file-hash.md +++ b/en/application-dev/reference/apis/js-apis-file-hash.md @@ -1,11 +1,10 @@ # @ohos.file.hash (File Hash Processing) -The **fileHash** module implements hash processing on files. +The **FileHash** module implements hash processing on files. > **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 APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +> 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 @@ -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: -**Stage Model** +Stage Model ```js import UIAbility from '@ohos.app.ability.UIAbility'; @@ -30,7 +29,7 @@ export default class EntryAbility extends UIAbility { } ``` -**FA Model** +FA Model ```js 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 | --------------------- | -------------------------- | | Promise<string> | 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** ```js @@ -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. | | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**. **sha256** is recommended for security purposes.| -| callback | AsyncCallback<string> | Yes | Callback used to return the hash value obtained. The hash value is a hexadecimal string consisting of digits and uppercase letters.| +| callback | AsyncCallback<string> | 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** + ```js let filePath = pathDir + "/test.txt"; Hash.hash(filePath, "sha256", (err, str) => { diff --git a/en/application-dev/reference/apis/js-apis-file-picker.md b/en/application-dev/reference/apis/js-apis-file-picker.md index c61b79455e..f08294549c 100644 --- a/en/application-dev/reference/apis/js-apis-file-picker.md +++ b/en/application-dev/reference/apis/js-apis-file-picker.md @@ -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. ## Modules to Import + ```js import picker from '@ohos.file.picker'; ``` diff --git a/en/application-dev/reference/apis/js-apis-file-securityLabel.md b/en/application-dev/reference/apis/js-apis-file-securityLabel.md index c564516e66..d0005ee159 100644 --- a/en/application-dev/reference/apis/js-apis-file-securityLabel.md +++ b/en/application-dev/reference/apis/js-apis-file-securityLabel.md @@ -4,8 +4,7 @@ The **securityLabel** module provides APIs for managing data security levels of > **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 APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +> 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 @@ -60,9 +59,24 @@ Sets a security label for a file in asynchronous mode. This API uses a promise t **Return value** -| Type | Description | -| ------------------- | ---------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------- | + | Promise<void> | 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** @@ -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**.| | callback | AsyncCallback<void> | 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** ```js @@ -119,6 +148,21 @@ Sets a security label for a file in synchronous mode. | 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**.| +**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** ```js @@ -136,15 +180,30 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------- | -| path | string | Yes | Path of the target file.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------- | + | path | string | Yes | Path of the target file.| **Return value** -| Type | Description | -| --------------------- | ------------ | -| Promise<string> | Security label obtained.| + | Type | Description | + | --------------------- | ------------ | + | Promise<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** @@ -167,10 +226,25 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------- | ---- | -------------------------- | -| path | string | Yes | Path of the target file. | -| callback | AsyncCallback<string> | Yes | Callback invoked to return the security label obtained.| + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | -------------------------- | + | path | string | Yes | Path of the target file. | + | callback | AsyncCallback<string> | 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** @@ -184,6 +258,7 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb } }); ``` + ## securityLabel.getSecurityLabelSync getSecurityLabelSync(path:string):string @@ -204,6 +279,21 @@ Obtains the security label of a file in synchronous mode. | ------ | ------------ | | 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** ```js diff --git a/en/application-dev/reference/apis/js-apis-file-statvfs.md b/en/application-dev/reference/apis/js-apis-file-statvfs.md index f431f3cb17..34282138f7 100644 --- a/en/application-dev/reference/apis/js-apis-file-statvfs.md +++ b/en/application-dev/reference/apis/js-apis-file-statvfs.md @@ -4,14 +4,14 @@ The **statfs** module provides APIs for obtaining file system information, inclu > **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 APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +> 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 ```js import statvfs from '@ohos.file.statvfs'; ``` + ## statvfs.getFreeSize getFreeSize(path:string):Promise<number> @@ -22,15 +22,19 @@ Obtains the number of free bytes of the specified file system in asynchronous mo **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------------------- | -| path | string | Yes | File path of the file system.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------------------- | + | path | string | Yes | File path of the file system.| **Return value** -| Type | Description | -| --------------------- | -------------- | -| Promise<number> | Promise used to return the number of free bytes obtained.| + | Type | Description | + | --------------------- | -------------- | + | Promise<number> | 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** @@ -53,10 +57,14 @@ Obtains the number of free bytes of the specified file system in asynchronous mo **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------- | ---- | ---------------------------- | -| path | string | Yes | File path of the file system.| -| callback | AsyncCallback<number> | Yes | Callback invoked to return the number of free bytes obtained.| + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | path | string | Yes | File path of the file system.| + | callback | AsyncCallback<number> | 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** @@ -81,15 +89,19 @@ Obtains the total number of bytes of the specified file system in asynchronous m **Parameters** -| Name| Type | Mandatory| Description | -| ---- | ------ | ---- | ---------------------------- | -| path | string | Yes | File path of the file system.| + | Name| Type | Mandatory| Description | + | ---- | ------ | ---- | ---------------------------- | + | path | string | Yes | File path of the file system.| **Return value** -| Type | Description | -| --------------------- | ------------ | -| Promise<number> | Promise used to return the total number of bytes obtained.| + | Type | Description | + | --------------------- | ------------ | + | Promise<number> | 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** @@ -112,10 +124,14 @@ Obtains the total number of bytes of the specified file system in asynchronous m **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------- | ---- | ---------------------------- | -| path | string | Yes | File path of the file system.| -| callback | AsyncCallback<number> | Yes | Callback invoked to return the total number of bytes obtained. | + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | path | string | Yes | File path of the file system.| + | callback | AsyncCallback<number> | 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** diff --git a/en/application-dev/reference/apis/js-apis-file-storage-statistics.md b/en/application-dev/reference/apis/js-apis-file-storage-statistics.md index 716e0da462..01ffbea245 100644 --- a/en/application-dev/reference/apis/js-apis-file-storage-statistics.md +++ b/en/application-dev/reference/apis/js-apis-file-storage-statistics.md @@ -4,8 +4,8 @@ The **storageStatistics** module provides APIs for obtaining storage space infor > **NOTE** > -> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +> 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. + ## Modules to Import ```js @@ -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. - **Parameters** | Name | Type | Mandatory| Description| @@ -37,6 +36,19 @@ Obtains the total size (in bytes) of the specified volume in an external storage | --------------------- | ---------------- | | Promise<number> | 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** ```js @@ -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. - **Parameters** | Name | Type | Mandatory| Description | @@ -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. | | callback | AsyncCallback<number> | 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** ```js @@ -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. - **Parameters** | Name | Type | Mandatory| Description| @@ -103,6 +126,19 @@ Obtains the available space (in bytes) of the specified volume in an external st | --------------------- | ------------------ | | Promise<number> | 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** ```js @@ -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. - **Parameters** | Name | Type | Mandatory| Description | @@ -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. | | callback | AsyncCallback<number> | 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** ```js @@ -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. - **Parameters** | Name | Type | Mandatory| Description | @@ -170,6 +217,19 @@ Obtains the space (in bytes) of an application. This API uses a promise to retur | ------------------------------------------ | -------------------------- | | Promise<[Bundlestats](#bundlestats9)> | 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** ```js @@ -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. - **Parameters** | Name | Type | Mandatory| Description | @@ -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.| | callback | AsyncCallback<[Bundlestats](#bundlestats9)> | 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** ```js @@ -225,6 +297,16 @@ Obtains the space (in bytes) of this third-party application. This API uses a pr | ------------------------------------------ | -------------------------- | | Promise<[Bundlestats](#bundlestats9)> | 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** ```js @@ -246,6 +328,16 @@ Obtains the space (in bytes) of this third-party application. This API uses an a | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | callback | AsyncCallback<[BundleStats](#bundlestats9)> | 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** ```js @@ -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. | | dataSize | number | Yes| No| Total data size of the application, in bytes.| - ## storageStatistics.getTotalSize9+ getTotalSize(): Promise<number> @@ -284,6 +375,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses a promi | --------------------- | ------------------ | | Promise<number> | 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** ```js @@ -309,6 +412,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn | -------- | ------------------------------------ | ---- | ------------------------ | | callback | AsyncCallback<number> | 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** ```js @@ -318,7 +433,6 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn }); ``` - ## storageStatistics.getFreeSize9+ getFreeSize(): Promise<number> @@ -337,6 +451,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a | --------------------- | ------------------ | | Promise<number> | 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** ```js @@ -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)); ``` - ## storageStatistics.getFreeSize9+ getFreeSize(callback: AsyncCallback<number>): void @@ -363,6 +488,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses an | -------- | ------------------------------------ | ---- | ------------------------- | | callback | AsyncCallback<number> | 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** ```js @@ -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. - **Return value** | Type | Description | | --------------------- | ---------------- | | Promise<number> | 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** ```js @@ -419,6 +567,18 @@ Obtains the system data space, in bytes. This API uses an asynchronous callback | ---------- | ------------------------------------ | ---- | -------------------------- | | callback | AsyncCallback<number> | 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** ```js @@ -446,6 +606,18 @@ Obtains the storage statistics (in bytes) of this user. This API uses a promise | --------------------- | ---------------- | | Promise<[StorageStats](#storagestats9)> | 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** ```js @@ -474,6 +646,18 @@ Obtains the storage statistics (in bytes) of this user. This API uses an asynchr | ---------- | ------------------------------------ | ---- | -------------------------- | | callback | AsyncCallback<[StorageStats](#storagestats9)> | 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** ```js @@ -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)); }); ``` + +## storageStatistics.getUserStorageStats9+ + getUserStorageStats(userId: number): Promise<StorageStats> 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 | --------------------- | ---------------- | | Promise<[StorageStats](#storagestats9)> | 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** ```js @@ -534,6 +734,19 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a | userId | number | Yes | User ID.| | callback | AsyncCallback<[StorageStats](#storagestats9)> | 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** ```js @@ -544,7 +757,6 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a }); ``` - ## StorageStats9+ **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics diff --git a/en/application-dev/reference/apis/js-apis-file-volumemanager.md b/en/application-dev/reference/apis/js-apis-file-volumemanager.md index c2628ce063..bec02a0f67 100644 --- a/en/application-dev/reference/apis/js-apis-file-volumemanager.md +++ b/en/application-dev/reference/apis/js-apis-file-volumemanager.md @@ -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 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 @@ -26,9 +25,21 @@ Obtains information about all volumes of this external storage device. This API **Return value** -| Type | Description | -| ---------------------------------- | -------------------------- | -| Promise<[Volume](#volume)[]> | Promise used to return information about all available volumes.| + | Type | Description | + | ---------------------------------- | -------------------------- | + | Promise<[Volume](#volume)[]> | 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** @@ -52,9 +63,21 @@ Obtains information about all volumes of this external storage device. This API **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------- | ---- | ------------------------------------ | -| callback | AsyncCallback<[Volume](#volume)[]> | Yes | Callback invoked to return information about all available volumes.| + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------------------- | ---- | ------------------------------------ | + | callback | AsyncCallback<[Volume](#volume)[]> | 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** @@ -65,7 +88,6 @@ Obtains information about all volumes of this external storage device. This API }); ``` - ## volumemanager.mount mount(volumeId: string): Promise<void> @@ -78,15 +100,31 @@ Asynchronously mounts a volume. This API uses a promise to return the result. Cu **Parameters** -| Name | Type | Mandatory| Description| -| -------- | ------ | ---- | ---- | -| volumeId | string | Yes | Volume ID.| + | Name | Type | Mandatory| Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes | Volume ID.| **Return value** -| Type | Description | -| ---------------------- | ---------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ---------------------- | ---------- | + | Promise<void> | 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** @@ -111,10 +149,26 @@ Asynchronously mounts a volume. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------- | ---- | -------------------- | -| volumeId | string | Yes | Volume ID. | -| callback | AsyncCallback<void> | Yes | Callback that returns no value.| + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | Yes | Volume ID. | + | callback | AsyncCallback<void> | 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** @@ -137,15 +191,31 @@ Asynchronously unmounts a volume. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory| Description| -| -------- | ------ | ---- | ---- | -| volumeId | string | Yes | Volume ID.| + | Name | Type | Mandatory| Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes | Volume ID.| **Return value** -| Type | Description | -| ---------------------- | ---------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ---------------------- | ---------- | + | Promise<void> | 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** @@ -170,10 +240,26 @@ Asynchronously unmounts a volume. This API uses an asynchronous callback to retu **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------- | ---- | -------------------- | -| volumeId | string | Yes | Volume ID. | -| callback | AsyncCallback<void> | Yes | Callback that returns no value.| + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | Yes | Volume ID. | + | callback | AsyncCallback<void> | 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** @@ -196,15 +282,28 @@ Obtains information about a volume based on the universally unique identifier (U **Parameters** -| Name | Type | Mandatory| Description| -| -------- | ------ | ---- | ---- | -| uuid | string | Yes | UUID of the volume.| + | Name | Type | Mandatory| Description| + | -------- | ------ | ---- | ---- | + | uuid | string | Yes | UUID of the volume.| **Return value** -| Type | Description | -| ---------------------------------- | -------------------------- | -| Promise<[Volume](#volume)> | Promise used to return the volume information obtained.| + | Type | Description | + | ---------------------------------- | -------------------------- | + | Promise<[Volume](#volume)> | 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** @@ -229,10 +328,23 @@ Obtains information about a volume based on the UUID. This API uses an asynchron **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------ | ---- | -------------------- | -| uuid | string | Yes | UUID of the volume. | -| callback | AsyncCallback<[Volume](#volume)> | Yes | Callback invoked to return the volume information obtained.| + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------------------ | ---- | -------------------- | + | uuid | string | Yes | UUID of the volume. | + | callback | AsyncCallback<[Volume](#volume)> | 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** @@ -255,15 +367,28 @@ Obtains information about a volume based on the volume ID. This API uses a promi **Parameters** -| Name | Type | Mandatory | Description| -| -------- | ------ | ---- | ---- | -| volumeId | string | Yes | Volume ID.| + | Name | Type | Mandatory | Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes | Volume ID.| **Return value** -| Type | Description | -| ---------------------------------- | -------------------------- | -| Promise<[Volume](#volume)> | Promise used to return the volume information obtained.| + | Type | Description | + | ---------------------------------- | -------------------------- | + | Promise<[Volume](#volume)> | 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** @@ -288,10 +413,23 @@ Obtains information about a volume based on the volume ID. This API uses an asyn **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------- | ---- | ----------------------------- | -| volumeId | string | Yes | Volume ID. | -| callback | AsyncCallback<[Volume](#volume)> | Yes | Callback invoked to return the volume information obtained. | + | Name | Type | Mandatory| Description | + | -------- | ------------------------- | ---- | ----------------------------- | + | volumeId | string | Yes | Volume ID. | + | callback | AsyncCallback<[Volume](#volume)> | 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** @@ -314,16 +452,31 @@ Sets volume description. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory| Description| -| --------- | ------ | ---- | ---- | -| uuid | string | Yes | UUID of the volume.| -| description | string | Yes | Volume description to set.| + | Name | Type | Mandatory| Description| + | --------- | ------ | ---- | ---- | + | uuid | string | Yes | UUID of the volume.| + | description | string | Yes | Volume description to set.| **Return value** -| Type | Description | -| ---------------------- | -------------------------- | -| Promise<void> | Promise that returns no value. | + | Type | Description | + | ---------------------- | -------------------------- | + | Promise<void> | 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** @@ -349,11 +502,26 @@ Sets volume description. This API uses an asynchronous callback to return the re **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | --------------------------------------- | ---- | ---------------- | -| uuid | string | Yes | UUID of the volume. | -| description | string | Yes | Volume description to set. | -| callback | AsyncCallback<void> | Yes | Callback that returns no value.| + | Name | Type | Mandatory| Description | + | ---------- | --------------------------------------- | ---- | ---------------- | + | uuid | string | Yes | UUID of the volume. | + | description | string | Yes | Volume description to set. | + | callback | AsyncCallback<void> | 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** @@ -377,16 +545,31 @@ Formats a volume. This API uses a promise to return the result. Currently, only **Parameters** -| Name | Type | Mandatory| Description| -| ----------- | ------ | ---- | ---- | -| volumeId | string | Yes | Volume ID.| -| fsType | string | Yes | File system type, which can be VFAT or exFAT.| + | Name | Type | Mandatory| Description| + | ----------- | ------ | ---- | ---- | + | volumeId | string | Yes | Volume ID.| + | fsType | string | Yes | File system type, which can be VFAT or exFAT.| **Return value** -| Type | Description | -| ---------------------- | ---------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ---------------------- | ---------- | + | Promise<void> | 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** @@ -412,11 +595,26 @@ Formats a volume. This API uses an asynchronous callback to return the result. C **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------- | ---- | ----------------------------- | -| volumeId | string | Yes | Volume ID. | -| fsType | string | Yes | File system type, which can be VFAT or exFAT.| -| callback | AsyncCallback<void> | Yes | Callback that returns no value. | + | Name | Type | Mandatory| Description | + | -------- | ------------------------- | ---- | ----------------------------- | + | volumeId | string | Yes | Volume ID. | + | fsType | string | Yes | File system type, which can be VFAT or exFAT.| + | callback | AsyncCallback<void> | 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** @@ -440,16 +638,29 @@ Partitions a disk. This API uses a promise to return the result. The system supp **Parameters** -| Name | Type | Mandatory| Description| -| ----------- | ------ | ---- | ---- | -| diskId | string | Yes | ID of the disk to partition.| -| type | number | Yes | Partition type. | + | Name | Type | Mandatory| Description| + | ----------- | ------ | ---- | ---- | + | diskId | string | Yes | ID of the disk to partition.| + | type | number | Yes | Partition type. | **Return value** -| Type | Description | -| --------------------- | ----------------------- | -| Promise<void> | Promise used to return the result. | + | Type | Description | + | --------------------- | ----------------------- | + | Promise<void> | 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** @@ -475,11 +686,24 @@ Asynchronously partitions a disk. This API uses a callback to return the result. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------------- | -| diskId | string | Yes | ID of the disk to partition. | -| type | number | Yes | Partition type. | -| callback | AsyncCallback<void> | Yes | Callback that returns no value. | + | Name | Type | Mandatory| Description | + | -------- | --------------------------------------- | ---- | ---------------- | + | diskId | string | Yes | ID of the disk to partition. | + | type | number | Yes | Partition type. | + | callback | AsyncCallback<void> | 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** diff --git a/en/application-dev/reference/apis/js-apis-fileShare.md b/en/application-dev/reference/apis/js-apis-fileShare.md index b9d9fb65f7..2d0d66de9f 100644 --- a/en/application-dev/reference/apis/js-apis-fileShare.md +++ b/en/application-dev/reference/apis/js-apis-fileShare.md @@ -1,6 +1,6 @@ -# @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** > @@ -9,7 +9,7 @@ The **fileShare** module provides APIs for granting the access permissions on a ## Modules to Import ```js -import fileShare from '@ohos.fileShare'; +import fileShare from '@ohos.fileshare'; ``` ## fileShare.grantUriPermission @@ -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.| | 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).
**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file.
**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.| -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | + | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | **Error codes** @@ -44,7 +44,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod | 401 | The input parameter is invalid | | 143000001 | IPC error | - **Example** ```js @@ -66,7 +65,6 @@ try { } ``` - ## fileShare.grantUriPermission grantUriPermission(uri: string, bundleName: string, mode: number): Promise<void> @@ -89,10 +87,9 @@ Grants permissions on a user file by the URI to an application. This API uses a **Return value** -| Type | Description | -| ---------------------------- | ---------- | -| Promise<void> | Promise that returns no value.| - + | Type | Description | + | ---------------------------- | ---------- | + | Promise<void> | Promise that returns no value.| **Error codes** @@ -105,7 +102,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod | 401 | The input parameter is invalid | | 143000001 | IPC error | - **Example** ```js diff --git a/en/application-dev/reference/apis/js-apis-userFileManager.md b/en/application-dev/reference/apis/js-apis-userFileManager.md index 04df43b345..a676fb1f3b 100644 --- a/en/application-dev/reference/apis/js-apis-userFileManager.md +++ b/en/application-dev/reference/apis/js-apis-userFileManager.md @@ -4,8 +4,8 @@ The **userFileManager** module provides user data management capabilities, inclu > **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 APIs provided by this module are system APIs. +> - 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. ## Modules to Import @@ -49,11 +49,8 @@ let mgr = userFileManager.getUserFileMgr(context); getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void; - Obtains image and video assets. This API uses an asynchronous callback to return the result. - - **System capability**: SystemCapability.FileManagement.UserFileManager.Core **Required permissions**: ohos.permission.READ_IMAGEVIDEO @@ -92,7 +89,6 @@ async function example() { } ``` - ### getPhotoAssets getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>; @@ -141,6 +137,7 @@ async function example() { } } ``` + ### createPhotoAsset createPhotoAsset(displayName: string, albumUri: string, callback: AsyncCallback<FileAsset>): void; @@ -261,7 +258,6 @@ async function example() { getPhotoAlbums(options: AlbumFetchOptions, callback: AsyncCallback<FetchResult<Album>>): void; - Obtains image and video albums. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.UserFileManager.Core @@ -352,7 +348,6 @@ async function example() { getPrivateAlbum(type: PrivateAlbumType, callback: AsyncCallback<FetchResult<PrivateAlbum>>): void; - Obtains the system album. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.UserFileManager.Core @@ -424,7 +419,6 @@ async function example() { getAudioAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void; - Obtains audio assets. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.UserFileManager.Core @@ -469,7 +463,6 @@ async function example() { getAudioAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>; - Obtains audio assets. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.UserFileManager.Core @@ -515,6 +508,7 @@ async function example() { } } ``` + ### delete delete(uri: string, callback: AsyncCallback<void>): void; @@ -564,6 +558,7 @@ async function example() { }); } ``` + ### delete delete(uri: string): Promise<void>; @@ -675,8 +670,8 @@ Unsubscribes from changes of the file management library. This API uses a callba | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| type | [ChangeEvent](#changeevent) | Yes | Type of event to unsubscribe from.
**deviceChange** indicates the device change.
**albumChange** indicates the album change.
**imageChange** indicates the image change.
**audioChange** indicates the audio file change.
**videoChange** indicates the video file change.
**remoteFileChange** indicates the file change on the registered device. | -| callback | Callback<void> | No | Callback for the change. | +| type | [ChangeEvent](#changeevent) | Yes | Type of event to subscribe to.
**deviceChange** indicates the device change.
**albumChange** indicates the album change.
**imageChange** indicates the image change.
**audioChange** indicates the audio file change.
**videoChange** indicates the video file change.
**remoteFileChange** indicates the file change on the registered device.| +| callback | Callback<void> | No | Callback that returns no value. | **Example** @@ -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 - **System capability**: SystemCapability.FileManagement.UserFileManager.Core **Parameters** @@ -1923,6 +1917,7 @@ async function example() { }); } ``` + ### getPhotoAssets getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>; @@ -2106,6 +2101,7 @@ async function example() { } ``` + ### getPhotoAssets getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>; @@ -2147,6 +2143,7 @@ async function example() { console.info('fetchResult.count = ', count); } ``` + ### delete delete(uri: string, callback: AsyncCallback<void>): void; @@ -2190,6 +2187,7 @@ async function example() { }); } ``` + ### delete delete(uri: string): Promise<void>; @@ -2280,6 +2278,7 @@ async function example() { }); } ``` + ### recover recover(uri: string): Promise<void>; @@ -2366,7 +2365,6 @@ Defines information about a registered device. | networkId | string | Yes | No | Network ID of the registered device.| | isOnline | boolean | Yes | No | Whether the registered device is online. | - ## FileType Enumerates media file types. @@ -2390,8 +2388,6 @@ Enumerates the system album types. | TYPE_FAVORITE | 0 | Favorites.| | TYPE_TRASH | 1 | Recycle bin.| - - ## AudioKey Defines the key information about an audio file. @@ -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_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 Defines the options for fetching media files. diff --git a/en/application-dev/reference/errorcodes/errorcode-filemanagement.md b/en/application-dev/reference/errorcodes/errorcode-filemanagement.md index 4f45c7d005..219f564605 100644 --- a/en/application-dev/reference/errorcodes/errorcode-filemanagement.md +++ b/en/application-dev/reference/errorcodes/errorcode-filemanagement.md @@ -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). -The error codes of the file management subsystem consist of the following:
- Basic file I/O error codes
- User data management error codes
- User file access error codes
- 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 @@ -49,6 +54,7 @@ The process does not exist. **Solution** 1. Check whether the process is killed unexpectedly. + 2. Check whether the service related to the process has started. ### 13900004 System Call Interrupted @@ -64,6 +70,7 @@ The system call is interrupted by another thread. **Solution** 1. Check the multi-thread code logic. + 2. Invoke the system call again. ### 13900005 I/O Error @@ -161,7 +168,9 @@ Out of memory A memory overflow occurs. **Solution** + 1. Check the memory overhead. + 2. Control the memory overhead. ### 13900012 Permission Denied @@ -172,13 +181,14 @@ Permission denied **Possible Causes** - - 1. You do not have the permission to operate the file. + 2. The file sandbox path is incorrect. **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. ### 13900013 Incorrect Address @@ -375,7 +385,7 @@ Seek is used in pipe or FIFO. **Solution** -Check the use of seek. +Check the use of **seek()**. ### 13900027 Read-Only File System @@ -460,6 +470,7 @@ The specified directory is not empty. **Solution** 1. Check the directory. + 2. Ensure that the directory is empty. ### 13900033 Too Many Symbol Links @@ -516,7 +527,7 @@ The device pointed to by the file descriptor is not a character stream device. **Solution** -Check whether the file descriptor points to a stream device. +Check whether the file descriptor points to a stream. ### 13900037 No Data Available @@ -599,7 +610,9 @@ Unknown error The error is unidentified. **Solution** + 1. Call the API again. + 2. Restart the service. ## User Data Management Error Codes @@ -636,7 +649,7 @@ Use the obtained URI. **Error Message** -Invalid file extension +Invalid file name extension **Possible Causes** @@ -660,7 +673,7 @@ The file is moved to the Recycle Bin. Check whether the file is in the Recycle Bin. -## Spatial Statistics Error Codes +## Space Statistics Error Codes ### 13600001 IPC Failed @@ -680,7 +693,7 @@ Check whether the service is started. **Error Message** -Not supported file system +Not supported filesystem **Possible Causes** @@ -767,11 +780,15 @@ Check whether the specified directory or node exists. No such object **Possible Causes** + 1. The specified volume ID is incorrect. + 2. The specified bundle name is incorrect. **Solution** + 1. Check whether the specified volume exists. + 2. Check whether the specified bundle name exists. ### 13600009 Invalid User ID @@ -799,6 +816,7 @@ IPC error **Possible Causes** 1. The server service does not exist. + 2. The extension mechanism is abnormal. **Solution** @@ -854,7 +872,9 @@ Check the data returned by the server. Fail to register notification **Possible Causes** + 1. The server service does not exist. + 2. The extension mechanism is abnormal. **Solution** @@ -868,7 +888,9 @@ Check that the server service exists. Fail to remove notification **Possible Causes** + 1. The server service does not exist. + 2. The extension mechanism is abnormal. **Solution** @@ -896,47 +918,11 @@ Check whether the specified Notify agent is registered. Fail to notify agent **Possible Causes** + 1. The service does not exist. + 2. The extension mechanism is abnormal. **Solution** 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); -} -``` diff --git a/en/release-notes/changelogs/v3.2-beta5/changelogs-filemanagement.md b/en/release-notes/changelogs/v3.2-beta5/changelogs-filemanagement.md index d032a9fe06..850e9a739a 100644 --- a/en/release-notes/changelogs/v3.2-beta5/changelogs-filemanagement.md +++ b/en/release-notes/changelogs/v3.2-beta5/changelogs-filemanagement.md @@ -2,11 +2,11 @@ ## 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** -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](../v3.2-beta4/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](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** @@ -24,11 +24,11 @@ import environment from '@ohos.file.environment'; ## 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** -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](../v3.2-beta4/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](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** @@ -58,11 +58,11 @@ The type of the **ino** attribute of **Stat** is changed from number to BigInt. ## 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** -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](../v3.2-beta4/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](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** @@ -80,11 +80,11 @@ import fileAccess from '@ohos.file.fileAccess'; ## 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** -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](../v3.2-beta4/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](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** @@ -102,11 +102,11 @@ import fileExtensionInfo from '@ohos.file.fileExtensionInfo'; ## 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** -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](../v3.2-beta4/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](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** @@ -124,11 +124,11 @@ import storageStatistics from '@ohos.file.storageStatistics'; ## 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** -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](../v3.2-beta4/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](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** -- GitLab