diff --git a/zh-cn/application-dev/reference/apis/js-apis-document.md b/zh-cn/application-dev/reference/apis/js-apis-document.md
index 01d6e24a1c50a71f3e42bdf383315a6fc48e43d6..6cb8430b9697867344234c33467ad35bd2c135ec 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-document.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-document.md
@@ -12,7 +12,7 @@ import document from '@ohos.document';
## document.choose
-choose(type:string[]): Promise<string>
+choose(types:string[]): Promise<string>
通过文件管理器选择文件,异步返回文件URI,使用promise形式返回结果。
@@ -22,7 +22,7 @@ choose(type:string[]): Promise<string>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------------- |
- | type | string[] | 否 | 限定文件选择的类型 |
+ | types | string[] | 否 | 限定文件选择的类型 |
- 返回值:
@@ -33,7 +33,8 @@ choose(type:string[]): Promise<string>
- 示例:
```js
- await document.choose(type);
+ let tpyes = [];
+ document.choose(types);
```
## document.choose
@@ -52,13 +53,14 @@ choose(callback:AsyncCallback<string>): void
- 示例:
```js
- await document.choose(function(err, uri) {
+ let uri = "";
+ document.choose(function(err, uri) {
//do something with uri
});
```
## document.choose
-choose(type:string[], callback:AsyncCallback<string>): void
+choose(types:string[], callback:AsyncCallback<string>): void
通过文件管理器选择文件,异步返回文件URI,使用callback形式返回结果。
@@ -68,20 +70,22 @@ choose(type:string[], callback:AsyncCallback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
- | type | string[] | 否 | 限定选择文件的类型 |
+ | types | string[] | 否 | 限定选择文件的类型 |
| callback | AsyncCallback<string> | 是 | 异步获取对应文件URI(注:当前返回错误码) |
- 示例:
```js
- await document.choose(type, function(err, uri) {
+ let types = [];
+ let uri = "";
+ document.choose(types, function(err, uri) {
//do something with uri
});
```
## document.show
-show(url:string, type:string):Promise<number>
+show(url:string, types:string):Promise<number>
异步打开URI对应的文件,使用promise形式返回结果。
@@ -92,7 +96,7 @@ show(url:string, type:string):Promise<number>
| 参数 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------- |
| uri | string | 是 | 待打开的文件URI |
- | type | string | 是 | 待打开文件的类型 |
+ | types | string | 是 | 待打开文件的类型 |
- 返回值:
@@ -103,12 +107,14 @@ show(url:string, type:string):Promise<number>
- 示例:
```js
- await document.show(uri, type);
+ let types = "";
+ let uri = "";
+ document.show(uri, types);
```
## document.show
-show(url:string, type:string, callback:AsyncCallback<void>): void
+show(url:string, types:string, callback:AsyncCallback<void>): void
异步打开URI对应的文件,使用callback形式返回结果。
@@ -119,13 +125,15 @@ show(url:string, type:string, callback:AsyncCallback<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
| uri | string | 是 | 待打开的文件URI |
- | type | string | 是 | 待打开文件的类型 |
+ | types | string | 是 | 待打开文件的类型 |
| callback | AsyncCallback<void> | 是 | 异步打开uri对应文件(注:当前返回错误码) |
- 示例:
```js
- await document.show(uri, type, function(err) {
+ let types = "";
+ let uri = "";
+ document.show(uri, types, function(err) {
//do something
});
```
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 122562e487b0cba7f55bf38ae2a5a2bae7ef6e5e..bc13f14d4338604b74040865e1e43c9b028abf46 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md
@@ -18,10 +18,7 @@ import fileio from '@ohos.fileio';
```js
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
- let path = '';
- context.getFilesDir().then((data) => {
- path = data;
- })
+ let path = context.getFilesDir();
```
@@ -327,52 +324,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
@@ -397,7 +353,8 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise<voi
**示例:**
```js
- fileio.copyFile(src, dest).then(function(){
+ let dest = "";
+ fileio.copyFile(path, dest).then(function(){
console.info("copyFile succeed");
}).catch(function(err){
console.info("copyFile failed with error:"+ err);
@@ -423,7 +380,8 @@ copyFile(src: string | number, dest: string | number, mode: number, callback: As
**示例:**
```js
- fileio.copyFile(src, dest, function (err) {
+ let dest = "";
+ fileio.copyFile(path, dest, function (err) {
// do something
});
```
@@ -446,7 +404,8 @@ copyFileSync(src: string | number, dest: string | number, mode?: number): void
**示例:**
```js
- fileio.copyFileSync(src, dest);
+ let dest = "";
+ fileio.copyFileSync(path, dest);
```
@@ -589,7 +548,7 @@ openSync(path:string, flags?:number, mode?:number): number
| ------ | ------ | ---- | ------------------------------------------------------------ |
| path | string | 是 | 待打开文件的应用沙箱路径。 |
| flags | number | 否 | 打开文件的选项,必须指定如下选项中的一个,默认以只读方式打开:
- 0o0:只读打开。
- 0o1:只写打开。
- 0o2:读写打开。
同时,也可给定如下选项,以按位或的方式追加,默认不给定任何额外选项:
- 0o100:若文件不存在,则创建文件。使用该选项时必须指定第三个参数 mode。
- 0o200:如果追加了0o100选项,且文件已经存在,则出错。
- 0o1000:如果文件存在且以只写或读写的方式打开文件,则将其长度裁剪为零。
- 0o2000:以追加方式打开,后续写将追加到文件末尾。
- 0o4000:如果path指向FIFO、块特殊文件或字符特殊文件,则本次打开及后续 IO 进行非阻塞操作。
- 0o200000:如果path不指向目录,则出错。
- 0o400000:如果path指向符号链接,则出错。
- 0o4010000:以同步IO的方式打开文件。 |
-| mode | number | 否 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。
- 0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。
- 0o640:所有者具有读、写权限,所有用户组具有读权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。
创建出的文件权限受umask影响,umask随进程启动确定,其修改当前不开放。 |
+| mode | number | 否 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。
- 0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。
创建出的文件权限受umask影响,umask随进程启动确定,其修改当前不开放。 |
**返回值:**
| 类型 | 说明 |
@@ -598,15 +557,7 @@ openSync(path:string, flags?:number, mode?:number): number
**示例:**
```js
- let fd = fileio.openSync(path, 0o102, 0o640);
- ```
- ```js
- let fd = fileio.openSync(path, 0o102, 0o666);
- fileio.writeSync(fd, 'hello world');
- let fd1 = fileio.openSync(path, 0o2002);
- fileio.writeSync(fd1, 'hello world');
- let num = fileio.readSync(fd1, new ArrayBuffer(4096), {position: 0});
- console.info("num == " + num);
+ let fd = fileio.openSync(path);
```
@@ -879,7 +830,7 @@ write(fd: number, buffer: ArrayBuffer | string, options?: {
**示例:**
```js
- let fd = fileio.openSync(fpath, 0o100 | 0o2, 0o666);
+ let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, "hello, world").then(function(number){
console.info("write data to file succeed and size is:"+ number);
}).catch(function(err){
@@ -976,7 +927,7 @@ hash(path: string, algorithm: string): Promise<string>
fileio.hash(path, "sha256").then(function(str){
console.info("calculate file hash succeed:"+ str);
}).catch(function(error){
- console.info("calculate file hash failed with error:"+ err);
+ console.info("calculate file hash failed with error:"+ error);
});
```
@@ -998,7 +949,7 @@ hash(path: string, algorithm: string, callback: AsyncCallback<string>): vo
**示例:**
```js
- fileio.hash(fpath, "sha256", function(err, hashStr) {
+ fileio.hash(path, "sha256", function(err, hashStr) {
if (hashStr) {
console.info("calculate file hash succeed:"+ hashStr);
}
@@ -1027,7 +978,7 @@ chmod(path: string, mode: number):Promise<void>
**示例:**
```js
- fileio.chmod(path, mode).then(function() {
+ fileio.chmod(path, 0o400).then(function() {
console.info("chmod succeed");
}).catch(function(err){
console.info("chmod failed with error:"+ err);
@@ -1052,7 +1003,7 @@ chmod(path: string, mode: number, callback: AsyncCallback<void>): void
**示例:**
```js
- fileio.chmod(path, mode, function (err) {
+ fileio.chmod(path, 0o400, function (err) {
// do something
});
```
@@ -1074,7 +1025,7 @@ chmodSync(path: string, mode: number): void
**示例:**
```js
- fileio.chmodSync(fpath, mode);
+ fileio.chmodSync(path, 0o400);
```
@@ -1098,6 +1049,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){
@@ -1201,6 +1153,8 @@ ftruncate(fd: number, len: number, callback:AsyncCallback<void>): void
**示例:**
```js
+ let fd = fileio.openSync(path);
+ let len = 5;
fileio.ftruncate(fd, len, function(err){
// do something
});
@@ -1223,6 +1177,8 @@ ftruncateSync(fd: number, len?: number): void
**示例:**
```js
+ let fd = fileio.openSync(path);
+ let len = 5;
fileio.ftruncateSync(fd, len);
```
@@ -1248,6 +1204,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){
@@ -1273,6 +1230,7 @@ truncate(path: string, len: number, callback:AsyncCallback<void>): void
**示例:**
```js
+ let len = 5;
fileio.truncate(path, len, function(err){
// do something
});
@@ -1295,6 +1253,7 @@ truncateSync(path: string, len?: number): void
**示例:**
```js
+ let len = 5;
fileio.truncateSync(path, len);
```
@@ -1353,7 +1312,7 @@ readText(filePath: string, options: {
**示例:**
```js
- fileio.readText(path, function(err, str){
+ fileio.readText(path, { position: pos, length: len, encoding: 'UTF-8' }, function (err, str){
// do something
});
```
@@ -1409,7 +1368,7 @@ lstat(path: string): Promise<Stat>
**示例:**
```js
fileio.lstat(path).then(function(stat){
- console.info("get link status succeed:"+ number);
+ console.info("get link status succeed:"+ stat.rdev);
}).catch(function(err){
console.info("get link status failed with error:"+ err);
});
@@ -1462,69 +1421,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+
@@ -1548,7 +1444,8 @@ rename(oldPath: string, newPath: string): Promise<void>
**示例:**
```js
- fileio.rename(oldPath, newPath).then(function() {
+ let newPath = path +"123";
+ fileio.rename(path, newPath).then(function() {
console.info("rename succeed");
}).catch(function(err){
console.info("rename failed with error:"+ err);
@@ -1573,7 +1470,8 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): v
**示例:**
```js
- fileio.rename(oldPath, newPath, function(err){
+ let newPath = path +"123";
+ fileio.rename(path, newPath, function(err){
});
```
@@ -1594,7 +1492,8 @@ renameSync(oldPath: string, newPath: string): void
**示例:**
```js
- fileio.renameSync(oldPath, newPath);
+ let newPath = path +"123";
+ fileio.renameSync(path, newPath);
```
@@ -1618,6 +1517,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){
@@ -1641,7 +1541,8 @@ fsync(fd: number, callback: AsyncCallback<void>): void
| Callback | AsyncCallback<void> | 是 | 异步将文件数据同步之后的回调。 |
**示例:**
- ```js
+ ```js
+ let fd = fileio.openSync(path);
fileio.fsync(fd, function(err){
// do something
});
@@ -1663,6 +1564,7 @@ fsyncSync(fd: number): void
**示例:**
```js
+ let fd = fileio.openSync(path);
fileio.fyncsSync(fd);
```
@@ -1686,7 +1588,8 @@ fdatasync(fd: number): Promise<void>
| Promise<void> | Promise对象。无返回值。 |
**示例:**
- ```js
+ ```js
+ let fd = fileio.openSync(path);
fileio.fdatasync(fd).then(function(err) {
console.info("sync data succeed");
}).catch(function(err){
@@ -1711,6 +1614,7 @@ fdatasync(fd: number, callback:AsyncCallback<void>): void
**示例:**
```js
+ let fd = fileio.openSync(path);
fileio.fdatasync (fd, function (err) {
// do something
});
@@ -1732,6 +1636,7 @@ fdatasyncSync(fd: number): void
**示例:**
```js
+ let fd = fileio.openSync(path);
let stat = fileio.fdatasyncSync(fd);
```
@@ -1757,7 +1662,8 @@ symlink(target: string, srcPath: string): Promise<void>
**示例:**
```js
- fileio.symlink(target, srcPath).then(function() {
+ let srcPath = "";
+ fileio.symlink(path, srcPath).then(function() {
console.info("symlink succeed");
}).catch(function(err){
console.info("symlink failed with error:"+ err);
@@ -1782,7 +1688,8 @@ symlink(target: string, srcPath: string, callback: AsyncCallback<void>): v
**示例:**
```js
- fileio.symlink(target, srcPath, function (err) {
+ let srcPath = "";
+ fileio.symlink(path, srcPath, function (err) {
// do something
});
```
@@ -1804,7 +1711,8 @@ symlinkSync(target: string, srcPath: string): void
**示例:**
```js
- fileio.symlinkSync(target, srcPath);
+ let srcPath = "";
+ fileio.symlinkSync(path, srcPath);
```
@@ -1857,7 +1765,7 @@ chown(path: string, uid: number, gid: number, callback: AsyncCallback<void>
**示例:**
```js
- let stat = fileio.statSync(fpath)
+ let stat = fileio.statSync(path)
fileio.chown(path, stat.uid, stat.gid, function (err){
// do something
});
@@ -1881,7 +1789,7 @@ chownSync(path: string, uid: number, gid: number): void
**示例:**
```js
- let stat = fileio.statSync(fpath)
+ let stat = fileio.statSync(path)
fileio.chownSync(path, stat.uid, stat.gid);
```
@@ -1981,6 +1889,8 @@ fchmod(fd: number, mode: number): Promise<void>
**示例:**
```js
+ let fd = fileio.openSync(path);
+ let mode = 0o400;
fileio.fchmod(fd, mode).then(function() {
console.info("chmod succeed");
}).catch(function(err){
@@ -2006,6 +1916,8 @@ fchmod(fd: number, mode: number, callback: AsyncCallback<void>): void
**示例:**
```js
+ let fd = fileio.openSync(path);
+ let mode = 0o400;
fileio.fchmod(fd, mode, function (err) {
// do something
});
@@ -2028,7 +1940,9 @@ fchmodSync(fd: number, mode: number): void
**示例:**
```js
- fileio.fchmodSync(fd, mode);
+ let fd = fileio.openSync(path);
+ let mode = 0o400;
+ fileio.fchmodSync(fd, mode);
```
@@ -2078,6 +1992,7 @@ createStream(path: string, mode: string, callback: AsyncCallback<Stream>):
**示例:**
```js
+ let mode = 0o400;
fileio.createStream(path, mode, function(err, stream){
// do something
});
@@ -2130,6 +2045,8 @@ fdopenStream(fd: number, mode: string): Promise<Stream>
**示例:**
```js
+ let fd = fileio.openSync(path);
+ let mode = 0o400;
fileio.fdopenStream(fd, mode).then(function(stream){
console.info("openStream succeed");
}).catch(function(err){
@@ -2155,6 +2072,8 @@ fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): v
**示例:**
```js
+ let fd = fileio.openSync(path);
+ let mode = 0o400;
fileio.fdopenStream(fd, mode, function (err, stream) {
// do something
});
@@ -2182,6 +2101,7 @@ fdopenStreamSync(fd: number, mode: string): Stream
**示例:**
```js
+ let fd = fileio.openSync(path);
let ss = fileio.fdopenStreamSync(fd, "r+");
```
@@ -2208,6 +2128,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");
@@ -2235,7 +2156,8 @@ fchown(fd: number, uid: number, gid: number, callback: AsyncCallback<void>
**示例:**
```js
- let stat = fileio.statSync(fpath);
+ let fd = fileio.openSync(path);
+ let stat = fileio.statSync(path);
fileio.fchown(fd, stat.uid, stat.gid, function (err){
// do something
});
@@ -2259,7 +2181,8 @@ fchownSync(fd: number, uid: number, gid: number): void
**示例:**
```js
- let stat = fileio.statSync(fpath);
+ let fd = fileio.openSync(path);
+ let stat = fileio.statSync(path);
fileio.fchownSync(fd, stat.uid, stat.gid);
```
@@ -2364,6 +2287,8 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe
**示例:**
```js
+ let filename = path +"/test.txt";
+ let events = 1;
fileio.createWatcher(filename, events, function(watcher){
// do something
});
@@ -2498,7 +2423,7 @@ isFile(): boolean
**示例:**
```js
- let isFile = fileio.statSync(fpath).isFile();
+ let isFile = fileio.statSync(path).isFile();
```
@@ -2600,7 +2525,7 @@ close(): Promise<void>
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path,"r+");
ss.close().then(function(){
console.info("close fileStream succeed");
}).catch(function(err){
@@ -2641,7 +2566,7 @@ closeSync(): void
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path,"r+");
ss.closeSync();
```
@@ -2661,7 +2586,7 @@ flush(): Promise<void>
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path,"r+");
ss.flush().then(function (){
console.info("flush succeed");
}).catch(function(err){
@@ -2685,7 +2610,7 @@ flush(callback: AsyncCallback<void>): void
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path,"r+");
ss.flush(function (err) {
// do something
});
@@ -2702,7 +2627,7 @@ flushSync(): void
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path,"r+");
ss.flushSync();
```
@@ -2733,7 +2658,7 @@ write(buffer: ArrayBuffer | string, options?: {
**示例:**
```js
- let ss= fileio.createStreamSync(fpath, "r+");
+ let ss= fileio.createStreamSync(path, "r+");
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){
@@ -2764,7 +2689,7 @@ write(buffer: ArrayBuffer | string, options: {
**示例:**
```js
- let ss= fileio.createStreamSync(fpath, "r+");
+ let ss= fileio.createStreamSync(path, "r+");
ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) {
if (bytesWritten) {
// do something
@@ -2800,7 +2725,7 @@ writeSync(buffer: ArrayBuffer | string, options?: {
**示例:**
```js
- let ss= fileio.createStreamSync(fpath,"r+");
+ let ss= fileio.createStreamSync(path,"r+");
let num = ss.writeSync("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'});
```
@@ -2830,10 +2755,10 @@ read(buffer: ArrayBuffer, options?: {
**示例:**
```js
- let ss = fileio.createStreamSync(fpath, "r+");
+ let ss = fileio.createStreamSync(path, "r+");
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)));
+ console.log(String.fromCharCode.apply(null, new Uint8Array(readout.buffer)));
}).catch(function(err){
console.info("read data failed with error:"+ err);
});
@@ -2861,7 +2786,7 @@ read(buffer: ArrayBuffer, options: {
**示例:**
```js
- let ss = fileio.createStreamSync(fpath, "r+");
+ let ss = fileio.createStreamSync(path, "r+");
ss.read(new ArrayBuffer(4096),{offset: 1, length: 5, position: 5},function (err, readOut) {
if (readOut) {
console.info("read data succeed");
@@ -2898,7 +2823,7 @@ readSync(buffer: ArrayBuffer, options?: {
**示例:**
```js
- let ss = fileio.createStreamSync(fpath, "r+");
+ let ss = fileio.createStreamSync(path, "r+");
let num = ss.readSync(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5});
```
@@ -2923,7 +2848,7 @@ read(): Promise<Dirent>
**示例:**
```js
- let dir = fileio.opendirSync(path);
+ dir = fileio.opendirSync(path);
dir.read().then(function (dirent){
console.log("read succeed:"+JSON.stringify(dirent));
}).catch(function(err){
@@ -2947,7 +2872,7 @@ read(callback: AsyncCallback<Dirent>): void
**示例:**
```js
- let dir = fileio.opendirSync(path);
+ dir = fileio.opendirSync(path);
dir.read(function (err, dirent) {
if (dirent) {
// do something
@@ -2972,45 +2897,11 @@ readSync(): Dirent
**示例:**
```js
- let dir = fileio.opendirSync(path);
+ dir = fileio.opendirSync(path);
let dirent = dir.readSync();
```
-### close
-
-close(): Promise<void>
-
-异步关闭目录,使用promise形式返回结果。目录被关闭后,Dir中持有的文件描述将被释放,后续将无法从Dir中读取目录项。
-
-**系统能力**:SystemCapability.FileManagement.File.FileIO
-
-**示例:**
- ```js
- let dir = fileio.opendirSync(path);
- dir.close().then(function(err){
- console.info("close dir successfully");
- });
- ```
-
-
- ### close
-
-close(callback: AsyncCallback<void>): void
-
-异步关闭目录,使用callback形式返回结果。目录被关闭后,Dir中持有的文件描述将被释放,后续将无法从Dir中读取目录项。
-
-**系统能力**:SystemCapability.FileManagement.File.FileIO
-
-**示例:**
- ```js
- let dir = fileio.opendirSync(path);
- dir.close(function(err){
- console.info("close dir successfully");
- });
- ```
-
-
### closeSync
closeSync(): void
@@ -3021,7 +2912,7 @@ closeSync(): void
**示例:**
```js
- let dir = fileio.opendirSync(path);
+ dir = fileio.opendirSync(path);
dir.closeSync();
```
@@ -3054,7 +2945,7 @@ isBlockDevice(): boolean
**示例:**
```js
- let dir = fileio.opendirSync(path);
+ dir = fileio.opendirSync(path);
let isBLockDevice = dir.readSync().isBlockDevice();
```
@@ -3074,7 +2965,7 @@ isCharacterDevice(): boolean
**示例:**
```js
- let dir = fileio.opendirSync(path);
+ dir = fileio.opendirSync(path);
let isCharacterDevice = dir.readSync().isCharacterDevice();
```
@@ -3094,7 +2985,7 @@ isDirectory(): boolean
**示例:**
```js
- let dir = fileio.opendirSync(path);
+ dir = fileio.opendirSync(path);
let isDirectory = dir.readSync().isDirectory();
```
@@ -3114,7 +3005,7 @@ isFIFO(): boolean
**示例:**
```js
- let dir = fileio.opendirSync(path);
+ dir = fileio.opendirSync(path);
let isFIFO = dir.readSync().isFIFO();
```
@@ -3134,7 +3025,7 @@ isFile(): boolean
**示例:**
```js
- let dir = fileio.opendirSync(path);
+ dir = fileio.opendirSync(path);
let isFile = dir.readSync().isFile();
```
@@ -3154,7 +3045,7 @@ isSocket(): boolean
**示例:**
```js
- let dir = fileio.opendirSync(dpath);
+ dir = fileio.opendirSync(path);
let isSocket = dir.readSync().isSocket();
```
@@ -3174,6 +3065,6 @@ isSymbolicLink(): boolean
**示例:**
```js
- let dir = fileio.opendirSync(path);
+ dir = fileio.opendirSync(path);
let isSymbolicLink = dir.readSync().isSymbolicLink();
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md
index d2a521a9d6965e374b4dfd3e1222214ad3c9786e..baf1e22240d033d0df379111f9f020a338df5e89 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md
@@ -111,7 +111,7 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
```js
// 获取目录下所有文件
// 通过listFile、getRoot获取的文件uri
- let media_path = file.path
+ let media_path = ""
filemanager.listFile(media_path, "file")
.then((fileInfo) => {
if(Array.isArray(fileInfo)) {
@@ -120,6 +120,9 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
}
}
}).catch((err) => {
+
+
+
console.log(err)
});
```
@@ -152,7 +155,7 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
```js
// 通过listFile、getRoot获取的文件path
- let fileInfos = await filemanager.getRoot();
+ let fileInfos = filemanager.getRoot();
let media_path = "";
for (let i = 0; i < fileInfos.length; i++) {
if (fileInfos[i].name == "image_album") {
@@ -197,7 +200,7 @@ createFile(path : string, filename : string, options? : {dev? : DevInfo}) : P
| 类型 | 说明 |
| --- | -- |
- | Promise<string> | 文件uri |
+ | string | 文件uri |
- 异常
| 错误名称 | 错误类型 | 错误码 |说明 |
@@ -211,7 +214,7 @@ createFile(path : string, filename : string, options? : {dev? : DevInfo}) : P
```js
// 创建文件,返回文件uri
- let media_path = file.uri // 通过listFile、getRoot获取的文件uri
+ let media_path = "" // 通过listFile、getRoot获取的文件uri
let name = "xxx.jpg" // 待保存文件的后缀
filemanager.createFile(media_path, name).then((uri) => {
// 返回uri给应用
@@ -252,13 +255,15 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac
```js
// 创建文件,返回文件uri
// 通过listFile、getRoot获取的文件uri
- let media_path = file.path
+ let media_path = ""
// 待保存文件的后缀
let name = "xxx.jpg"
- filemanager.createFile(media_path, name, (err, uri) => {
+ let dev = "";
+ filemanager.createFile(media_path, name, { DevInfo: dev }, function(err, uri) {
// 返回uri给应用
- console.log("file uri:"+uri);
- });
+ console.log("file uri:"+uri);
+ });
+
```
## FileInfo
diff --git a/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md b/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md
new file mode 100644
index 0000000000000000000000000000000000000000..9a912a0efdb0691018bb535dcf4f310da5dafbb3
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md
@@ -0,0 +1,181 @@
+# 数据标签
+
+>  **说明:**
+> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+该模块提供文件数据安全等级的相关功能:向应用程序提供查询、设置文件数据安全等级的JS接口。
+
+## 导入模块
+
+```js
+import securityLabel from '@ohos.securityLabel';
+```
+
+## 使用说明
+
+使用该功能模块对文件/目录进行操作前,需要先获取其应用沙箱路径,获取方式及其接口用法请参考:
+
+```js
+import featureAbility from '@ohos.ability.featureAbility';
+let context = featureAbility.getContext();
+let path = context.getFilesDir();
+```
+
+## securityLabel.setSecurityLabel
+
+setSecurityLabel(path:string, dataLevel:string):Promise<void>
+
+以异步方法设置数据标签,以promise形式返回结果。
+
+**系统能力**:SystemCapability.FileManagement.File.DistributedFile
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| --------- | ------ | ---- | -------------------------------------------- |
+| path | string | 是 | 文件路径 |
+| dataLevel | string | 是 | 文件等级属性,只支持"s0","s1","s2","s3","s4" |
+
+**返回值:**
+
+ | 类型 | 说明 |
+ | ------------------- | ---------------- |
+ | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。|
+
+**示例:**
+
+ ```js
+ let dataLevel = "s4";
+ securityLabel.setSecurityLabel(path, dataLevel).then(function(){
+ console.info("setSecurityLabel successfully");
+ }).catch(function(error){
+ console.info("setSecurityLabel failed with error:" + error);
+ });
+ ```
+
+## securityLabel.setSecurityLabel
+
+setSecurityLabel(path:string, dataLevel:string, callback: AsyncCallback<void>):void
+
+以异步方法设置数据标签,以callback形式返回结果。
+
+**系统能力**:SystemCapability.FileManagement.File.DistributedFile
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| --------- | ------------------------- | ---- | -------------------------------------------- |
+| path | string | 是 | 文件路径 |
+| dataLevel | string | 是 | 文件等级属性,只支持"s0","s1","s2","s3","s4" |
+| callback | AsyncCallback<void> | 是 | 是否设置数据标签之后的回调 |
+
+**示例:**
+
+ ```js
+ let dataLevel = "s4";
+ securityLabel.setSecurityLabel(path, dataLevel, function(error){
+ console.info("setSecurityLabel:" + JSON.stringify(error));
+ });
+ ```
+## securityLabel.setSecurityLabelSync
+
+setSecurityLabelSync(path:string, dataLevel:string):void
+
+以同步方法设置数据标签。
+
+**系统能力**:SystemCapability.FileManagement.File.DistributedFile
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| --------- | ------ | ---- | -------------------------------------------- |
+| path | string | 是 | 文件路径 |
+| dataLevel | string | 是 | 文件等级属性,只支持"s0","s1","s2","s3","s4" |
+
+**示例:**
+
+```js
+let dataLevel = "s4";
+securityLabel.setSecurityLabelSync(path, dataLevel);
+```
+
+## securityLabel.getSecurityLabel
+
+getSecurityLabel(path:string):Promise<string>
+
+异步方法获取数据标签,以promise形式返回结果。
+
+**系统能力**:SystemCapability.FileManagement.File.DistributedFile
+
+**参数:**
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------ | ------ | ---- | -------- |
+ | path | string | 是 | 文件路径 |
+
+**返回值:**
+
+ | 类型 | 说明 |
+ | --------------------- | ------------ |
+ | Promise<string> | 返回数据标签 |
+
+**示例:**
+
+ ```js
+ let dataLevel = "s4";
+ securityLabel.getSecurityLabel(path).then(function(dataLevel){
+ console.log("getSecurityLabel successfully:" + dataLevel);
+ }).catch(function(error){
+ console.log("getSecurityLabel failed with error:" + error);
+ });
+ ```
+
+## securityLabel.getSecurityLabel
+
+getSecurityLabel(path:string, callback:AsyncCallback<string>): void
+
+异步方法获取数据标签,以callback形式返回结果。
+
+**系统能力**:SystemCapability.FileManagement.File.DistributedFile
+
+**参数:**
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | --------------------------- | ---- | -------------------------- |
+ | path | string | 是 | 文件路径 |
+ | callback | AsyncCallback<string> | 是 | 异步获取数据标签之后的回调 |
+
+**示例:**
+
+ ```js
+ let dataLevel = "s4";
+ securityLabel.getSecurityLabel(path,function(error, dataLevel){
+ console.log("getSecurityLabel successfully:" + dataLevel);
+ });
+ ```
+## securityLabel.getSecurityLabelSync
+
+getSecurityLabelSync(path:string):string
+
+以同步方法获取数据标签。
+
+**系统能力**:SystemCapability.FileManagement.File.DistributedFile
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | ------ | ---- | -------- |
+| path | string | 是 | 文件路径 |
+
+**返回值:**
+
+| 类型 | 说明 |
+| ------ | ------------ |
+| string | 返回数据标签 |
+
+**示例:**
+
+```js
+let result = securityLabel.getSecurityLabelSync(path);
+console.log("getSecurityLabel successfully:" + result);
+```
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 dde71634ef505143dab3fad9920c71c5925282f3..f9d9047f6f9c85483e40cc7efe78b749eefc3fea 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
@@ -4,14 +4,13 @@
>
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。
-> - 本模块接口为系统接口,三方应用不支持调用。
该模块提供空间查询相关的常用功能:包括对内外卡的空间查询,对应用分类数据统计的查询,对应用数据的查询等。
## 导入模块
```js
-import storagestatistics from "@ohos.storageStatistics";
+import storageStatistics from "@ohos.storageStatistics";
```
## storagestatistics.getTotalSizeOfVolume
@@ -20,8 +19,12 @@ getTotalSizeOfVolume(volumeUuid: string): Promise<number>
异步获取指定卷的总空间大小,以promise方式返回。
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+**系统API**:该接口为系统接口,三方应用不支持调用
+
- 参数
| 参数名 | 类型 | 必填 | 说明 |
@@ -51,8 +54,12 @@ getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):v
异步获取指定卷的总空间大小,以callback方式返回。
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+**系统API**:该接口为系统接口,三方应用不支持调用
+
- 参数
| 参数名 | 类型 | 必填 | 说明 |
@@ -78,8 +85,12 @@ getFreeSizeOfVolume(volumeUuid: string): Promise<number>
异步获取指定卷的可用空间大小,以promise方式返回。
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+**系统API**:该接口为系统接口,三方应用不支持调用
+
- 参数
| 参数名 | 类型 | 必填 | 说明 |
@@ -110,8 +121,12 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):vo
异步获取指定卷的可用空间大小,以callback方式返回。
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+**系统API**:该接口为系统接口,三方应用不支持调用
+
- 参数
| 参数名 | 类型 | 必填 | 说明 |
@@ -135,8 +150,12 @@ getBundleStats(packageName: string): Promise<BundleStats>
异步获取应用存储数据,以promise方式返回。
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+**系统API**:该接口为系统接口,三方应用不支持调用
+
- 参数
| 参数名 | 类型 | 必填 | 说明 |
@@ -166,8 +185,12 @@ getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>)
异步获取应用存储数据,以callback方式返回。
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+**系统API**:该接口为系统接口,三方应用不支持调用
+
- 参数
| 参数名 | 类型 | 必填 | 说明 |
@@ -185,14 +208,311 @@ getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>)
});
```
+
+
+## storagestatistics.getCurrentBundleStats9+
+
+getCurrentBundleStats(): Promise
+
+第三方应用异步获取占用空间,以promise方式返回。
+
+**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+- 返回值
+
+ | 类型 | 说明 |
+ | ------------------------------------------ | -------------------------- |
+ | Promise<[Bundlestats](#bundlestats)> | 返回指定卷上的应用存储状态 |
+
+- 示例
+
+ ```js
+ let bundleStats = storageStatistics.getCurrentBundleStats();
+ console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
+ ```
+
+## storagestatistics.getCurrentBundleStats9+
+
+getCurrentBundleStats(callback: AsyncCallback): void
+
+第三方应用异步获取占用空间,以callback方式返回。
+
+**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
+ | callback | callback:AsyncCallback<[BundleStats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 |
+
+- 示例
+
+ ```js
+ storagestatistics.getCurrentBundleStats(function(error, bundleStats){
+ // do something
+ console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
+ });
+ ```
+
+
+
## BundleStats9+
**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.SpatialStatistics。
-### 属性
+- 属性
+
+| 名称 | 类型 | 说明 |
+| --------- | ------ | -------------- |
+| appSize | number | app数据大小 |
+| cacheSize | number | 缓存数据大小 |
+| dataSize | number | 应用总数据大小 |
+
+
+
+
+## storagestatistics.getTotalSize9+
+
+getTotalSize(): Promise
+
+获取内卡的总空间大小,以promise方式返回。
+
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
+**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+**系统API**:该接口为系统接口,三方应用不支持调用
+
+- 返回值
+
+ | 类型 | 说明 |
+ | --------------------- | ------------------ |
+ | Promise<number> | 返回内卡的总空间大小 |
+
+- 示例
+
+ ```js
+ let number = storageStatistics.getTotalSize();
+ console.info("getTotalSize successfully:"+ JSON.stringify(number));
+ ```
+
+## storagestatistics.getTotalSize9+
+
+getTotalSize(callback: AsyncCallback): void
+
+获取内卡的总空间大小,以callback方式返回。
+
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
+**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+**系统API**:该接口为系统接口,三方应用不支持调用
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------------------------------------ | ---- | ------------------------ |
+ | callback | callback:AsyncCallback<number> | 是 | 获取内卡的总空间大小之后的回调 |
+
+- 示例
+
+ ```js
+ storagestatistics.getTotalSize(function(error, number){
+ // do something
+ console.info("getTotalSize successfully:"+ JSON.stringify(number));
+ });
+ ```
+
+
+## storagestatistics.getFreeSize9+
+
+getFreeSize(): Promise
+
+获取内卡的可用空间大小,以promise方式返回。
+
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
+**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+**系统API**:该接口为系统接口,三方应用不支持调用
+
+- 返回值
+
+ | 类型 | 说明 |
+ | --------------------- | ------------------ |
+ | Promise<number> | 返回内卡的可用空间大小 |
+
+- 示例
+
+ ```js
+ let number = storageStatistics.getFreeSize();
+ console.info("getFreeSize successfully:"+ JSON.stringify(number));
+ ```
+
+
+## storagestatistics.getFreeSize9+
+
+getFreeSize(callback: AsyncCallback): void
+
+获取内卡的可用空间大小,以callback方式返回。
+
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
+**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+**系统API**:该接口为系统接口,三方应用不支持调用
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------------------------------------ | ---- | ------------------------- |
+ | callback | callback:AsyncCallback<number> | 是 | 获取内卡的可用空间大小之后的回调 |
+
+- 示例
+
+ ```js
+ storagestatistics.getFreeSize(function(error, number){
+ // do something
+ console.info("getFreeSize successfully:"+ JSON.stringify(number));
+ });
+ ```
+
+
+
+## storagestatistics.getSystemSize9+
+
+getSystemSize(): Promise<number>
+
+异步获取系统空间大小,以promise方式返回。
+
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
+**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+**系统API**:该接口为系统接口,三方应用不支持调用
+
+- 返回值
+
+ | 类型 | 说明 |
+ | --------------------- | ---------------- |
+ | Promise<number> | 返回系统空间大小 |
+
+- 示例
+
+ ```js
+ storagestatistics.getSystemSize().then(function(number){
+ console.info("getSystemSize successfully:"+ number);
+ }).catch(function(err){
+ console.info("getSystemSize failed with error:"+ err);
+ });
+ ```
+
+## storagestatistics.getSystemSize9+
+
+getSystemSize(callback:AsyncCallback<number>):void
+
+异步获取系统空间大小,以callback方式返回。
+
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
+**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+**系统API**:该接口为系统接口,三方应用不支持调用
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------------------------------------ | ---- | -------------------------- |
+ | callback | callback:AsyncCallback<number> | 是 | 获取系统空间大小之后的回调 |
+
+- 示例
+
+ ```js
+ storagestatistics.getSystemSize(function(error, number){
+ // do something
+ console.info("getSystemSize successfully:"+ number);
+ });
+ ```
+
+
+
+## storagestatistics.getUserStorageStats9+
+
+getUserStorageStats(userId?: string): Promise<StorageStats>
+
+异步获取用户各类别数据大小,以promise方式返回。
+
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
+**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+**系统API**:该接口为系统接口,三方应用不支持调用
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------ | ---- | ---- |
+ | userId | string | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。|
+
+- 返回值
+
+ | 类型 | 说明 |
+ | --------------------- | ---------------- |
+ | Promise<[StorageStats](#StorageStats)> | 返回各类别数据大小 |
+
+- 示例
+
+ ```js
+ let userId = "";
+ storagestatistics.getUserStorageStats(userId).then(function(StorageStats){
+ console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
+ }).catch(function(err){
+ console.info("getUserStorageStats failed with error:"+ err);
+ });
+ ```
+
+## storagestatistics.getUserStorageStats9+
+
+getUserStorageStats(userId?: string, callback:AsyncCallback<StorageStats>):void
+
+异步获取用户各类别数据大小,以callback方式返回。
+
+**需要权限**:ohos.permission.STORAGE_MANAGER
+
+**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+**系统API**:该接口为系统接口,三方应用不支持调用
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------------------------------------ | ---- | -------------------------- |
+ | userId | string | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。 |
+ | callback | callback:AsyncCallback<[StorageStats](#StorageStats)> | 是 | 返回各类别数据大小之后的回调 |
+
+- 示例
+
+ ```js
+ let userId = "";
+ storagestatistics.getUserStorageStats(userId, function(error, StorageStats){
+ // do something
+ console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
+ });
+ ```
+
+
+
+## StorageStats9+
+
+**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.SpatialStatistics。
+
+- 属性
| 名称 | 类型 | 说明 |
| --------- | ------ | -------------- |
-| appSize9+ | number | app数据大小 |
-| cacheSize9+ | number | 缓存数据大小 |
-| dataSize9+ | number | 应用总数据大小 |
\ No newline at end of file
+| total | number | 内卡总空间大小 |
+| audio | number | 音频数据大小 |
+| video | number | 视频数据大小 |
+| image | number | 图像数据大小 |
+| file | number | 文件数据大小 |
+| app | number | 应用数据大小 |