提交 5521fea9 编写于 作者: A annie_wangli

update docs

Signed-off-by: Nannie_wangli <annie.wangli@huawei.com>
上级 4662fd8a
# statfs # statfs
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**<br/>
> 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. > 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 ## Modules to Import
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
import statfs from '@ohos.statfs'; import statfs from '@ohos.statfs';
``` ```
## Note ## Guidelines
Before using this module to perform operations on a file or directory, obtain the absolute path of the file or directory. For details, see [getOrCreateLocalDir of the Context module](js-apis-Context.md). Before using this module to perform operations on a file or directory, obtain the absolute path of the file or directory. For details, see [getOrCreateLocalDir of the Context module](js-apis-Context.md).
...@@ -21,27 +21,25 @@ For example, if the application directory obtained by using **getOrCreateLocalDi ...@@ -21,27 +21,25 @@ For example, if the application directory obtained by using **getOrCreateLocalDi
let path = dir + "xxx.txt"; let path = dir + "xxx.txt";
``` ```
## System Capabilities
SystemCapability.FileManagement.File.FileIO
## statfs.getFreeBytes ## statfs.getFreeBytes
getFreeBytes(path:string):Promise&lt;number&gt; getFreeBytes(path:string):Promise&lt;number&gt;
Obtains the number of free bytes of the specified file system in asynchronous mode. This method uses a promise to return the result. Obtains the number of free bytes of the specified file system in asynchronous mode. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.FileManagement.File.FileIO
- **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------- | | ------ | ------ | ---- | ---------------------------- |
| path | string | Yes| File path of the file system.| | path | string | Yes | File path of the file system.|
- Return values - Return value
| Type| Description| | Type | Description |
| --------------------- | -------------- | | --------------------- | -------------- |
| Promise&lt;number&gt; | Number of free bytes obtained.| | Promise&lt;number&gt; | Promise used to return the number of free bytes obtained.|
- Example - Example
...@@ -60,38 +58,42 @@ getFreeBytes(path:string, callback:AsyncCallback&lt;number&gt;): void ...@@ -60,38 +58,42 @@ getFreeBytes(path:string, callback:AsyncCallback&lt;number&gt;): void
Obtains the number of free bytes of the specified file system in asynchronous mode. This method uses a callback to return the result. Obtains the number of free bytes of the specified file system in asynchronous mode. This method uses a callback to return the result.
- Parameters **System capability**: SystemCapability.FileManagement.File.FileIO
| Name| Type| Mandatory| Description| - **Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- | | -------- | --------------------------- | ---- | ---------------------------- |
| path | string | Yes| File path of the file system.| | path | string | Yes | File path of the file system.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the number of free bytes obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of free bytes obtained.|
- Example - Example
```js ```js
statfs.getFreeBytes(path, function(err, number){ statfs.getFreeBytes(path, function(err, number){
// Do something. //do something
}); });
``` ```
## statfs.getTotalBytes ## statfs.getTotalBytes
getTotalBytes.(path:string):Promise&lt;number&gt; getTotalBytes(path: string): Promise&lt;number&gt;
Obtains the total number of bytes of the specified file system in asynchronous mode. This method uses a promise to return the result. Obtains the total number of bytes of the specified file system in asynchronous mode. This method uses a promise to return the result.
- Parameters **System capability**: SystemCapability.FileManagement.File.FileIO
- **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ---------------------------- | | ---- | ------ | ---- | ---------------------------- |
| path | string | Yes| File path of the file system.| | path | string | Yes | File path of the file system.|
- Return values - Return value
| Type| Description| | Type | Description |
| --------------------- | ------------ | | --------------------- | ------------ |
| Promise&lt;number&gt; | Total number of bytes obtained.| | Promise&lt;number&gt; | Promise used to return the total number of bytes obtained.|
- Example - Example
...@@ -106,21 +108,23 @@ Obtains the total number of bytes of the specified file system in asynchronous m ...@@ -106,21 +108,23 @@ Obtains the total number of bytes of the specified file system in asynchronous m
## statfs.getTotalBytes ## statfs.getTotalBytes
getTotalBytes(path:string, callback:AsyncCallback&lt;number&gt;): void getTotalBytes(path: string, callback: AsyncCallback&lt;number&gt;): void
Obtains the total number of bytes of the specified file system in asynchronous mode. This method uses a callback to return the result. Obtains the total number of bytes of the specified file system in asynchronous mode. This method uses a callback to return the result.
- Parameters **System capability**: SystemCapability.FileManagement.File.FileIO
- **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- | | -------- | --------------------------- | ---- | ---------------------------- |
| path | string | Yes| File path of the file system.| | path | string | Yes | File path of the file system.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the total number of bytes obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total number of bytes obtained. |
- Example - Example
```js ```js
statfs.getTotalBytes(path, function(err, number){ statfs.getTotalBytes(path, function(err, number){
// Do something. //do something
}); });
``` ```
# Volume Management # Volume Management
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> >
> 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. > - 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.
> - This is a system API and cannot be called by third-party applications.
## Modules to Import ## Modules to Import
```js ```js
import volumemanager from "@ohos.volumemanager"; import volumemanager from "@ohos.volumeManager";
``` ```
## System Capabilities ## volumemanager.getAllVolumes<sup>9+</sup>
SystemCapability.FileManagement.StorageService.Volume getAllVolumes(): Promise&lt;Array&lt;Volume&gt;&gt;
## volumemanager.getAllVolumes
getAllVolumes(): Promise&lt;Volume[]&gt;
Asynchronously obtains information about all available volumes. This method uses a promise to return the result. Asynchronously obtains information about all available volumes. This method uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
- Return value - Return value
| Type| Description| | Type | Description |
| ---------------------------------- | -------------------------- | | ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)[]&gt; | Promise used to return the execution result.| | Promise&lt;[Volume](#volume)[]&gt; | Promise used to return the execution result.|
...@@ -34,17 +33,19 @@ Asynchronously obtains information about all available volumes. This method uses ...@@ -34,17 +33,19 @@ Asynchronously obtains information about all available volumes. This method uses
}); });
``` ```
## volumemanager.getAllVolumes ## volumemanager.getAllVolumes<sup>9+</sup>
getAllVolumes(callback:AsyncCallback&lt;Volume[]&gt;):void getAllVolumes(callback: AsyncCallback&lt;Array&lt;Volume&gt;&gt;): void
Asynchronously obtains information about all available volumes. This method uses a callback to return the result. Asynchronously obtains information about all available volumes. This method uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------------------------ | | -------- | ------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback:AsyncCallback&lt;[Volume](#volume)[]&gt; | Yes| Callback invoked to return the volume information obtained.| | callback | callback:AsyncCallback&lt;[Volume](#volume)[]&gt; | Yes | Callback invoked to return the volume information obtained.|
- Example - Example
...@@ -56,21 +57,23 @@ Asynchronously obtains information about all available volumes. This method uses ...@@ -56,21 +57,23 @@ Asynchronously obtains information about all available volumes. This method uses
``` ```
## volumemanager.mount ## volumemanager.mount<sup>9+</sup>
mount(volumeId: string): Promise&lt;boolean&gt; mount(volumeId: string): Promise&lt;boolean&gt;
Asynchronously mounts a volume. This method uses a promise to return the result. Asynchronously mounts a volume. This method uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| volumeId | string | Yes| Volume ID.| | volumeId | string | Yes | Volume ID.|
- Return value - Return value
| Type| Description| | Type | Description |
| ---------------------- | ---------- | | ---------------------- | ---------- |
| Promise&lt;boolean&gt; | Promise used to return the execution result.| | Promise&lt;boolean&gt; | Promise used to return the execution result.|
...@@ -83,18 +86,20 @@ Asynchronously mounts a volume. This method uses a promise to return the result. ...@@ -83,18 +86,20 @@ Asynchronously mounts a volume. This method uses a promise to return the result.
}); });
``` ```
## volumemanager.mount ## volumemanager.mount<sup>9+</sup>
mount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void mount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
Asynchronously mounts a volume. This method uses a callback to return the result. Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- | | -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | Yes| Volume ID.| | volumeId | string | Yes | Volume ID. |
| callback | callback:AsyncCallback&lt;boolean&gt; | Yes| Callback invoked to return the execution result.| | callback | callback:AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the execution result.|
- Example - Example
...@@ -105,21 +110,23 @@ Asynchronously mounts a volume. This method uses a callback to return the result ...@@ -105,21 +110,23 @@ Asynchronously mounts a volume. This method uses a callback to return the result
}); });
``` ```
## volumemanager.unmount ## volumemanager.unmount<sup>9+</sup>
unmount(volumeId: string): Promise&lt;boolean&gt; unmount(volumeId: string): Promise&lt;boolean&gt;
Asynchronously unmounts a volume. This method uses a promise to return the result. Asynchronously unmounts a volume. This method uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| volumeId | string | Yes| Volume ID.| | volumeId | string | Yes | Volume ID.|
- Return value - Return value
| Type| Description| | Type | Description |
| ---------------------- | ---------- | | ---------------------- | ---------- |
| Promise&lt;boolean&gt; | Promise used to return the execution result.| | Promise&lt;boolean&gt; | Promise used to return the execution result.|
...@@ -132,18 +139,20 @@ Asynchronously unmounts a volume. This method uses a promise to return the resul ...@@ -132,18 +139,20 @@ Asynchronously unmounts a volume. This method uses a promise to return the resul
}); });
``` ```
## volumemanager.unmount ## volumemanager.unmount<sup>9+</sup>
unmount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void unmount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
Asynchronously unmounts a volume. This method uses a callback to return the result. Asynchronously unmounts a volume. This method uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- | | -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | Yes| Volume ID.| | volumeId | string | Yes | Volume ID. |
| callback | callback:AsyncCallback&lt;boolean&gt; | Yes| Callback invoked to return the execution result.| | callback | callback:AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the execution result.|
- Example - Example
...@@ -154,15 +163,17 @@ Asynchronously unmounts a volume. This method uses a callback to return the resu ...@@ -154,15 +163,17 @@ Asynchronously unmounts a volume. This method uses a callback to return the resu
}); });
``` ```
## Volume ## Volume<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.Volume
### Attributes ### Attributes
| Name| Type| Description| | Name | Type | Description |
| ----------- | ------- | -------------------- | | ----------- | ------- | -------------------- |
| id | number | Volume ID.| | id<sup>9+</sup> | number | Volume ID. |
| uuid | string | Universally unique identifier (UUID) of the volume.| | uuid<sup>9+</sup> | string | Universally unique identifier (UUID) of the volume. |
| description | string | Description of the volume.| | description<sup>9+</sup> | string | Description of the volume. |
| removeAble | boolean | Whether the volume is a removable storage device.| | removable<sup>9+</sup> | boolean | Whether the volume is a removable storage device.|
| state | int | Current volume status.| | state<sup>9+</sup> | int | Current volume status. |
| path | string | Mount address of the volume.| | path<sup>9+</sup> | string | Mount address of the volume. |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册