提交 73eab8cf 编写于 作者: Z zhangxingxia

update apis

Signed-off-by: Nzhangxingxia <zhangxingxia1@huawei.com>
上级 1fbbc31a
...@@ -29,9 +29,9 @@ getStorageDataDir():Promise&lt;string&gt; ...@@ -29,9 +29,9 @@ getStorageDataDir():Promise&lt;string&gt;
```js ```js
environment.getStorageDataDir().then(function(path){ environment.getStorageDataDir().then(function(path){
// do something console.info("getStorageDataDir successfully:"+ path);
}).catch(function(error){ }).catch(function(error){
console.info("getStorageDataDir failed with error:"+ error);
}); });
``` ```
...@@ -71,9 +71,9 @@ getUserDataDir():Promise&lt;string&gt; ...@@ -71,9 +71,9 @@ getUserDataDir():Promise&lt;string&gt;
```js ```js
environment.getUserDataDir().then(function(path){ environment.getUserDataDir().then(function(path){
// do something console.info("getUserDataDir successfully:"+ path);
}).catch(function(error){ }).catch(function(error){
console.info("getUserDataDir failed with error:"+ error);
}); });
``` ```
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
## 导入模块 ## 导入模块
```js ```js
import filemanager from 'ohos.filemanager' import filemanager from 'ohos.filemanager';
``` ```
## 系统能力 ## 系统能力
...@@ -31,17 +31,15 @@ getRoot(options? : {dev? : DevInfo}) : Promise&lt;FileInfo[]&gt; ...@@ -31,17 +31,15 @@ getRoot(options? : {dev? : DevInfo}) : Promise&lt;FileInfo[]&gt;
- 示例 - 示例
```js ```js
filemanager.getRoot() filemanager.getRoot().then((fileInfo) => {
.then((fileInfo) => {
if(Array.isArray(fileInfo)) { if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) { for (var i = 0; i < fileInfo.length; i++) {
console.log(JSON.Stringify(fileInfo)) console.log(JSON.Stringify(fileInfo))
} }
} }
}) }).catch((err) => {
.catch((err) => {
console.log(err) console.log(err)
}) });
``` ```
## filemanager.getRoot ## filemanager.getRoot
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## 导入模块 ## 导入模块
```js ```js
import statfs from '@ohos.statfs' import statfs from '@ohos.statfs';
``` ```
## 使用说明 ## 使用说明
...@@ -18,7 +18,7 @@ import statfs from '@ohos.statfs' ...@@ -18,7 +18,7 @@ import statfs from '@ohos.statfs'
通过上述接口获取到应用目录路径dir,文件名为“xxx.txt”,文件所在绝对路径为: 通过上述接口获取到应用目录路径dir,文件名为“xxx.txt”,文件所在绝对路径为:
```js ```js
let path = dir + "xxx.txt" let path = dir + "xxx.txt";
``` ```
## 系统能力 ## 系统能力
...@@ -46,7 +46,12 @@ getFreeBytes(path:string):Promise&lt;number&gt; ...@@ -46,7 +46,12 @@ getFreeBytes(path:string):Promise&lt;number&gt;
- 示例: - 示例:
```js ```js
let num = await statfs.getFreeBytes(path); let path = "/data";
statfs.getFreeBytes(path).then(function (number){
console.info("getFreeBytes successfully:"+ number);
}).catch(function(err){
console.info("getFreeBytes failed with error:"+ err);
});
``` ```
## statfs.getFreeBytes ## statfs.getFreeBytes
...@@ -91,7 +96,12 @@ getTotalBytes.(path:string):Promise&lt;number&gt; ...@@ -91,7 +96,12 @@ getTotalBytes.(path:string):Promise&lt;number&gt;
- 示例: - 示例:
```js ```js
let num = await statfs.getTotalBytes(path); let path = "/data";
statfs.getTotalBytes(path).then(function (number){
console.info("getTotalBytes successfully:"+ number);
}).catch(function(err){
console.info("getTotalBytes failed with error:"+ err);
});
``` ```
## statfs.getTotalBytes ## statfs.getTotalBytes
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册