@@ -17,15 +17,31 @@ import fileio from '@ohos.fileio';
Before using the APIs provided by this module to perform operations on files or directories, obtain the path of the application sandbox as follows:
Stage Model
```js
importAbilityfrom'@ohos.application.Ability';
classMainAbilityextendsAbility{
onWindowStageCreate(windowStage){
letcontext=this.context;
letpath=context.filesDir;
}
}
```
For details about how to obtain the stage model context, see [Stage Model](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-ability-context.md#abilitycontext).
For details about how to obtain the context of the FA model, see [FA Model](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-Context.md#context).
## fileio.stat
...
...
@@ -654,7 +670,7 @@ Reads data from a file. This API uses a promise to return the result.
| path | string | Yes | Application sandbox path of the file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
| callback | AsyncCallback<[Stream](#stream7)> | Yes | Callback invoked when the stream is open asynchronously. |
| callback | AsyncCallback<[Stream](#stream)> | Yes | Callback invoked when the stream is open asynchronously. |
**Example**
...
...
@@ -2216,7 +2232,7 @@ Synchronously opens a stream based on the file path.
| Type | Description |
| ------------------ | --------- |
| [Stream](#stream7) | Stream opened.|
| [Stream](#stream) | Stream opened.|
**Example**
...
...
@@ -2244,7 +2260,7 @@ Opens a file stream based on the file descriptor. This API uses a promise to ret
| Type | Description |
| --------------------------------- | --------- |
| Promise<[Stream](#stream7)> | Promise used to return the result.|
| Promise<[Stream](#stream)> | Promise used to return the result.|
**Example**
...
...
@@ -2272,7 +2288,7 @@ Opens a file stream based on the file descriptor. This API uses an asynchronous
| fd | number | Yes | File descriptor of the target file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
| callback | AsyncCallback <[Stream](#stream7)> | Yes | Callback invoked when the stream is open asynchronously. |
| callback | AsyncCallback <[Stream](#stream)> | Yes | Callback invoked when the stream is open asynchronously. |
**Example**
...
...
@@ -2303,7 +2319,7 @@ Synchronously opens a stream based on the file descriptor.
| Type | Description |
| ------------------ | --------- |
| [Stream](#stream7) | Stream opened.|
| [Stream](#stream) | Stream opened.|
**Example**
...
...
@@ -2720,7 +2736,7 @@ Stops the **watcher** instance. This API uses a promise to return the result.
The **secuityLabel** module provides APIs to manage file data security levels, including obtaining and setting file data security levels.
> **NOTE**<br/>
> 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 **secuityLabel** module provides APIs to manage file data security levels, including obtaining and setting file data security levels.
## Modules to Import
```js
...
...
@@ -48,8 +48,7 @@ Sets the security label for a file in asynchronous mode. This API uses a promise
The **storageStatistics** module provides APIs for obtaining storage space information, including the space of built-in and plug-in memory cards, space occupied by different types of data, and space of application data.
> **NOTE**<br/>
>
> - 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.
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
The **storageStatistics** module provides APIs for obtaining storage space information, including the space of built-in and plug-in memory cards, space occupied by different types of data, and space of application data.
## Modules to Import
```js
...
...
@@ -264,14 +264,13 @@ Asynchronously obtains space information of the current third-party application.