diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md
index 63b359debfcf06fe70a681d363487f5af6892d95..ebdc2315773a1166ee57e10a6750860225a89aa0 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md
@@ -16,6 +16,7 @@ import fileio from '@ohos.fileio';
## 使用说明
使用该功能模块对文件/目录进行操作前,需要先获取其应用沙箱路径,获取方式及其接口用法请参考:
+
```js
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
@@ -353,58 +354,11 @@ closeSync(fd: number): void
**示例:**
```js
+ let fd = fileio.openSync(path);
fileio.closeSync(fd);
```
-## fileio.close7+
-
-close(): Promise<void>
-
-关闭文件流,使用Promise异步回调。
-
-**系统能力**:SystemCapability.FileManagement.File.FileIO
-
-**返回值:**
-
- | 类型 | 说明 |
- | ------------------- | ---------------------------- |
- | Promise<void> | Promise对象。无返回值。 |
-
-**示例:**
-
- ```js
- fileio.close().then(function(){
- console.info("close file stream succeed");
- }).catch(function(err){
- console.info("close file stream failed with error:"+ err);
- });
- ```
-
-
-## fileio.close7+
-
-close(callback: AsyncCallback<void>): void
-
-关闭文件流,使用callback异步回调。
-
-**系统能力**:SystemCapability.FileManagement.File.FileIO
-
-**参数:**
-
- | 参数名 | 类型 | 必填 | 说明 |
- | -------- | ------------------------- | ---- | ------------- |
- | callback | AsyncCallback<void> | 是 | 异步关闭文件流之后的回调。 |
-
-**示例:**
-
- ```js
- fileio.close(function(err){
- // do something
- });
- ```
-
-
## fileio.copyFile
copyFile(src:string | number, dest:string | number, mode?:number):Promise<void>
@@ -430,6 +384,8 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise<voi
**示例:**
```js
+ let src = path;
+ let dest = src + 'tgt';
fileio.copyFile(src, dest).then(function(){
console.info("copyFile succeed");
}).catch(function(err){
@@ -458,6 +414,8 @@ copyFile(src: string | number, dest: string | number, mode: number, callback: As
**示例:**
```js
+ let src = path;
+ let dest = src + 'tgt';
fileio.copyFile(src, dest, function (err) {
// do something
});
@@ -483,6 +441,8 @@ copyFileSync(src: string | number, dest: string | number, mode?: number): void
**示例:**
```js
+ let src = path;
+ let dest = src + 'tgt';
fileio.copyFileSync(src, dest);
```
@@ -1059,7 +1019,7 @@ hash(path: string, algorithm: string): Promise<string>
```js
fileio.hash(path, "sha256").then(function(str){
console.info("calculate file hash succeed:"+ str);
- }).catch(function(error){
+ }).catch(function(err){
console.info("calculate file hash failed with error:"+ err);
});
```
@@ -1116,7 +1076,7 @@ chmod(path: string, mode: number):Promise<void>
**示例:**
```js
- fileio.chmod(path, mode).then(function() {
+ fileio.chmod(path, 0o700).then(function() {
console.info("chmod succeed");
}).catch(function(err){
console.info("chmod failed with error:"+ err);
@@ -1143,7 +1103,7 @@ chmod(path: string, mode: number, callback: AsyncCallback<void>): void
**示例:**
```js
- fileio.chmod(path, mode, function (err) {
+ fileio.chmod(path, 0o700, function (err) {
// do something
});
```
@@ -1167,7 +1127,7 @@ chmodSync(path: string, mode: number): void
**示例:**
```js
- fileio.chmodSync(path, mode);
+ fileio.chmodSync(path, 0o700);
```
@@ -1194,6 +1154,7 @@ fstat(fd: number): Promise<Stat>
**示例:**
```js
+ let fd = fileio.openSync(path);
fileio.fstat(fd).then(function(stat){
console.info("fstat succeed:"+ JSON.stringify(stat));
}).catch(function(err){
@@ -1307,7 +1268,9 @@ ftruncate(fd: number, len: number, callback:AsyncCallback<void>): void
**示例:**
```js
- fileio.ftruncate(fd, len, function(err){
+ let fd = fileio.openSync(path);
+ let len = 5;
+ fileio.ftruncate(fd, 5, function(err){
// do something
});
```
@@ -1331,6 +1294,8 @@ ftruncateSync(fd: number, len?: number): void
**示例:**
```js
+ let fd = fileio.openSync(path);
+ let len = 5;
fileio.ftruncateSync(fd, len);
```
@@ -1359,6 +1324,7 @@ truncate(path: string, len?: number): Promise<void>
**示例:**
```js
+ let len = 5;
fileio.truncate(path, len).then(function(){
console.info("truncate file succeed");
}).catch(function(err){
@@ -1386,6 +1352,7 @@ truncate(path: string, len: number, callback:AsyncCallback<void>): void
**示例:**
```js
+ let len = 5;
fileio.truncate(path, len, function(err){
// do something
});
@@ -1410,6 +1377,7 @@ truncateSync(path: string, len?: number): void
**示例:**
```js
+ let len = 5;
fileio.truncateSync(path, len);
```
@@ -1467,13 +1435,13 @@ readText(filePath: string, options: {
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| filePath | string | 是 | 待读取文件的应用沙箱路径。 |
-| options | Object | 否 | 支持如下选项:
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- encoding,string类型,表示数据的编码方式,默认 'utf-8',仅支持 'utf-8'。 |
+| options | Object | 是 | 支持如下选项:
- position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
- encoding,string类型,表示数据的编码方式,默认 'utf-8',仅支持 'utf-8'。 |
| callback | AsyncCallback<string> | 是 | 回调函数,返回读取文件的内容。 |
**示例:**
```js
- fileio.readText(path, function(err, str){
+ fileio.readText(path, { position: 1, encoding: 'UTF-8' }, function(err, str){
// do something
});
```
@@ -1593,76 +1561,6 @@ lstatSync(path:string): Stat
```
-## fileio.read7+
-
-read(buffer: ArrayBuffer, options?: {
- position?: number;
- offset?: number;
- length?: number;
-}): Promise<ReadOut>
-
-从文件读取数据,使用Promise异步回调。
-
-**系统能力**:SystemCapability.FileManagement.File.FileIO
-
-**参数:**
-
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ----------- | ---- | ------------------------------------------------------------ |
- | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
- | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
约束:offset+length<=buffer.size。 |
-
-**返回值:**
-
- | 类型 | 说明 |
- | ---------------------------------- | ------ |
- | Promise<[ReadOut](#readout)> | Promise对象。返回读取的结果。 |
-
-**示例:**
-
- ```js
- fileio.read(new ArrayBuffer(4096)).then(function(readout){
- console.info("read file data succeed");
- console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
- }).catch(function(err){
- console.info("read file data failed with error:"+ err);
- });
- ```
-
-
-## fileio.read7+
-
-read(buffer: ArrayBuffer, options: {
- position?: number;
- offset?: number;
- length?: number;
-}, callback: AsyncCallback<ReadOut>): void
-
-从文件读取数据,使用callback异步回调。
-
-**系统能力**:SystemCapability.FileManagement.File.FileIO
-
-**参数:**
-
- | 参数名 | 类型 | 必填 | 说明 |
- | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
- | buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
- | options | Object | 否 | 支持如下选项:
- offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。
- length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。
约束:offset+length<=buffer.size。 |
- | callback | AsyncCallback<[ReadOut](#readout)> | 是 | 异步从文件读取数据之后的回调。 |
-
-**示例:**
-
- ```js
- let buf = new ArrayBuffer(4096);
- fileio.read(buf, function (err, readOut) {
- if (readOut) {
- console.info("read file data succeed");
- console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
- }
- });
- ```
-
-
## fileio.rename7+
rename(oldPath: string, newPath: string): Promise<void>
@@ -1687,6 +1585,8 @@ rename(oldPath: string, newPath: string): Promise<void>
**示例:**
```js
+ let oldPath = path;
+ let newPath = oldPath + '123';
fileio.rename(oldPath, newPath).then(function() {
console.info("rename succeed");
}).catch(function(err){
@@ -1714,6 +1614,8 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): v
**示例:**
```js
+ let oldPath = path;
+ let newPath = oldPath + '123';
fileio.rename(oldPath, newPath, function(err){
});
```
@@ -1737,6 +1639,8 @@ renameSync(oldPath: string, newPath: string): void
**示例:**
```js
+ let oldPath = path;
+ let newPath = oldPath + '123';
fileio.renameSync(oldPath, newPath);
```
@@ -1764,6 +1668,7 @@ fsync(fd: number): Promise<void>
**示例:**
```js
+ let fd = fileio.openSync(path);
fileio.fsync(fd).then(function(){
console.info("sync data succeed");
}).catch(function(err){
@@ -1790,6 +1695,7 @@ fsync(fd: number, callback: AsyncCallback<void>): void
**示例:**
```js
+ let fd = fileio.openSync(path);
fileio.fsync(fd, function(err){
// do something
});
@@ -1813,6 +1719,7 @@ fsyncSync(fd: number): void
**示例:**
```js
+ let fd = fileio.openSync(path);
fileio.fsyncSync(fd);
```
@@ -1840,6 +1747,7 @@ fdatasync(fd: number): Promise<void>
**示例:**
```js
+ let fd = fileio.openSync(path);
fileio.fdatasync(fd).then(function(err) {
console.info("sync data succeed");
}).catch(function(err){
@@ -1866,6 +1774,7 @@ fdatasync(fd: number, callback:AsyncCallback<void>): void
**示例:**
```js
+ let fd = fileio.openSync(path);
fileio.fdatasync (fd, function (err) {
// do something
});
@@ -1889,6 +1798,7 @@ fdatasyncSync(fd: number): void
**示例:**
```js
+ let fd = fileio.openSync(path);
let stat = fileio.fdatasyncSync(fd);
```
@@ -1917,6 +1827,8 @@ symlink(target: string, srcPath: string): Promise<void>
**示例:**
```js
+ let target = path;
+ let srcPath = target + 'aaa';
fileio.symlink(target, srcPath).then(function() {
console.info("symlink succeed");
}).catch(function(err){
@@ -1944,6 +1856,8 @@ symlink(target: string, srcPath: string, callback: AsyncCallback<void>): v
**示例:**
```js
+ let target = path;
+ let srcPath = target + 'aaa';
fileio.symlink(target, srcPath, function (err) {
// do something
});
@@ -1968,6 +1882,8 @@ symlinkSync(target: string, srcPath: string): void
**示例:**
```js
+ let target = path;
+ let srcPath = target + 'aaa';
fileio.symlinkSync(target, srcPath);
```
@@ -2163,6 +2079,8 @@ fchmod(fd: number, mode: number): Promise<void>
**示例:**
```js
+ let fd = fileio.openSync(path);
+ let mode = 0o700;
fileio.fchmod(fd, mode).then(function() {
console.info("chmod succeed");
}).catch(function(err){
@@ -2190,6 +2108,8 @@ fchmod(fd: number, mode: number, callback: AsyncCallback<void>): void
**示例:**
```js
+ let fd = fileio.openSync(path);
+ let mode = 0o700;
fileio.fchmod(fd, mode, function (err) {
// do something
});
@@ -2214,6 +2134,8 @@ fchmodSync(fd: number, mode: number): void
**示例:**
```js
+ let fd = fileio.openSync(path);
+ let mode = 0o700;
fileio.fchmodSync(fd, mode);
```
@@ -2416,6 +2338,7 @@ fchown(fd: number, uid: number, gid: number): Promise<void>
**示例:**
```js
+ let fd = fileio.openSync(path);
let stat = fileio.statSync(path);
fileio.fchown(fd, stat.uid, stat.gid).then(function() {
console.info("chown succeed");
@@ -2445,6 +2368,7 @@ fchown(fd: number, uid: number, gid: number, callback: AsyncCallback<void>
**示例:**
```js
+ let fd = fileio.openSync(path);
let stat = fileio.statSync(path);
fileio.fchown(fd, stat.uid, stat.gid, function (err){
// do something
@@ -2471,6 +2395,7 @@ fchownSync(fd: number, uid: number, gid: number): void
**示例:**
```js
+ let fd = fileio.openSync(path);
let stat = fileio.statSync(path);
fileio.fchownSync(fd, stat.uid, stat.gid);
```
@@ -3103,7 +3028,7 @@ read(buffer: ArrayBuffer, options?: {
```js
let ss = fileio.createStreamSync(path, "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 succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
}).catch(function(err){
@@ -3180,7 +3105,7 @@ readSync(buffer: ArrayBuffer, options?: {
## Dir
-管理目录,在调用Dir的方法前,需要先通过[opendir()](#fileioopendir)方法(同步或异步)来构建一个Dir实例。
+管理目录,在调用Dir的方法前,需要先通过opendir方法(同步或异步)来构建一个Dir实例。
### read
@@ -3450,7 +3375,7 @@ isSocket(): boolean
**示例:**
```js
- let dir = fileio.opendirSync(dpath);
+ let dir = fileio.opendirSync(path);
let isSocket = dir.readSync().isSocket();
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md b/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md
index 34a85c6f3ca0098102c08121a098058e1fb15010..5dedb55f06c6e564743cda51a39057625791a518 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md
@@ -18,7 +18,10 @@ import securityLabel from '@ohos.securityLabel';
```js
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
-let path = context.getFilesDir();
+let path = '';
+context.getFilesDir().then((data) => {
+ path = data;
+})
```
## securityLabel.setSecurityLabel
diff --git a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md
index be091dacdebc8dd1b1d944c01af095c0b57f5625..d5d8993ad9b98294182b3abc3a547e1a9aee8a40 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md
@@ -470,7 +470,7 @@ getUserStorageStats(userId? : number): Promise<StorageStats>
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
- | userId | string | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。|
+ | userId | number | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。|
**返回值:**
@@ -481,7 +481,7 @@ getUserStorageStats(userId? : number): Promise<StorageStats>
**示例:**
```js
- let userId = "";
+ let userId = 1;
storageStatistics.getUserStorageStats(userId).then(function(StorageStats){
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
}).catch(function(err){
@@ -507,13 +507,13 @@ getUserStorageStats(userId: number, callback:AsyncCallback<StorageStats>):
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------ | ---- | -------------------------- |
- | userId | string | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。 |
+ | userId | number | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。 |
| callback | callback:AsyncCallback<[StorageStats](#StorageStats)> | 是 | 返回各类别数据大小之后的回调 |
**示例:**
```js
- let userId = "";
+ let userId = 1;
storageStatistics.getUserStorageStats(userId, function(error, StorageStats){
// do something
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
diff --git a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md
index 7cc98e4b15693698873fed6ca834c4eb9248f51c..535c50272bda24adad3d53bf78f20179de52cb0e 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md
@@ -204,7 +204,11 @@ getVolumeByUuid(uuid: string): Promise<Volume>
```js
let uuid = "";
- let volume = await volumemanager.getVolumeByUuid(uuid);
+ volumemanager.getVolumeByUuid(uuid).then(function(volume) {
+ console.info("getVolumeByUuid successfully:" + JSON.stringify(volume));
+ }).catch(function(error){
+ console.info("getVolumeByUuid failed with error:"+ error);
+ });
```
## volumemanager.getVolumeByUuid
@@ -259,7 +263,11 @@ getVolumeById(id: string): Promise<Volume>
```js
let id = "";
- let volume = await volumemanager.getVolumeById(id);
+ volumemanager.getVolumeById(id).then(function(volume) {
+ console.info("getVolumeById successfully:" + JSON.stringify(volume));
+ }).catch(function(error){
+ console.info("getVolumeById failed with error:"+ error);
+ });
```
## volumemanager.getVolumeById
@@ -316,7 +324,11 @@ setVolumeDescription(uuid: string, description: string): Promise<void>
```js
let uuid = "";
let description = "";
- let bool = await volumemanager.setVolumeDescription(uuid, description);
+ volumemanager.setVolumeDescription(uuid, description).then(function() {
+ console.info("setVolumeDescription successfully");
+ }).catch(function(error){
+ console.info("setVolumeDescription failed with error:"+ error);
+ });
```
## volumemanager.setVolumeDescription
@@ -373,7 +385,11 @@ format(volId: string): Promise<void>
```js
let volId = "";
- let bool = await volumemanager.format(volId);
+ volumemanager.format(volId).then(function() {
+ console.info("format successfully");
+ }).catch(function(error){
+ console.info("format failed with error:"+ error);
+ });
```
## volumemanager.format
@@ -430,7 +446,11 @@ partition(volId: string, fstype: string): Promise<void>
```js
let volId = "";
let fstype = "";
- let bool = await volumemanager.partition(volId, fstype);
+ volumemanager.partition(volId, fstype).then(function() {
+ console.info("partition successfully");
+ }).catch(function(error){
+ console.info("partition failed with error:"+ error);
+ });
```
## volumemanager.partition
@@ -456,7 +476,7 @@ partition(volId: string, fstype : string, callback: AsyncCallback<void>):
```js
let volId = "";
let fstype = "";
- volumemanager.format(volId, fstype, (error, bool) => {
+ volumemanager.partition(volId, fstype, (error, bool) => {
// do something
});
```