提交 5f9f9d93 编写于 作者: R raoxian

修改fileio、securityLabel、storage-statistics、volumemanager文档

Signed-off-by: Nraoxian <raoxian@huawei.com>
上级 de8dd534
...@@ -353,58 +353,11 @@ closeSync(fd: number): void ...@@ -353,58 +353,11 @@ closeSync(fd: number): void
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
fileio.closeSync(fd); fileio.closeSync(fd);
``` ```
## fileio.close<sup>7+</sup>
close(): Promise&lt;void&gt;
关闭文件流,使用Promise异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | 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.close<sup>7+</sup>
close(callback: AsyncCallback&lt;void&gt;): void
关闭文件流,使用callback异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步关闭文件流之后的回调。 |
**示例:**
```js
fileio.close(function(err){
// do something
});
```
## fileio.copyFile ## 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;
...@@ -430,6 +383,8 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise&lt;voi ...@@ -430,6 +383,8 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise&lt;voi
**示例:** **示例:**
```js ```js
let src = path;
let dest = src + 'tgt';
fileio.copyFile(src, dest).then(function(){ fileio.copyFile(src, dest).then(function(){
console.info("copyFile succeed"); console.info("copyFile succeed");
}).catch(function(err){ }).catch(function(err){
...@@ -458,6 +413,8 @@ copyFile(src: string | number, dest: string | number, mode: number, callback: As ...@@ -458,6 +413,8 @@ copyFile(src: string | number, dest: string | number, mode: number, callback: As
**示例:** **示例:**
```js ```js
let src = path;
let dest = src + 'tgt';
fileio.copyFile(src, dest, function (err) { fileio.copyFile(src, dest, function (err) {
// do something // do something
}); });
...@@ -483,6 +440,8 @@ copyFileSync(src: string | number, dest: string | number, mode?: number): void ...@@ -483,6 +440,8 @@ copyFileSync(src: string | number, dest: string | number, mode?: number): void
**示例:** **示例:**
```js ```js
let src = path;
let dest = src + 'tgt';
fileio.copyFileSync(src, dest); fileio.copyFileSync(src, dest);
``` ```
...@@ -1059,7 +1018,7 @@ hash(path: string, algorithm: string): Promise&lt;string&gt; ...@@ -1059,7 +1018,7 @@ hash(path: string, algorithm: string): Promise&lt;string&gt;
```js ```js
fileio.hash(path, "sha256").then(function(str){ fileio.hash(path, "sha256").then(function(str){
console.info("calculate file hash succeed:"+ str); console.info("calculate file hash succeed:"+ str);
}).catch(function(error){ }).catch(function(err){
console.info("calculate file hash failed with error:"+ err); console.info("calculate file hash failed with error:"+ err);
}); });
``` ```
...@@ -1116,7 +1075,7 @@ chmod(path: string, mode: number):Promise&lt;void&gt; ...@@ -1116,7 +1075,7 @@ chmod(path: string, mode: number):Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
fileio.chmod(path, mode).then(function() { fileio.chmod(path, 0o700).then(function() {
console.info("chmod succeed"); console.info("chmod succeed");
}).catch(function(err){ }).catch(function(err){
console.info("chmod failed with error:"+ err); console.info("chmod failed with error:"+ err);
...@@ -1143,7 +1102,7 @@ chmod(path: string, mode: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1143,7 +1102,7 @@ chmod(path: string, mode: number, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
fileio.chmod(path, mode, function (err) { fileio.chmod(path, 0o700, function (err) {
// do something // do something
}); });
``` ```
...@@ -1167,7 +1126,7 @@ chmodSync(path: string, mode: number): void ...@@ -1167,7 +1126,7 @@ chmodSync(path: string, mode: number): void
**示例:** **示例:**
```js ```js
fileio.chmodSync(path, mode); fileio.chmodSync(path, 0o700);
``` ```
...@@ -1194,6 +1153,7 @@ fstat(fd: number): Promise&lt;Stat&gt; ...@@ -1194,6 +1153,7 @@ fstat(fd: number): Promise&lt;Stat&gt;
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
fileio.fstat(fd).then(function(stat){ fileio.fstat(fd).then(function(stat){
console.info("fstat succeed:"+ JSON.stringify(stat)); console.info("fstat succeed:"+ JSON.stringify(stat));
}).catch(function(err){ }).catch(function(err){
...@@ -1307,7 +1267,9 @@ ftruncate(fd: number, len: number, callback:AsyncCallback&lt;void&gt;): void ...@@ -1307,7 +1267,9 @@ ftruncate(fd: number, len: number, callback:AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
fileio.ftruncate(fd, len, function(err){ let fd = fileio.openSync(path);
let len = 5;
fileio.ftruncate(fd, 5, function(err){
// do something // do something
}); });
``` ```
...@@ -1331,6 +1293,8 @@ ftruncateSync(fd: number, len?: number): void ...@@ -1331,6 +1293,8 @@ ftruncateSync(fd: number, len?: number): void
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
let len = 5;
fileio.ftruncateSync(fd, len); fileio.ftruncateSync(fd, len);
``` ```
...@@ -1359,6 +1323,7 @@ truncate(path: string, len?: number): Promise&lt;void&gt; ...@@ -1359,6 +1323,7 @@ truncate(path: string, len?: number): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
let len = 5;
fileio.truncate(path, len).then(function(){ fileio.truncate(path, len).then(function(){
console.info("truncate file succeed"); console.info("truncate file succeed");
}).catch(function(err){ }).catch(function(err){
...@@ -1386,6 +1351,7 @@ truncate(path: string, len: number, callback:AsyncCallback&lt;void&gt;): void ...@@ -1386,6 +1351,7 @@ truncate(path: string, len: number, callback:AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
let len = 5;
fileio.truncate(path, len, function(err){ fileio.truncate(path, len, function(err){
// do something // do something
}); });
...@@ -1410,6 +1376,7 @@ truncateSync(path: string, len?: number): void ...@@ -1410,6 +1376,7 @@ truncateSync(path: string, len?: number): void
**示例:** **示例:**
```js ```js
let len = 5;
fileio.truncateSync(path, len); fileio.truncateSync(path, len);
``` ```
...@@ -1467,13 +1434,13 @@ readText(filePath: string, options: { ...@@ -1467,13 +1434,13 @@ readText(filePath: string, options: {
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| filePath | string | 是 | 待读取文件的应用沙箱路径。 | | filePath | string | 是 | 待读取文件的应用沙箱路径。 |
| options | Object | | 支持如下选项:<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;encoding,string类型,表示数据的编码方式,默认&nbsp;'utf-8',仅支持&nbsp;'utf-8'。 | | options | Object | | 支持如下选项:<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;encoding,string类型,表示数据的编码方式,默认&nbsp;'utf-8',仅支持&nbsp;'utf-8'。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调函数,返回读取文件的内容。 | | callback | AsyncCallback&lt;string&gt; | 是 | 回调函数,返回读取文件的内容。 |
**示例:** **示例:**
```js ```js
fileio.readText(path, function(err, str){ fileio.readText(path, { position: 1, encoding: 'UTF-8' }, function(err, str){
// do something // do something
}); });
``` ```
...@@ -1593,76 +1560,6 @@ lstatSync(path:string): Stat ...@@ -1593,76 +1560,6 @@ lstatSync(path:string): Stat
``` ```
## fileio.read<sup>7+</sup>
read(buffer: ArrayBuffer, options?: {
position?: number;
offset?: number;
length?: number;
}): Promise&lt;ReadOut&gt;
从文件读取数据,使用Promise异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ------------------------------------------------------------ |
| buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>约束:offset+length<=buffer.size。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | 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.read<sup>7+</sup>
read(buffer: ArrayBuffer, options: {
position?: number;
offset?: number;
length?: number;
}, callback: AsyncCallback&lt;ReadOut&gt;): void
从文件读取数据,使用callback异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | 是 | 异步从文件读取数据之后的回调。 |
**示例:**
```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.rename<sup>7+</sup> ## fileio.rename<sup>7+</sup>
rename(oldPath: string, newPath: string): Promise&lt;void&gt; rename(oldPath: string, newPath: string): Promise&lt;void&gt;
...@@ -1687,6 +1584,8 @@ rename(oldPath: string, newPath: string): Promise&lt;void&gt; ...@@ -1687,6 +1584,8 @@ rename(oldPath: string, newPath: string): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
let oldPath = path;
let newPath = oldPath + '123';
fileio.rename(oldPath, newPath).then(function() { fileio.rename(oldPath, newPath).then(function() {
console.info("rename succeed"); console.info("rename succeed");
}).catch(function(err){ }).catch(function(err){
...@@ -1714,6 +1613,8 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback&lt;void&gt;): v ...@@ -1714,6 +1613,8 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback&lt;void&gt;): v
**示例:** **示例:**
```js ```js
let oldPath = path;
let newPath = oldPath + '123';
fileio.rename(oldPath, newPath, function(err){ fileio.rename(oldPath, newPath, function(err){
}); });
``` ```
...@@ -1737,6 +1638,8 @@ renameSync(oldPath: string, newPath: string): void ...@@ -1737,6 +1638,8 @@ renameSync(oldPath: string, newPath: string): void
**示例:** **示例:**
```js ```js
let oldPath = path;
let newPath = oldPath + '123';
fileio.renameSync(oldPath, newPath); fileio.renameSync(oldPath, newPath);
``` ```
...@@ -1764,6 +1667,7 @@ fsync(fd: number): Promise&lt;void&gt; ...@@ -1764,6 +1667,7 @@ fsync(fd: number): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
fileio.fsync(fd).then(function(){ fileio.fsync(fd).then(function(){
console.info("sync data succeed"); console.info("sync data succeed");
}).catch(function(err){ }).catch(function(err){
...@@ -1790,6 +1694,7 @@ fsync(fd: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1790,6 +1694,7 @@ fsync(fd: number, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
fileio.fsync(fd, function(err){ fileio.fsync(fd, function(err){
// do something // do something
}); });
...@@ -1813,6 +1718,7 @@ fsyncSync(fd: number): void ...@@ -1813,6 +1718,7 @@ fsyncSync(fd: number): void
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
fileio.fsyncSync(fd); fileio.fsyncSync(fd);
``` ```
...@@ -1840,6 +1746,7 @@ fdatasync(fd: number): Promise&lt;void&gt; ...@@ -1840,6 +1746,7 @@ fdatasync(fd: number): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
fileio.fdatasync(fd).then(function(err) { fileio.fdatasync(fd).then(function(err) {
console.info("sync data succeed"); console.info("sync data succeed");
}).catch(function(err){ }).catch(function(err){
...@@ -1866,6 +1773,7 @@ fdatasync(fd: number, callback:AsyncCallback&lt;void&gt;): void ...@@ -1866,6 +1773,7 @@ fdatasync(fd: number, callback:AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
fileio.fdatasync (fd, function (err) { fileio.fdatasync (fd, function (err) {
// do something // do something
}); });
...@@ -1889,6 +1797,7 @@ fdatasyncSync(fd: number): void ...@@ -1889,6 +1797,7 @@ fdatasyncSync(fd: number): void
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
let stat = fileio.fdatasyncSync(fd); let stat = fileio.fdatasyncSync(fd);
``` ```
...@@ -1917,6 +1826,8 @@ symlink(target: string, srcPath: string): Promise&lt;void&gt; ...@@ -1917,6 +1826,8 @@ symlink(target: string, srcPath: string): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
let target = path;
let srcPath = target + 'aaa';
fileio.symlink(target, srcPath).then(function() { fileio.symlink(target, srcPath).then(function() {
console.info("symlink succeed"); console.info("symlink succeed");
}).catch(function(err){ }).catch(function(err){
...@@ -1944,6 +1855,8 @@ symlink(target: string, srcPath: string, callback: AsyncCallback&lt;void&gt;): v ...@@ -1944,6 +1855,8 @@ symlink(target: string, srcPath: string, callback: AsyncCallback&lt;void&gt;): v
**示例:** **示例:**
```js ```js
let target = path;
let srcPath = target + 'aaa';
fileio.symlink(target, srcPath, function (err) { fileio.symlink(target, srcPath, function (err) {
// do something // do something
}); });
...@@ -1968,6 +1881,8 @@ symlinkSync(target: string, srcPath: string): void ...@@ -1968,6 +1881,8 @@ symlinkSync(target: string, srcPath: string): void
**示例:** **示例:**
```js ```js
let target = path;
let srcPath = target + 'aaa';
fileio.symlinkSync(target, srcPath); fileio.symlinkSync(target, srcPath);
``` ```
...@@ -2163,6 +2078,8 @@ fchmod(fd: number, mode: number): Promise&lt;void&gt; ...@@ -2163,6 +2078,8 @@ fchmod(fd: number, mode: number): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
let mode = 0o700;
fileio.fchmod(fd, mode).then(function() { fileio.fchmod(fd, mode).then(function() {
console.info("chmod succeed"); console.info("chmod succeed");
}).catch(function(err){ }).catch(function(err){
...@@ -2190,6 +2107,8 @@ fchmod(fd: number, mode: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -2190,6 +2107,8 @@ fchmod(fd: number, mode: number, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
let mode = 0o700;
fileio.fchmod(fd, mode, function (err) { fileio.fchmod(fd, mode, function (err) {
// do something // do something
}); });
...@@ -2214,6 +2133,8 @@ fchmodSync(fd: number, mode: number): void ...@@ -2214,6 +2133,8 @@ fchmodSync(fd: number, mode: number): void
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
let mode = 0o700;
fileio.fchmodSync(fd, mode); fileio.fchmodSync(fd, mode);
``` ```
...@@ -2416,6 +2337,7 @@ fchown(fd: number, uid: number, gid: number): Promise&lt;void&gt; ...@@ -2416,6 +2337,7 @@ fchown(fd: number, uid: number, gid: number): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
let stat = fileio.statSync(path); let stat = fileio.statSync(path);
fileio.fchown(fd, stat.uid, stat.gid).then(function() { fileio.fchown(fd, stat.uid, stat.gid).then(function() {
console.info("chown succeed"); console.info("chown succeed");
...@@ -2445,6 +2367,7 @@ fchown(fd: number, uid: number, gid: number, callback: AsyncCallback&lt;void&gt; ...@@ -2445,6 +2367,7 @@ fchown(fd: number, uid: number, gid: number, callback: AsyncCallback&lt;void&gt;
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
let stat = fileio.statSync(path); let stat = fileio.statSync(path);
fileio.fchown(fd, stat.uid, stat.gid, function (err){ fileio.fchown(fd, stat.uid, stat.gid, function (err){
// do something // do something
...@@ -2471,6 +2394,7 @@ fchownSync(fd: number, uid: number, gid: number): void ...@@ -2471,6 +2394,7 @@ fchownSync(fd: number, uid: number, gid: number): void
**示例:** **示例:**
```js ```js
let fd = fileio.openSync(path);
let stat = fileio.statSync(path); let stat = fileio.statSync(path);
fileio.fchownSync(fd, stat.uid, stat.gid); fileio.fchownSync(fd, stat.uid, stat.gid);
``` ```
...@@ -3103,7 +3027,7 @@ read(buffer: ArrayBuffer, options?: { ...@@ -3103,7 +3027,7 @@ read(buffer: ArrayBuffer, options?: {
```js ```js
let ss = fileio.createStreamSync(path, "r+"); 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.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){ }).catch(function(err){
...@@ -3180,7 +3104,7 @@ readSync(buffer: ArrayBuffer, options?: { ...@@ -3180,7 +3104,7 @@ readSync(buffer: ArrayBuffer, options?: {
## Dir ## Dir
管理目录,在调用Dir的方法前,需要先通过[opendir()](#fileioopendir)方法(同步或异步)来构建一个Dir实例。 管理目录,在调用Dir的方法前,需要先通过opendir方法(同步或异步)来构建一个Dir实例。
### read ### read
...@@ -3450,7 +3374,7 @@ isSocket(): boolean ...@@ -3450,7 +3374,7 @@ isSocket(): boolean
**示例:** **示例:**
```js ```js
let dir = fileio.opendirSync(dpath); let dir = fileio.opendirSync(path);
let isSocket = dir.readSync().isSocket(); let isSocket = dir.readSync().isSocket();
``` ```
......
...@@ -18,7 +18,10 @@ import securityLabel from '@ohos.securityLabel'; ...@@ -18,7 +18,10 @@ import securityLabel from '@ohos.securityLabel';
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext(); let context = featureAbility.getContext();
let path = context.getFilesDir(); let path = '';
context.getFilesDir().then((data) => {
path = data;
})
``` ```
## securityLabel.setSecurityLabel ## securityLabel.setSecurityLabel
......
...@@ -470,7 +470,7 @@ getUserStorageStats(userId? : number): Promise&lt;StorageStats&gt; ...@@ -470,7 +470,7 @@ getUserStorageStats(userId? : number): Promise&lt;StorageStats&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- | | ---------- | ------ | ---- | ---- |
| userId | string | 否 | 用户id <br/>确认当前用户:<br/>-&nbsp;有值:表示指定用户。<br/>-&nbsp;无值:表示当前用户。| | userId | number | 否 | 用户id <br/>确认当前用户:<br/>-&nbsp;有值:表示指定用户。<br/>-&nbsp;无值:表示当前用户。|
**返回值:** **返回值:**
...@@ -481,7 +481,7 @@ getUserStorageStats(userId? : number): Promise&lt;StorageStats&gt; ...@@ -481,7 +481,7 @@ getUserStorageStats(userId? : number): Promise&lt;StorageStats&gt;
**示例:** **示例:**
```js ```js
let userId = ""; let userId = 1;
storageStatistics.getUserStorageStats(userId).then(function(StorageStats){ storageStatistics.getUserStorageStats(userId).then(function(StorageStats){
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
}).catch(function(err){ }).catch(function(err){
...@@ -507,13 +507,13 @@ getUserStorageStats(userId: number, callback:AsyncCallback&lt;StorageStats&gt;): ...@@ -507,13 +507,13 @@ getUserStorageStats(userId: number, callback:AsyncCallback&lt;StorageStats&gt;):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| userId | string | 否 | 用户id <br/>确认当前用户:<br/>-&nbsp;有值:表示指定用户。<br/>-&nbsp;无值:表示当前用户。 | | userId | number | 否 | 用户id <br/>确认当前用户:<br/>-&nbsp;有值:表示指定用户。<br/>-&nbsp;无值:表示当前用户。 |
| callback | callback:AsyncCallback&lt;[StorageStats](#StorageStats)&gt; | 是 | 返回各类别数据大小之后的回调 | | callback | callback:AsyncCallback&lt;[StorageStats](#StorageStats)&gt; | 是 | 返回各类别数据大小之后的回调 |
**示例:** **示例:**
```js ```js
let userId = ""; let userId = 1;
storageStatistics.getUserStorageStats(userId, function(error, StorageStats){ storageStatistics.getUserStorageStats(userId, function(error, StorageStats){
// do something // do something
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
......
...@@ -204,7 +204,11 @@ getVolumeByUuid(uuid: string): Promise&lt;Volume&gt; ...@@ -204,7 +204,11 @@ getVolumeByUuid(uuid: string): Promise&lt;Volume&gt;
```js ```js
let uuid = ""; 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 ## volumemanager.getVolumeByUuid
...@@ -259,7 +263,11 @@ getVolumeById(id: string): Promise&lt;Volume&gt; ...@@ -259,7 +263,11 @@ getVolumeById(id: string): Promise&lt;Volume&gt;
```js ```js
let id = ""; 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 ## volumemanager.getVolumeById
...@@ -316,7 +324,11 @@ setVolumeDescription(uuid: string, description: string): Promise&lt;void&gt; ...@@ -316,7 +324,11 @@ setVolumeDescription(uuid: string, description: string): Promise&lt;void&gt;
```js ```js
let uuid = ""; let uuid = "";
let description = ""; 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 ## volumemanager.setVolumeDescription
...@@ -373,7 +385,11 @@ format(volId: string): Promise&lt;void&gt; ...@@ -373,7 +385,11 @@ format(volId: string): Promise&lt;void&gt;
```js ```js
let volId = ""; 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 ## volumemanager.format
...@@ -430,7 +446,11 @@ partition(volId: string, fstype: string): Promise&lt;void&gt; ...@@ -430,7 +446,11 @@ partition(volId: string, fstype: string): Promise&lt;void&gt;
```js ```js
let volId = ""; let volId = "";
let fstype = ""; 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 ## volumemanager.partition
...@@ -456,7 +476,7 @@ partition(volId: string, fstype : string, callback: AsyncCallback&lt;void&gt;): ...@@ -456,7 +476,7 @@ partition(volId: string, fstype : string, callback: AsyncCallback&lt;void&gt;):
```js ```js
let volId = ""; let volId = "";
let fstype = ""; let fstype = "";
volumemanager.format(volId, fstype, (error, bool) => { volumemanager.partition(volId, fstype, (error, bool) => {
// do something // do something
}); });
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册