提交 594bf54c 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 90d0893c
......@@ -138,7 +138,7 @@
- [@ohos.bundle.bundleManager](js-apis-bundleManager.md)
- [@ohos.bundle.bundleMonitor](js-apis-bundleMonitor.md)
- [@ohos.bundle.defaultAppManager](js-apis-defaultAppManager.md)
- [@ohos.bundle.distributedBundle](js-apis-distributedBundle.md)
- [@ohos.bundle.distributedBundleManager (distributedBundleManager)](js-apis-distributedBundleManager.md)
- [@ohos.bundle.freeInstall](js-apis-freeInstall.md)
- [@ohos.bundle.installer](js-apis-installer.md)
- [@ohos.bundle.launcherBundleManager](js-apis-launcherBundleManager.md)
......@@ -210,22 +210,21 @@
- [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md)
- [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md)
- [@ohos.data.rdb (RDB)](js-apis-data-rdb.md)
- [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md)
- [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
- data/rdb
- [resultSet](js-apis-data-resultset.md)
- File Management
- [@ohos.document](js-apis-document.md)
- [@ohos.environment](js-apis-environment.md)
- [@ohos.data.fileAccess](js-apis-fileAccess.md)
- [@ohos.fileExtensionInfo](js-apis-fileExtensionInfo.md)
- [@ohos.fileio](js-apis-fileio.md)
- [@ohos.filemanagement.userFileManager](js-apis-userFileManager.md)
- [@ohos.multimedia.medialibrary](js-apis-medialibrary.md)
- [@ohos.securityLabel](js-apis-securityLabel.md)
- [@ohos.statfs](js-apis-statfs.md)
- [@ohos.storageStatistics](js-apis-storage-statistics.md)
- [@ohos.volumeManager](js-apis-volumemanager.md)
- [@ohos.data.fileAccess (User File Access and Management)](js-apis-fileAccess.md)
- [@ohos.fileExtensionInfo (User File Access and Management Attributes)](js-apis-fileExtensionInfo.md)
- [@ohos.fileio (File Management)](js-apis-fileio.md)
- [@ohos.filemanagement.userFileManager (User Data Management)](js-apis-userFileManager.md)
- [@ohos.multimedia.medialibrary (Media Library Management)](js-apis-medialibrary.md)
- [@ohos.securityLabel (Data Label)](js-apis-securityLabel.md)
- [@ohos.statfs (statfs)](js-apis-statfs.md)
- [@ohos.storageStatistics (Application Storage Statistics)](js-apis-storage-statistics.md)
- [@ohos.volumeManager (Volume Management)](js-apis-volumemanager.md)
- Telephony Service
- [@ohos.contact](js-apis-contact.md)
- [@ohos.telephony.call](js-apis-call.md)
......@@ -357,10 +356,11 @@
- [@ohos.bundle.innerBundleManager](js-apis-Bundle-InnerBundleManager.md)
- [@ohos.bundleState](js-apis-deviceUsageStatistics.md)
- [@ohos.bytrace](js-apis-bytrace.md)
- [@ohos.data.storage](js-apis-data-storage.md)
- [@ohos.data.distributedData](js-apis-distributed-data.md)
- [@ohos.data.distributedData (Distributed Data Management)](js-apis-distributed-data.md)
- [@ohos.data.storage (Lightweight Data Storage)](js-apis-data-storage.md)
- [@ohos.data.rdb (RDB)](js-apis-data-rdb.md)
- [@ohos.distributedBundle](js-apis-Bundle-distributedBundle.md)
- [@ohos.document](js-apis-document.md)
- [@ohos.document (File Operation)](js-apis-document.md)
- [@ohos.geolocation](js-apis-geolocation.md)
- [@ohos.hiAppEvent](js-apis-hiappevent.md)
- [@ohos.prompt](js-apis-prompt.md)
......
# @ohos.data.relationalStore
# @ohos.data.relationalStore (RDB Store)
The relational database (RDB) store manages data based on relational models. With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements.
......
# @ohos.data.storage
# @ohos.data.storage (Lightweight Data Storage)
The **DataStorage** module provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value (KV) pairs. Keys are of the string type, and values can be of the number, string, or Boolean type.
......
# File Interaction
# @ohos.document (File Operation)
> **NOTE**<br/>
> **NOTE**
>
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module have been deprecated since API version 9 and are not recommended for use. An exception will be thrown if any of the APIs is called.
> - The APIs provided by this module have been deprecated since API version 9 and are not recommended for use. An exception will be thrown if any of the APIs is called.
## Modules to Import
......@@ -12,7 +13,7 @@ import document from '@ohos.document';
## document.choose<sup>(deprecated)</sup>
choose(types? : string[]): Promise&lt;string&gt;
choose(types?: string[]): Promise&lt;string&gt;
Chooses files of the specified types using the file manager. This API uses a promise to return the result.
......
# @ohos.data.fileAccess
# @ohos.data.fileAccess (User File Access and Management)
The **fileAccess** module is a framework for accessing and operating user files based on the Extension ability mechanism. This module interacts with diverse file management services, such as the media library and external storage management service, and provides a set of file access and management APIs for system applications. The media library service allows access to user files on local devices and distributed devices. The external storage management service allows access to the user files stored on devices such as shared disks, USB flash drives, and SD cards.
......
# @ohos.fileExtensionInfo
# @ohos.fileExtensionInfo (User File Access and Management Attributes)
The **fileExtensionInfo** module defines attributes in **RootInfo** and **FileInfo** of the user file access and management module.
......
# File Management
# @ohos.fileio (File Management)
The **fileio** module provides APIs for file storage and management, including basic file management, directory management, file information statistics, and stream read and write.
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -20,8 +21,9 @@ Before using the APIs provided by this module to perform operations on files or
Stage Model
```js
import Ability from '@ohos.application.Ability';
class MainAbility extends Ability {
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
let context = this.context;
let pathDir = context.filesDir;
......@@ -29,19 +31,20 @@ class MainAbility extends Ability {
}
```
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 stage model context, see [AbilityContext](js-apis-ability-context.md#abilitycontext).
FA Model
```js
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getFilesDir().then((data) => {
let pathDir = data;
})
```
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).
For details about how to obtain the FA model context, see [Contex](js-apis-inner-app-context.md#context).
## fileio.stat
......@@ -67,10 +70,10 @@ Obtains file information. This API uses a promise to return the result.
```js
let filePath = pathDir + "test.txt";
fileio.stat(filePath).then(function(stat){
console.info("Got file info:"+ JSON.stringify(stat));
}).catch(function(err){
console.info("Failed to get file info. Error:"+ err);
fileio.stat(filePath).then(function (stat) {
console.info("getFileInfo succeed, the size of file is " + stat.size);
}).catch(function (err) {
console.info("getFileInfo failed with error:" + err);
});
```
......@@ -152,10 +155,10 @@ Opens a file directory. This API uses a promise to return the result.
```js
let dirPath = pathDir + "/testDir";
fileio.opendir(dirPath).then(function(dir){
console.info("Directory opened:"+ JSON.stringify(dir));
}).catch(function(err){
console.info("Failed to open the directory. Error:"+ err);
fileio.opendir(dirPath).then(function (dir) {
console.info("opendir succeed");
}).catch(function (err) {
console.info("opendir failed with error:" + err);
});
```
......@@ -240,17 +243,17 @@ Checks whether the current process can access a file. This API uses a promise to
```js
let filePath = pathDir + "/test.txt";
fileio.access(filePath).then(function() {
fileio.access(filePath).then(function () {
console.info("Access successful");
}).catch(function(err){
console.info("Access failed. Error:"+ err);
}).catch(function (err) {
console.info("access failed with error:" + err);
});
```
## fileio.access
access(path: string, mode: number, callback: AsyncCallback&lt;void&gt;): void
access(path: string, mode?: number, callback: AsyncCallback&lt;void&gt;): void
Checks whether the current process can access a file. This API uses an asynchronous callback to return the result.
......@@ -296,7 +299,7 @@ Synchronously checks whether the current process can access the specified file.
try {
fileio.accessSync(filePath);
} catch(err) {
console.info("accessSync failed with error:"+ err);
console.info("accessSync failed with error:" + err);
}
```
......@@ -326,10 +329,10 @@ Closes a file. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
fileio.close(fd).then(function(){
fileio.close(fd).then(function () {
console.info("File closed");
}).catch(function(err){
console.info("Failed to close the file. Error:"+ err);
}).catch(function (err) {
console.info("close file failed with error:" + err);
});
```
......@@ -385,7 +388,7 @@ Synchronously closes a file.
## fileio.copyFile
copyFile(src: string | number, dest: string | number, mode?: number): Promise&lt;void&gt;
copyFile(src: string|number, dest: string|number, mode?: number): Promise&lt;void&gt;
Copies a file. This API uses a promise to return the result.
......@@ -395,8 +398,8 @@ Copies a file. This API uses a promise to return the result.
| Name | Type | Mandatory | Description |
| ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string&nbsp;\|&nbsp;number | Yes | Path or file descriptor of the file to copy. |
| dest | string&nbsp;\|&nbsp;number | Yes | Path or file descriptor of the new file. |
| src | string\|number | Yes | Path or file descriptor of the file to copy. |
| dest | string\|number | Yes | Path or file descriptor of the new file. |
| mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
**Return value**
......@@ -410,17 +413,17 @@ Copies a file. This API uses a promise to return the result.
```js
let srcPath = pathDir + "srcDir/test.txt";
let dstPath = pathDir + "dstDir/test.txt";
fileio.copyFile(srcPath, dstPath).then(function(){
fileio.copyFile(srcPath, dstPath).then(function () {
console.info("File copied");
}).catch(function(err){
console.info("Failed to copy the file. Error:"+ err);
}).catch(function (err) {
console.info("copyFile failed with error:" + err);
});
```
## fileio.copyFile
copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback&lt;void&gt;): void
copyFile(src: string|number, dest: string|number, mode: number, callback: AsyncCallback&lt;void&gt;): void
Copies a file. This API uses an asynchronous callback to return the result.
......@@ -430,8 +433,8 @@ Copies a file. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ---------------------------------------- |
| src | string&nbsp;\|&nbsp;number | Yes | Path or file descriptor of the file to copy. |
| dest | string&nbsp;\|&nbsp;number | Yes | Path or file descriptor of the new file. |
| src | string\|number | Yes | Path or file descriptor of the file to copy. |
| dest | string\|number | Yes | Path or file descriptor of the new file. |
| mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is copied asynchronously. |
......@@ -448,7 +451,7 @@ Copies a file. This API uses an asynchronous callback to return the result.
## fileio.copyFileSync
copyFileSync(src: string | number, dest: string | number, mode?: number): void
copyFileSync(src: string|number, dest: string|number, mode?: number): void
Synchronously copies a file.
......@@ -458,8 +461,8 @@ Synchronously copies a file.
| Name | Type | Mandatory | Description |
| ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string&nbsp;\|&nbsp;number | Yes | Path or file descriptor of the file to copy. |
| dest | string&nbsp;\|&nbsp;number | Yes | Path or file descriptor of the new file. |
| src | string\|number | Yes | Path or file descriptor of the file to copy. |
| dest | string\|number | Yes | Path or file descriptor of the new file. |
| mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
**Example**
......@@ -496,10 +499,10 @@ Creates a directory. This API uses a promise to return the result.
```js
let dirPath = pathDir + '/testDir';
fileio.mkdir(dirPath).then(function() {
fileio.mkdir(dirPath).then(function () {
console.info("Directory created");
}).catch(function (error){
console.info("Failed to create the directory. Error:"+ error);
}).catch(function (error) {
console.info("mkdir failed with error:" + error);
});
```
......@@ -524,7 +527,7 @@ Creates a directory. This API uses an asynchronous callback to return the result
```js
let dirPath = pathDir + '/testDir';
fileio.mkdir(dirPath, function(err) {
fileio.mkdir(dirPath, function (err) {
console.info("Directory created");
});
```
......@@ -579,10 +582,10 @@ Opens a file. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
fileio.open(filePath, 0o1, 0o0200).then(function(number){
fileio.open(filePath, 0o1, 0o0200).then(function (number) {
console.info("File opened");
}).catch(function(err){
console.info("Failed to open the file. Error:"+ err);
}).catch(function (err) {
console.info("open file failed with error:" + err);
});
```
......@@ -602,13 +605,13 @@ Opens a file. This API uses an asynchronous callback to return the result.
| path | string | Yes | Application sandbox path of the file. |
| flags | number | No | Option for opening the file. You must specify one of the following options. By default, the file is open in read-only mode.<br>-&nbsp;**0o0**: Open the file in read-only mode.<br>-&nbsp;**0o1**: Open the file in write-only mode.<br>-&nbsp;**0o2**: Open the file in read/write mode.<br>In addition, you can specify the following options, separated using a bitwise OR operator (&#124;). By default, no additional option is specified.<br>-&nbsp;**0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.<br>-&nbsp;**0o200**: If **0o100** is added and the file already exists, throw an exception.<br>-&nbsp;**0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.<br>-&nbsp;**0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).<br>-&nbsp;**0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.<br>-&nbsp;**0o200000**: If **path** does not point to a directory, throw an exception.<br><br>-&nbsp;**0o400000**: If **path** points to a symbolic link, throw an exception.<br>-&nbsp;**0o4010000**: Open the file in synchronous I/O mode.|
| mode | number | No | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (&#124;). The default value is **0o666**.<br>-&nbsp;**0o666**: The owner, user group, and other users have the read and write permissions on the file.<br>-&nbsp;**0o700**: The owner has the read, write, and execute permissions.<br>- &nbsp;**0o400**: The owner has the read permission.<br>-&nbsp;**0o200**: The owner has the write permission.<br>-&nbsp;**0o100**: The owner has the execute permission.<br>-&nbsp;**0o070**: The user group has the read, write, and execute permissions.<br>-&nbsp;**0o040**: The user group has the read permission.<br>-&nbsp;**0o020**: The user group has the write permission.<br>-&nbsp;**0o010**: The user group has the execute permission.<br>-&nbsp;**0o007**: Other users have the read, write, and execute permissions.<br>-&nbsp;**0o004**: Other users have the read permission.<br>-&nbsp;**0o002**: Other users have the write permission.<br>-&nbsp;**0o001**: Other users have the execute permission.|
| callback | AsyncCallback&nbsp;&lt;void&gt; | Yes | Callback invoked when the file is open asynchronously. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the file is open asynchronously. |
**Example**
```js
let filePath = pathDir + "/test.txt";
fileio.open(filePath, 0, function(err, fd) {
fileio.open(filePath, 0, function (err, fd) {
// Do something.
});
```
......@@ -655,11 +658,7 @@ Synchronously opens a file.
## fileio.read
read(fd: number, buffer: ArrayBuffer, options?: {
offset?: number;
length?: number;
position?: number;
}): Promise&lt;ReadOut&gt;
read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: number; position?: number; }): Promise&lt;ReadOut&gt;
Reads data from a file. This API uses a promise to return the result.
......@@ -685,22 +684,18 @@ Reads data from a file. This API uses a promise to return the result.
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath, 0o2);
let buf = new ArrayBuffer(4096);
fileio.read(fd, buf).then(function(readOut){
fileio.read(fd, buf).then(function (readOut) {
console.info("Read file data successfully");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
}).catch(function(err){
console.info("Failed to read file data. Error:"+ err);
}).catch(function (err) {
console.info("read file data failed with error:" + err);
});
```
## fileio.read
read(fd: number, buffer: ArrayBuffer, options: {
offset?: number;
length?: number;
position?: number;
}, callback: AsyncCallback&lt;ReadOut&gt;): void
read(fd: number, buffer: ArrayBuffer, options: { offset?: number; length?: number; position?: number; }, callback: AsyncCallback&lt;ReadOut&gt;): void
Reads data from a file. This API uses an asynchronous callback to return the result.
......@@ -732,11 +727,7 @@ Reads data from a file. This API uses an asynchronous callback to return the res
## fileio.readSync
readSync(fd: number, buffer: ArrayBuffer, options?: {
offset?: number;
length?: number;
position?: number;
}): number
readSync(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: number; position?: number; }): number
Synchronously reads data from a file.
......@@ -790,10 +781,10 @@ Deletes a directory. This API uses a promise to return the result.
```js
let dirPath = pathDir + '/testDir';
fileio.rmdir(dirPath).then(function() {
fileio.rmdir(dirPath).then(function () {
console.info("Directory deleted");
}).catch(function(err){
console.info("Failed to delete the directory. Error:"+ err);
}).catch(function (err) {
console.info("rmdir failed with error:" + err);
});
```
......@@ -817,7 +808,7 @@ Deletes a directory. This API uses an asynchronous callback to return the result
```js
let dirPath = pathDir + '/testDir';
fileio.rmdir(dirPath, function(err){
fileio.rmdir(dirPath, function (err) {
// Do something.
console.info("Directory deleted");
});
......@@ -870,10 +861,10 @@ Deletes a file. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
fileio.unlink(filePath).then(function(){
fileio.unlink(filePath).then(function () {
console.info("File deleted");
}).catch(function(error){
console.info("Failed to delete the file. Error:"+ error);
}).catch(function (error) {
console.info("remove file failed with error:" + error);
});
```
......@@ -897,7 +888,7 @@ Deletes a file. This API uses an asynchronous callback to return the result.
```js
let filePath = pathDir + "/test.txt";
fileio.unlink(filePath, function(err) {
fileio.unlink(filePath, function (err) {
console.info("File deleted");
});
```
......@@ -927,12 +918,7 @@ Synchronously deletes a file.
## fileio.write
write(fd: number, buffer: ArrayBuffer | string, options?: {
offset?: number;
length?: number;
position?: number;
encoding?: string;
}): Promise&lt;number&gt;
write(fd: number, buffer: ArrayBuffer|string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): Promise&lt;number&gt;
Writes data into a file. This API uses a promise to return the result.
......@@ -943,7 +929,7 @@ Writes data into a file. This API uses a promise to return the result.
| Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the file to write. |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>-&nbsp;**offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>-&nbsp;**length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>-&nbsp;**position** (number): start position to write the data in the file. By default, data is written from the current position.<br>-&nbsp;**encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>Constraints: offset + length <= Buffer size|
**Return value**
......@@ -957,22 +943,17 @@ Writes data into a file. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath, 0o100 | 0o2, 0o666);
fileio.write(fd, "hello, world").then(function(number){
console.info("Data written to the file. Size is:"+ number);
}).catch(function(err){
console.info("Failed to write data to the file. Error:"+ err);
fileio.write(fd, "hello, world").then(function (number) {
console.info("write data to file succeed and size is:" + number);
}).catch(function (err) {
console.info("write data to file failed with error:" + err);
});
```
## fileio.write
write(fd: number, buffer: ArrayBuffer | string, options: {
offset?: number;
length?: number;
position?: number;
encoding?: string;
}, callback: AsyncCallback&lt;number&gt;): void
write(fd: number, buffer: ArrayBuffer|string, options: { offset?: number; length?: number; position?: number; encoding?: string; }, callback: AsyncCallback&lt;number&gt;): void
Writes data into a file. This API uses an asynchronous callback to return the result.
......@@ -983,7 +964,7 @@ Writes data into a file. This API uses an asynchronous callback to return the re
| Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the file to write. |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>-&nbsp;**offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>-&nbsp;**length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>-&nbsp;**position** (number): start position to write the data in the file. By default, data is written from the current position.<br>-&nbsp;**encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>Constraints: offset + length <= Buffer size|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. |
......@@ -994,7 +975,7 @@ Writes data into a file. This API uses an asynchronous callback to return the re
let fd = fileio.openSync(filePath, 0o100 | 0o2, 0o666);
fileio.write(fd, "hello, world", function (err, bytesWritten) {
if (bytesWritten) {
console.info("Data written to the file. Size is:"+ bytesWritten);
console.info("write data to file succeed and size is:" + bytesWritten);
}
});
```
......@@ -1002,12 +983,7 @@ Writes data into a file. This API uses an asynchronous callback to return the re
## fileio.writeSync
writeSync(fd: number, buffer: ArrayBuffer | string, options?: {
offset?: number;
length?: number;
position?: number;
encoding?: string;
}): number
writeSync(fd: number, buffer: ArrayBuffer|string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): number
Synchronously writes data into a file.
......@@ -1018,7 +994,7 @@ Synchronously writes data into a file.
| Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the file to write. |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>-&nbsp;**offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>-&nbsp;**length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>-&nbsp;**position** (number): start position to write the data in the file. By default, data is written from the current position.<br>-&nbsp;**encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>Constraints: offset + length <= Buffer size|
**Return value**
......@@ -1061,10 +1037,10 @@ Calculates the hash value of a file. This API uses a promise to return the resul
```js
let filePath = pathDir + "/test.txt";
fileio.hash(filePath, "sha256").then(function(str){
console.info("Calculated file hash:"+ str);
}).catch(function(err){
console.info("Failed to calculate the file hash. Error:"+ err);
fileio.hash(filePath, "sha256").then(function (str) {
console.info("calculate file hash succeed:" + str);
}).catch(function (err) {
console.info("calculate file hash failed with error:" + err);
});
```
......@@ -1089,9 +1065,9 @@ Calculates the hash value of a file. This API uses an asynchronous callback to r
```js
let filePath = pathDir + "/test.txt";
fileio.hash(filePath, "sha256", function(err, hashStr) {
fileio.hash(filePath, "sha256", function (err, hashStr) {
if (hashStr) {
console.info("Calculated file hash:"+ hashStr);
console.info("calculate file hash succeed:" + hashStr);
}
});
```
......@@ -1122,10 +1098,10 @@ Changes file permissions. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
fileio.chmod(filePath, 0o700).then(function() {
fileio.chmod(filePath, 0o700).then(function () {
console.info("File permissions changed");
}).catch(function(err){
console.info("Failed to change file permissions. Error:"+ err);
}).catch(function (err) {
console.info("chmod failed with error:" + err);
});
```
......@@ -1191,7 +1167,7 @@ Obtains file information based on the file descriptor. This API uses a promise t
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ |
| fd | number | Yes | File descriptor of the target file.|
| fd | number | Yes | Descriptor of the target file.|
**Return value**
......@@ -1204,10 +1180,10 @@ Obtains file information based on the file descriptor. This API uses a promise t
```js
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
fileio.fstat(fd).then(function(stat){
console.info("Obtained file info:"+ JSON.stringify(stat));
}).catch(function(err){
console.info("Failed to obtain file info. Error:"+ err);
fileio.fstat(fd).then(function (stat) {
console.info("fstat succeed, the size of file is " + stat.size);
}).catch(function (err) {
console.info("fstat failed with error:" + err);
});
```
......@@ -1293,17 +1269,17 @@ Truncates a file based on the file descriptor. This API uses a promise to return
```js
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
fileio.ftruncate(fd, 5).then(function(err) {
fileio.ftruncate(fd, 5).then(function (err) {
console.info("File truncated");
}).catch(function(err){
console.info("Failed to truncate the file. Error:"+ err);
}).catch(function (err) {
console.info("truncate file failed with error:" + err);
});
```
## fileio.ftruncate<sup>7+</sup>
ftruncate(fd: number, len: number, callback: AsyncCallback&lt;void&gt;): void
ftruncate(fd: number, len?: number, callback: AsyncCallback&lt;void&gt;): void
Truncates a file based on the file descriptor. This API uses an asynchronous callback to return the result.
......@@ -1323,7 +1299,7 @@ Truncates a file based on the file descriptor. This API uses an asynchronous cal
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
let len = 5;
fileio.ftruncate(fd, 5, function(err){
fileio.ftruncate(fd, 5, function (err) {
// Do something.
});
```
......@@ -1366,7 +1342,7 @@ Truncates a file based on the file path. This API uses a promise to return the r
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------- |
| path | string | Yes | Application sandbox path of the file to truncate.|
| path | string | Yes | Application sandbox path of the file to truncate. |
| len | number | No | File length, in bytes, after truncation.|
**Return value**
......@@ -1380,17 +1356,17 @@ Truncates a file based on the file path. This API uses a promise to return the r
```js
let filePath = pathDir + "/test.txt";
let len = 5;
fileio.truncate(filePath, len).then(function(){
fileio.truncate(filePath, len).then(function () {
console.info("File truncated");
}).catch(function(err){
console.info("Failed to truncate the file. Error:"+ err);
}).catch(function (err) {
console.info("truncate file failed with error:" + err);
});
```
## fileio.truncate<sup>7+</sup>
truncate(path: string, len: number, callback: AsyncCallback&lt;void&gt;): void
truncate(path: string, len?: number, callback: AsyncCallback&lt;void&gt;): void
Truncates a file based on the file path. This API uses an asynchronous callback to return the result.
......@@ -1409,7 +1385,7 @@ Truncates a file based on the file path. This API uses an asynchronous callback
```js
let filePath = pathDir + "/test.txt";
let len = 5;
fileio.truncate(filePath, len, function(err){
fileio.truncate(filePath, len, function (err) {
// Do something.
});
```
......@@ -1441,11 +1417,7 @@ Synchronously truncates a file based on the file path.
## fileio.readText<sup>7+</sup>
readText(filePath: string, options?: {
position?: number;
length?: number;
encoding?: string;
}): Promise&lt;string&gt;
readText(filePath: string, options?: { position?: number; length?: number; encoding?: string; }): Promise&lt;string&gt;
Reads the text content of a file. This API uses a promise to return the result.
......@@ -1468,21 +1440,17 @@ Reads the text content of a file. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
fileio.readText(filePath).then(function(str) {
console.info("Read text successfully:"+ str);
}).catch(function(err){
console.info("Failed to read the text. Error:"+ err);
fileio.readText(filePath).then(function (str) {
console.info("readText succeed:" + str);
}).catch(function (err) {
console.info("readText failed with error:" + err);
});
```
## fileio.readText<sup>7+</sup>
readText(filePath: string, options: {
position?: number;
length?: number;
encoding?: string;
}, callback: AsyncCallback&lt;string&gt;): void
readText(filePath: string, options: { position?: number; length?: number; encoding?: string; }, callback: AsyncCallback&lt;string&gt;): void
Reads the text content of a file. This API uses an asynchronous callback to return the result.
......@@ -1500,7 +1468,7 @@ Reads the text content of a file. This API uses an asynchronous callback to retu
```js
let filePath = pathDir + "/test.txt";
fileio.readText(filePath, { position: 1, encoding: 'UTF-8' }, function(err, str){
fileio.readText(filePath, { position: 1, encoding: 'UTF-8' }, function (err, str) {
// Do something.
});
```
......@@ -1508,11 +1476,7 @@ Reads the text content of a file. This API uses an asynchronous callback to retu
## fileio.readTextSync<sup>7+</sup>
readTextSync(filePath: string, options?: {
position?: number;
length?: number;
encoding?: string;
}): string
readTextSync(filePath: string, options?: { position?: number; length?: number; encoding?: string; }): string
Synchronously reads the text of a file.
......@@ -1563,10 +1527,10 @@ Obtains link information. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
fileio.lstat(filePath).then(function(stat){
console.info("Get link info:"+ JSON.stringify(stat));
}).catch(function(err){
console.info("Failed to obtain link info. Error:"+ err);
fileio.lstat(filePath).then(function (stat) {
console.info("get link status succeed, the size of file is" + stat.size);
}).catch(function (err) {
console.info("get link status failed with error:" + err);
});
```
......@@ -1637,7 +1601,7 @@ Renames a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------------- |
| oldPath | string | Yes | Application sandbox path of the file to rename.|
| newPath | String | Yes | Application sandbox path of the file renamed. |
| newPath | string | Yes | Application sandbox path of the file renamed. |
**Return value**
......@@ -1650,10 +1614,10 @@ Renames a file. This API uses a promise to return the result.
```js
let srcFile = pathDir + "/test.txt";
let dstFile = pathDir + '/new.txt';
fileio.rename(srcFile, dstFile).then(function() {
fileio.rename(srcFile, dstFile).then(function () {
console.info("File renamed");
}).catch(function(err){
console.info("Failed to rename the file. Error:"+ err);
}).catch(function (err) {
console.info("rename failed with error:" + err);
});
```
......@@ -1671,15 +1635,15 @@ Renames a file. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------------------------- |
| oldPath | string | Yes | Application sandbox path of the file to rename.|
| newPath | String | Yes | Application sandbox path of the file renamed. |
| Callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is asynchronously renamed. |
| newPath | string | Yes | Application sandbox path of the file renamed. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is asynchronously renamed. |
**Example**
```js
let srcFile = pathDir + "/test.txt";
let dstFile = pathDir + '/new.txt';
fileio.rename(srcFile, dstFile, function(err){
fileio.rename(srcFile, dstFile, function (err) {
});
```
......@@ -1697,7 +1661,7 @@ Synchronously renames a file.
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------------- |
| oldPath | string | Yes | Application sandbox path of the file to rename.|
| newPath | String | Yes | Application sandbox path of the file renamed. |
| newPath | string | Yes | Application sandbox path of the file renamed. |
**Example**
......@@ -1733,10 +1697,10 @@ Flushes data of a file to disk. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
fileio.fsync(fd).then(function(){
fileio.fsync(fd).then(function () {
console.info("Data flushed");
}).catch(function(err){
console.info("Failed to flush data. Error:"+ err);
}).catch(function (err) {
console.info("sync data failed with error:" + err);
});
```
......@@ -1761,7 +1725,7 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return
```js
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
fileio.fsync(fd, function(err){
fileio.fsync(fd, function (err) {
// Do something.
});
```
......@@ -1815,10 +1779,10 @@ Flushes data of a file to disk. This API uses a promise to return the result. **
```js
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
fileio.fdatasync(fd).then(function(err) {
fileio.fdatasync(fd).then(function (err) {
console.info("Data flushed");
}).catch(function(err){
console.info("Failed to flush data. Error:"+ err);
}).catch(function (err) {
console.info("sync data failed with error:" + err);
});
```
......@@ -1836,7 +1800,7 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return
| Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ----------------- |
| fd | number | Yes | File descriptor of the file to synchronize. |
| callback | AsyncCallback&nbsp;&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.|
**Example**
......@@ -1898,10 +1862,10 @@ Creates a symbolic link based on the file path. This API uses a promise to retur
```js
let srcFile = pathDir + "/test.txt";
let dstFile = pathDir + '/test';
fileio.symlink(srcFile, dstFile).then(function() {
fileio.symlink(srcFile, dstFile).then(function () {
console.info("Symbolic link created");
}).catch(function(err){
console.info("Failed to create the symbolic link. Error:"+ err);
}).catch(function (err) {
console.info("symlink failed with error:" + err);
});
```
......@@ -1984,10 +1948,10 @@ Changes the file owner based on the file path. This API uses a promise to return
```js
let filePath = pathDir + "/test.txt";
let stat = fileio.statSync(filePath);
fileio.chown(filePath, stat.uid, stat.gid).then(function(){
fileio.chown(filePath, stat.uid, stat.gid).then(function () {
console.info("File owner changed");
}).catch(function(err){
console.info("Failed to change the file owner. Error:"+ err);
}).catch(function (err) {
console.info("chown failed with error:" + err);
});
```
......@@ -2014,7 +1978,7 @@ Changes the file owner based on the file path. This API uses an asynchronous cal
```js
let filePath = pathDir + "/test.txt";
let stat = fileio.statSync(filePath)
fileio.chown(filePath, stat.uid, stat.gid, function (err){
fileio.chown(filePath, stat.uid, stat.gid, function (err) {
// Do something.
});
```
......@@ -2068,10 +2032,10 @@ Creates a temporary directory. This API uses a promise to return the result.
**Example**
```js
fileio.mkdtemp(pathDir + "/XXXXXX").then(function(pathDir){
console.info("mkdtemp succeed:"+ pathDir);
}).catch(function(err){
console.info("Failed to create the temporary directory. Error:"+ err);
fileio.mkdtemp(pathDir + "/XXXXXX").then(function (pathDir) {
console.info("mkdtemp succeed:" + pathDir);
}).catch(function (err) {
console.info("mkdtemp failed with error:" + err);
});
```
......@@ -2154,10 +2118,10 @@ Changes file permissions based on the file descriptor. This API uses a promise t
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
let mode = 0o700;
fileio.fchmod(fd, mode).then(function() {
fileio.fchmod(fd, mode).then(function () {
console.info("File permissions changed");
}).catch(function(err){
console.info("Failed to change file permissions. Error:"+ err);
}).catch(function (err) {
console.info("chmod failed with error:" + err);
});
```
......@@ -2176,7 +2140,7 @@ Changes file permissions based on the file descriptor. This API uses an asynchro
| -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the target file. |
| mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (&#124;).<br>-&nbsp;**0o700**: The owner has the read, write, and execute permissions.<br>- &nbsp;**0o400**: The owner has the read permission.<br>-&nbsp;**0o200**: The owner has the write permission.<br>-&nbsp;**0o100**: The owner has the execute permission.<br>-&nbsp;**0o070**: The user group has the read, write, and execute permissions.<br>-&nbsp;**0o040**: The user group has the read permission.<br>-&nbsp;**0o020**: The user group has the write permission.<br>-&nbsp;**0o010**: The user group has the execute permission.<br>-&nbsp;**0o007**: Other users have the read, write, and execute permissions.<br>-&nbsp;**0o004**: Other users have the read permission.<br>-&nbsp;**0o002**: Other users have the write permission.<br>-&nbsp;**0o001**: Other users have the execute permission.|
| callback | AsyncCallback&nbsp;&lt;void&gt; | Yes | Callback invoked when the file permissions are changed asynchronously. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file permissions are changed asynchronously. |
**Example**
......@@ -2240,10 +2204,10 @@ Opens a file stream based on the file path. This API uses a promise to return th
```js
let filePath = pathDir + "/test.txt";
fileio.createStream(filePath, "r+").then(function(stream){
fileio.createStream(filePath, "r+").then(function (stream) {
console.info("Stream created");
}).catch(function(err){
console.info("Failed to create the stream. Error:"+ err);
}).catch(function (err) {
console.info("createStream failed with error:" + err);
});
```
......@@ -2268,7 +2232,7 @@ Opens a file stream based on the file path. This API uses an asynchronous callba
```js
let filePath = pathDir + "/test.txt";
fileio.createStream(filePath, "r+", function(err, stream){
fileio.createStream(filePath, "r+", function (err, stream) {
// Do something.
});
```
......@@ -2329,10 +2293,10 @@ Opens a file stream based on the file descriptor. This API uses a promise to ret
```js
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
fileio.fdopenStream(fd, "r+").then(function(stream){
fileio.fdopenStream(fd, "r+").then(function (stream) {
console.info("Stream opened");
}).catch(function(err){
console.info("Failed to open the stream. Error:"+ err);
}).catch(function (err) {
console.info("openStream failed with error:" + err);
});
```
......@@ -2351,7 +2315,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 | -&nbsp;**r**: Open a file for reading. The file must exist.<br>-&nbsp;**r+**: Open a file for both reading and writing. The file must exist.<br>-&nbsp;**w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>-&nbsp;**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>-&nbsp;**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>-&nbsp;**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&nbsp;&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is open asynchronously. |
| callback | AsyncCallback&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is open asynchronously. |
**Example**
......@@ -2422,10 +2386,10 @@ Changes the file owner based on the file descriptor. This API uses a promise to
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
let stat = fileio.statSync(filePath);
fileio.fchown(fd, stat.uid, stat.gid).then(function() {
fileio.fchown(fd, stat.uid, stat.gid).then(function () {
console.info("File owner changed");
}).catch(function(err){
console.info("Failed to change the file owner. Error:"+ err);
}).catch(function (err) {
console.info("chown failed with error:" + err);
});
```
......@@ -2453,7 +2417,7 @@ Changes the file owner based on the file descriptor. This API uses an asynchrono
let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath);
let stat = fileio.statSync(filePath);
fileio.fchown(fd, stat.uid, stat.gid, function (err){
fileio.fchown(fd, stat.uid, stat.gid, function (err) {
// Do something.
});
```
......@@ -2512,10 +2476,10 @@ Changes the file owner (owner of the symbolic link, not the file referred to by
```js
let filePath = pathDir + "/test.txt";
let stat = fileio.statSync(filePath);
fileio.lchown(filePath, stat.uid, stat.gid).then(function() {
fileio.lchown(filePath, stat.uid, stat.gid).then(function () {
console.info("File owner changed");
}).catch(function(err){
console.info("Failed to change the file owner. Error:"+ err);
}).catch(function (err) {
console.info("chown failed with error:" + err);
});
```
......@@ -2542,7 +2506,7 @@ Changes the file owner (owner of the symbolic link, not the file referred to by
```js
let filePath = pathDir + "/test.txt";
let stat = fileio.statSync(filePath);
fileio.lchown(filePath, stat.uid, stat.gid, function (err){
fileio.lchown(filePath, stat.uid, stat.gid, function (err) {
// Do something.
});
```
......@@ -2586,8 +2550,8 @@ Listens for file or directory changes. This API uses an asynchronous callback to
| Name | Type | Mandatory| Description |
| -------- | --------------------------------- | ---- | ------------------------------------------------------------ |
| filePath | string | Yes | Application sandbox path of the file. |
| events | Number | Yes | -&nbsp;**1**: The file or directory is renamed.<br>-&nbsp;**2**: The file or directory is modified.<br>-&nbsp;**3**: The file or directory is modified and renamed.|
| callback | AsyncCallback&lt;number&nbsp;&gt; | Yes | Called each time a change is detected. |
| events | number | Yes | -&nbsp;**1**: The file or directory is renamed.<br>-&nbsp;**2**: The file or directory is modified.<br>-&nbsp;**3**: The file or directory is modified and renamed.|
| callback | AsyncCallback&lt;number&gt; | Yes | Called each time a change is detected. |
**Return value**
......@@ -2599,8 +2563,8 @@ Listens for file or directory changes. This API uses an asynchronous callback to
```js
let filePath = pathDir +"/test.txt";
fileio.createWatcher(filePath, 1, function(number){
console.info("Monitoring times: "+number);
fileio.createWatcher(filePath, 1, function (number) {
console.info("Monitoring times: " +number);
});
```
......@@ -2616,7 +2580,7 @@ Obtains the file read result. This class applies only to the **read()** method.
| --------- | ---------- | ---- | ---- | ----------------- |
| bytesRead | number | Yes | Yes | Length of the data read. |
| offset | number | Yes | Yes | Position of the buffer to which the data will be read in reference to the start address of the buffer.|
| buffer | ArrayBufer | Yes | Yes | Buffer for storing the data read. |
| buffer | ArrayBuffer | Yes | Yes | Buffer for storing the data read. |
## Stat
......@@ -2631,7 +2595,7 @@ Provides detailed file information. Before calling a method of the **Stat** clas
| ------ | ------ | ---- | ---- | ---------------------------------------- |
| dev | number | Yes | No | Major device number. |
| ino | number | Yes | No | File ID. Different files on the same device have different **ino**s. |
| mode | number | Yes | No | File type and permissions. The first four bits indicate the file type, and the last 12 bits indicate the permissions. The bit fields are described as follows:<br>-&nbsp;**0o170000**: mask used to obtain the file type.<br>-&nbsp;**0o140000**: The file is a socket.<br>-&nbsp;**0o120000**: The file is a symbolic link.<br>-&nbsp;**0o100000**: The file is a regular file.<br>-&nbsp;**0o060000**: The file is a block device.<br>-&nbsp;**0o040000**: The file is a directory.<br>-&nbsp;**0o020000**: The file is a character device.<br>-&nbsp;**0o010000**: The file is a named pipe (FIFO).<br>-&nbsp;**0o0700**: mask used to obtain the owner permissions.<br>-&nbsp;**0o0400**: The owner has the permission to read a regular file or a directory entry.<br>-&nbsp;**0o0200**: The owner has the permission to write a regular file or create and delete a directory entry.<br>-&nbsp;**0o0100**: The owner has the permission to execute a regular file or search for the specified path in a directory.<br>-&nbsp;**0o0070**: mask used to obtain the user group permissions.<br>-&nbsp;**0o0040**: The user group has the permission to read a regular file or a directory entry.<br>-&nbsp;**0o0020**: The user group has the permission to write a regular file or create and delete a directory entry.<br>-&nbsp;**0o0010**: The user group has the permission to execute a regular file or search for the specified path in a directory.<br>-&nbsp;**0o0007**: mask used to obtain the permissions of other users.<br>-&nbsp;**0o0004**: Other users have the permission to read a regular file or a directory entry.<br>-&nbsp;**0o0002**: Other users have the permission to write a regular file or create and delete a directory entry.<br>-&nbsp;**0o0001**: Other users have the permission to execute a regular file or search for the specified path in a directory.|
| mode | number | Yes | No | File type and permissions. The first four bits indicate the file type, and the last 12 bits indicate the permissions. The bit fields are described as follows:<br>-&nbsp;**0o170000**: mask used to obtain the file type.<br>-&nbsp;**0o140000**: The file is a socket.<br>-&nbsp;**0o120000**: The file is a symbolic link.<br>-&nbsp;**0o100000**: The file is a regular file.<br>-&nbsp;**0o060000**: The file is a block device.<br>-&nbsp;**0o040000**: The file is a directory.<br>-&nbsp;**0o020000**: The file is a character device.<br>- **0o010000**: The file is a named pipe (FIFO).<br>-&nbsp;**0o0700**: mask used to obtain the owner permissions.<br>-&nbsp;**0o0400**: The owner has the permission to read a regular file or a directory entry.<br>-&nbsp;**0o0200**: The owner has the permission to write a regular file or create and delete a directory entry.<br>-&nbsp;**0o0100**: The owner has the permission to execute a regular file or search for the specified path in a directory.<br>-&nbsp;**0o0070**: mask used to obtain the user group permissions.<br>-&nbsp;**0o0040**: The user group has the permission to read a regular file or a directory entry.<br>-&nbsp;**0o0020**: The user group has the permission to write a regular file or create and delete a directory entry.<br>-&nbsp;**0o0010**: The user group has the permission to execute a regular file or search for the specified path in a directory.<br>-&nbsp;**0o0007**: mask used to obtain the permissions of other users.<br>-&nbsp;**0o0004**: Other users have the permission to read a regular file or a directory entry.<br>-&nbsp;**0o0002**: Other users have the permission to write a regular file or create and delete a directory entry.<br>-&nbsp;**0o0001**: Other users have the permission to execute a regular file or search for the specified path in a directory.|
| nlink | number | Yes | No | Number of hard links in the file. |
| uid | number | Yes | No | User ID, that is ID of the file owner. |
| gid | number | Yes | No | Group ID, that is, ID of the user group of the file. |
......@@ -2814,10 +2778,10 @@ Stops the **watcher** instance. This API uses a promise to return the result.
```js
let filePath = path + "/test.txt";
let watcher = fileio.createWatcher(filePath, 1, function(number){
console.info("Monitoring times: "+number);
let watcher = fileio.createWatcher(filePath, 1, function (number) {
console.info("Monitoring times: " +number);
});
watcher.stop().then(function(){
watcher.stop().then(function () {
console.info("Watcher stopped");
});
```
......@@ -2841,10 +2805,10 @@ Stops the **watcher** instance. This API uses an asynchronous callback to return
```js
let filePath = path +"/test.txt";
let watcher = fileio.createWatcher(filePath, 1, function(number){
console.info("Monitoring times: "+number);
let watcher = fileio.createWatcher(filePath, 1, function (number) {
console.info("Monitoring times: " +number);
});
watcher.stop(function(){
watcher.stop(function () {
console.info("Watcher stopped");
})
```
......@@ -2874,10 +2838,10 @@ Closes the stream. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
let ss= fileio.createStreamSync(filePath, "r+");
ss.close().then(function(){
ss.close().then(function () {
console.info("File stream closed");
}).catch(function(err){
console.info("Failed to close the file stream. Error:"+ err);
}).catch(function (err) {
console.info("close fileStream failed with error:" + err);
});
```
......@@ -2943,10 +2907,10 @@ Flushes the stream. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
let ss= fileio.createStreamSync(filePath, "r+");
ss.flush().then(function (){
ss.flush().then(function () {
console.info("Stream flushed");
}).catch(function(err){
console.info("Failed to flush the stream. Error:"+ err);
}).catch(function (err) {
console.info("flush failed with error:" + err);
});
```
......@@ -2995,12 +2959,7 @@ Synchronously flushes the stream.
### write<sup>7+</sup>
write(buffer: ArrayBuffer | string, options?: {
offset?: number;
length?: number;
position?: number;
encoding?: string;
}): Promise&lt;number&gt;
write(buffer: ArrayBuffer|string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): Promise&lt;number&gt;
Writes data into the stream. This API uses a promise to return the result.
......@@ -3010,7 +2969,7 @@ Writes data into the stream. This API uses a promise to return the result.
| Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>-&nbsp;**offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>-&nbsp;**length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>-&nbsp;**position** (number): start position to write the data in the file. By default, data is written from the current position.<br>-&nbsp;**encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>Constraints: offset + length <= Buffer size |
**Return value**
......@@ -3024,22 +2983,17 @@ Writes data into the stream. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
let ss= fileio.createStreamSync(filePath, "r+");
ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number){
console.info("Data written to the stream. Size is:"+ number);
}).catch(function(err){
console.info("Failed to write data to the stream. Error:"+ err);
ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number) {
console.info("write succeed and size is:" + number);
}).catch(function (err) {
console.info("write failed with error:" + err);
});
```
### write<sup>7+</sup>
write(buffer: ArrayBuffer | string, options: {
offset?: number;
length?: number;
position?: number;
encoding?: string;
}, callback: AsyncCallback&lt;number&gt;): void
write(buffer: ArrayBuffer|string, options: { offset?: number; length?: number; position?: number; encoding?: string; }, callback: AsyncCallback&lt;number&gt;): void
Writes data into the stream. This API uses an asynchronous callback to return the result.
......@@ -3049,7 +3003,7 @@ Writes data into the stream. This API uses an asynchronous callback to return th
| Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>-&nbsp;**offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>-&nbsp;**length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>-&nbsp;**position** (number): start position to write the data in the file. By default, data is written from the current position.<br>-&nbsp;**encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>Constraints: offset + length <= Buffer size|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. |
......@@ -3061,7 +3015,7 @@ Writes data into the stream. This API uses an asynchronous callback to return th
ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) {
if (bytesWritten) {
// Do something.
console.info("Data written to the stream. Size is:"+ bytesWritten);
console.info("write succeed and size is:" + bytesWritten);
}
});
```
......@@ -3069,12 +3023,7 @@ Writes data into the stream. This API uses an asynchronous callback to return th
### writeSync<sup>7+</sup>
writeSync(buffer: ArrayBuffer | string, options?: {
offset?: number;
length?: number;
position?: number;
encoding?: string;
}): number
writeSync(buffer: ArrayBuffer|string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): number
Synchronously writes data into the stream.
......@@ -3084,7 +3033,7 @@ Synchronously writes data into the stream.
| Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | Yes | Data to write. It can be a string or data from a buffer. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>-&nbsp;**offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>-&nbsp;**length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>-&nbsp;**position** (number): start position to write the data in the file. By default, data is written from the current position.<br>-&nbsp;**encoding** (string): format of the string to be encoded. The default value is **utf-8**, which is the only value supported.<br>Constraints: offset + length <= Buffer size |
**Return value**
......@@ -3104,11 +3053,7 @@ Synchronously writes data into the stream.
### read<sup>7+</sup>
read(buffer: ArrayBuffer, options?: {
position?: number;
offset?: number;
length?: number;
}): Promise&lt;ReadOut&gt;
read(buffer: ArrayBuffer, options?: { position?: number; offset?: number; length?: number; }): Promise&lt;ReadOut&gt;
Reads data from the stream. This API uses a promise to return the result.
......@@ -3132,22 +3077,18 @@ Reads data from the stream. This API uses a promise to return the result.
```js
let filePath = pathDir + "/test.txt";
let ss = fileio.createStreamSync(filePath, "r+");
ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readOut){
ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readOut) {
console.info("Read data successfully");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
}).catch(function(err){
console.info("Failed to read data. Error:"+ err);
}).catch(function (err) {
console.info("read data failed with error:" + err);
});
```
### read<sup>7+</sup>
read(buffer: ArrayBuffer, options: {
position?: number;
offset?: number;
length?: number;
}, callback: AsyncCallback&lt;ReadOut&gt;): void
read(buffer: ArrayBuffer, options: { position?: number; offset?: number; length?: number; }, callback: AsyncCallback&lt;ReadOut&gt;): void
Reads data from the stream. This API uses an asynchronous callback to return the result.
......@@ -3177,11 +3118,7 @@ Reads data from the stream. This API uses an asynchronous callback to return the
### readSync<sup>7+</sup>
readSync(buffer: ArrayBuffer, options?: {
position?: number;
offset?: number;
length?: number;
}): number
readSync(buffer: ArrayBuffer, options?: { position?: number; offset?: number; length?: number; }): number
Synchronously reads data from the stream.
......@@ -3231,10 +3168,10 @@ Reads the next directory entry. This API uses a promise to return the result.
**Example**
```js
dir.read().then(function (dirent){
console.log("Read the next directory entry:"+JSON.stringify(dirent));
}).catch(function(err){
console.info("Failed to read the next directory entry. Error:"+ err);
dir.read().then(function (dirent) {
console.log("read succeed, the name of dirent is " + dirent.name);
}).catch(function (err) {
console.info("read failed with error:" + err);
});
```
......@@ -3259,7 +3196,7 @@ Reads the next directory entry. This API uses an asynchronous callback to return
dir.read(function (err, dirent) {
if (dirent) {
// Do something.
console.log("Read the next directory entry:"+JSON.stringify(dirent));
console.log("read succeed, the name of file is " + dirent.name);
}
});
```
......@@ -3297,7 +3234,7 @@ Closes a directory. This API uses a promise to return the result. After a direct
**Example**
```js
dir.close().then(function(err){
dir.close().then(function (err) {
console.info("close dir successfully");
});
```
......@@ -3314,7 +3251,7 @@ Closes a directory. This API uses an asynchronous callback to return the result.
**Example**
```js
dir.close(function(err){
dir.close(function (err) {
console.info("close dir successfully");
});
```
......@@ -3503,17 +3440,16 @@ Checks whether a directory entry is a symbolic link.
## Filter<sup>9+</sup>
Defines the file filter configuration.
**System API**: This is a system API.
**System capability**: SystemCapability.FileManagement.File.FileIO
Defines the file filter configuration.
| Name | Type | Description |
| ----------- | --------------- | ------------------ |
| suffix | Array&lt;string&gt; | File name extensions. The keywords in the array are of the OR relationship. |
| displayName | Array&lt;string&gt; | File name for fuzzy match. The keywords in the array are of the OR relationship.|
| displayName | Array&lt;string&gt; | File names for fuzzy match. The keywords in the array are of the OR relationship.|
| mimeType | Array&lt;string&gt; | MIME types to match. The keywords in the array are of the OR relationship. |
| fileSizeOver | number | File size to match. The files which are of the same or a lager size are matched. |
| lastModifiedAfter | Date | File modification time to match. The files modified after the specified time are matched. |
......
# Security Label
# @ohos.securityLabel (Data Label)
The **secuityLabel** module provides APIs to manage file data security levels, including obtaining and setting file data security levels.
> **NOTE**<br/>
> **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......
# statfs
# @ohos.statfs (statfs)
The statfs module provides APIs for obtaining file system information, including the total number of bytes and the number of idle bytes of the file system.
The **statfs** module provides APIs for obtaining file system information, including the total number of bytes and the number of idle bytes of the file system.
> **NOTE**<br>
> **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.
## Modules to Import
......
# @ohos.storageStatistics (App Storage Statistics)
# @ohos.storageStatistics (Application Storage Statistics)
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.
......@@ -68,7 +68,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| volumeUuid | string | Yes | UUID of the volume. |
| callback | callback: AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total size of the volume.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total size of the volume.|
**Example**
......@@ -137,7 +137,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | ---------------------------- |
| volumeUuid | string | Yes | UUID of the volume. |
| callback | callback: AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the volume.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the volume.|
**Example**
......@@ -173,7 +173,7 @@ This is a system API and cannot be called by third-party applications.
| Type | Description |
| ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained.|
| Promise&lt;[Bundlestats](#bundlestats9)&gt; | Promise used to return the space information obtained.|
**Example**
......@@ -205,7 +205,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| packageName | string | Yes | Bundle name of the application.|
| callback | callback: AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained.|
| callback | AsyncCallback&lt;[Bundlestats](#bundlestats9)&gt; | Yes | Callback invoked to return the space information obtained.|
**Example**
......@@ -229,7 +229,7 @@ Asynchronously obtains space information of the current third-party application.
| Type | Description |
| ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained. |
| Promise&lt;[Bundlestats](#bundlestats9)&gt; | Promise used to return the space information obtained. |
**Example**
......@@ -250,7 +250,7 @@ Asynchronously obtains space information of the current third-party application.
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback: AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained. |
| callback | AsyncCallback&lt;[BundleStats](#bundlestats9)&gt; | Yes | Callback invoked to return the space information obtained. |
**Example**
......@@ -270,11 +270,11 @@ Asynchronously obtains space information of the current third-party application.
This is a system API and cannot be called by third-party applications.
| Name | Type | Description |
| --------- | ------ | -------------- |
| appSize | number | Size of the application. |
| cacheSize | number | Cache size of the application. |
| dataSize | number | Total data size of the application.|
| Name | Type | Readable| Writable| Description |
| --------- | ------ | --- | ---- | -------------- |
| appSize | number | Yes| No| Size of the application. |
| cacheSize | number | Yes| No| Cache size of the application. |
| dataSize | number | Yes| No| Total data size of the application.|
## storageStatistics.getTotalSize<sup>9+</sup>
......@@ -322,7 +322,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------ | ---- | ------------------------ |
| callback | callback: AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the built-in memory card.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the built-in memory card.|
**Example**
......@@ -380,7 +380,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------- |
| callback | callback: AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in memory card.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in memory card.|
**Example**
......@@ -439,7 +439,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | callback: AsyncCallback&lt;number&gt; | Yes | Callback used to return the system space obtained.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the system space obtained.|
**Example**
......@@ -452,7 +452,7 @@ This is a system API and cannot be called by third-party applications.
## storageStatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId? : number): Promise&lt;StorageStats&gt;
getUserStorageStats(userId?: number): Promise&lt;StorageStats&gt;
Asynchronously obtains the space occupied by each type of user data. This API uses a promise to return the result.
......@@ -474,7 +474,7 @@ This is a system API and cannot be called by third-party applications.
| Type | Description |
| --------------------- | ---------------- |
| Promise&lt;[StorageStats](#storagestats)&gt; | Promise used to return the information obtained.|
| Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the information obtained.|
**Example**
......@@ -489,7 +489,7 @@ This is a system API and cannot be called by third-party applications.
## storageStatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId: number, callback: AsyncCallback&lt;StorageStats&gt;): void
getUserStorageStats(userId?: number, callback: AsyncCallback&lt;StorageStats&gt;): void
Asynchronously obtains the space occupied by each type of user data. This API uses a callback to return the result.
......@@ -506,7 +506,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| userId | number | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried. |
| callback | callback: AsyncCallback&lt;[StorageStats](#storagestats)&gt; | Yes | Callback invoked to return the information obtained.|
| callback | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes | Callback invoked to return the information obtained.|
**Example**
......@@ -528,11 +528,11 @@ This is a system API and cannot be called by third-party applications.
This is a system API and cannot be called by third-party applications.
| Name | Type | Description |
| --------- | ------ | -------------- |
| total | number | Total space of the built-in memory card. |
| audio | number | Space occupied by audio data. |
| video | number | Space occupied by video data.|
| image | number | Space occupied by image data. |
| file | number | Space occupied by files. |
| app | number | Space occupied by application data.|
| Name | Type | Readable | Writable | Description |
| --------- | ------ | ---- | ----- | -------------- |
| total | number | Yes| No| Total space of the built-in memory card. |
| audio | number |Yes| No| Space occupied by audio data. |
| video | number | Yes| No| Space occupied by video data.|
| image | number | Yes| No| Space occupied by image data. |
| file | number | Yes| No| Space occupied by files. |
| app | number | Yes| No| Space occupied by application data.|
# @ohos.filemanagement.userFileManager
# @ohos.filemanagement.userFileManager (User Data Management)
The **userFileManager** module provides user data management capabilities, including accessing and modifying user media data (audio and video clips, images, and files).
......
# Volume Management
# @ohos.volumeManager (Volume Management)
The volumeManager module provides APIs for volume and disk management, including obtaining volume information, mounting or unmounting volumes, partitioning disks, and formatting volumes.
> **NOTE**<br>
> **NOTE**
>
> - The initial APIs of this module are supported since API version 9.
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
......@@ -52,7 +51,7 @@ Asynchronously obtains information about all available volumes. This API uses a
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback: AsyncCallback&lt;[Volume](#volume)[]&gt; | Yes | Callback invoked to return the volume information obtained.|
| callback | AsyncCallback&lt;[Volume](#volume)[]&gt; | Yes | Callback invoked to return the volume information obtained.|
**Example**
......@@ -110,7 +109,7 @@ Asynchronously obtains the available space of the specified volume. This API use
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | Yes | Volume ID. |
| callback | callback: AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the execution result.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the execution result.|
**Example**
......@@ -167,7 +166,7 @@ Asynchronously unmounts a volume. This API uses a callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | Yes | Volume ID. |
| callback | callback: AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the execution result.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the execution result.|
**Example**
......@@ -226,7 +225,7 @@ Asynchronously obtains volume information based on the UUID. This API uses a cal
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------- |
| uuid | string | Yes | UUID of the volume. |
| callback | callback: AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained.|
| callback | AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained.|
**Example**
......@@ -285,7 +284,7 @@ Asynchronously obtains volume information based on the volume ID. This API uses
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- |
| volumeId | string | Yes | Volume ID. |
| callback | callback:AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained. |
| callback | AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained. |
**Example**
......@@ -347,7 +346,7 @@ Asynchronously sets the volume description based on the UUID. This API uses a ca
| ---------- | --------------------------------------- | ---- | ---------------- |
| uuid | string | Yes | UUID of the volume. |
| description | string | Yes | Volume description. |
| callback | callback: AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.|
**Example**
......@@ -410,7 +409,7 @@ Asynchronously formats a volume. This API uses a callback to return the result.
| -------- | ------------------------- | ---- | ----------------------------- |
| volumeId | string | Yes | Volume ID. |
| fsType | string | Yes | File system type.|
| callback | callback: AsyncCallback&lt;void&gt; | Yes | Called after the volume is formatted. |
| callback | AsyncCallback&lt;void&gt; | Yes | Called after the volume is formatted. |
**Example**
......@@ -473,7 +472,7 @@ Asynchronously partitions a disk. This API uses a callback to return the result.
| -------- | --------------------------------------- | ---- | ---------------- |
| diskId | string | Yes | ID of the disk to which the volume belongs. |
| type | number | Yes | Partition type. |
| callback | callback: AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Example**
......@@ -491,12 +490,12 @@ Asynchronously partitions a disk. This API uses a callback to return the result.
### Attributes
| Name | Type | Description |
| ----------- | ------- | -------------------- |
| id | string | Volume ID. |
| uuid | string | UUID of the volume. |
| diskId | string | ID of the disk to which the volume belongs. |
| description | string | Description of the volume. |
| removable | boolean | Whether the volume is a removable storage device.|
| state | number | Volume state. |
| path | string | Mount address of the volume. |
| Name | Type | Readable | Writable | Description |
| ----------- | ------- | ------- | ----- | -------------------- |
| id | string | Yes| No| Volume ID. |
| uuid | string | Yes| No| UUID of the volume. |
| diskId | string | Yes| No| ID of the disk to which the volume belongs. |
| description | string | Yes| No| Description of the volume. |
| removable | boolean | Yes| No| Whether the volume is a removable storage device.|
| state | number | Yes| No| Volume state. |
| path | string | Yes| No| Mount address of the volume. |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册