From b6f53667952ed0d233c6e2b17343e3d30357f028 Mon Sep 17 00:00:00 2001 From: annie_wangli Date: Fri, 11 Feb 2022 14:10:09 +0800 Subject: [PATCH 1/2] update docs Signed-off-by: annie_wangli --- .../reference/apis/js-apis-statfs.md | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 en/application-dev/reference/apis/js-apis-statfs.md diff --git a/en/application-dev/reference/apis/js-apis-statfs.md b/en/application-dev/reference/apis/js-apis-statfs.md new file mode 100644 index 00000000000..c35b68d23a9 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-statfs.md @@ -0,0 +1,115 @@ +# statfs + + + +## Modules to Import + +``` +import statfs from '@ohos.statfs' +``` + +## Note + +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). + +Absolute file or directory path = Application directory + File name or directory name + +For example, if the application directory obtained by using **getOrCreateLocalDir** is **dir** and the file name is **xxx.txt**, the absolute path of the file is as follows: + +``` +let path = dir + "xxx.txt" +``` + +## Required Permissions + +None + +## statfs.getFreeBytes + +getFreeBytes(path:string):Promise<number> + +Obtains the number of free bytes of the specified file system in asynchronous mode. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ------ | ------ | ---- | ---------------------------- | + | path | string | Yes| File path of the file system.| + +- Return values + + | Type| Description| + | --------------------- | -------------- | + | Promise<number> | Number of free bytes obtained.| + +- Example + + ``` + let num = await statfs.getFreeBytes(path); + ``` + +## statfs.getFreeBytes + +getFreeBytes(path:string, callback:AsyncCallback<number>): void + +Obtains the number of free bytes of the specified file system in asynchronous mode. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | --------------------------- | ---- | ---------------------------- | + | path | string | Yes| File path of the file system.| + | callback | AsyncCallback<number> | Yes| Callback invoked to return the number of free bytes obtained.| + +- Example + + ``` + statfs.getFreeBytes(path, function(err, number){ + //do something + }); + ``` + +## statfs.getTotalBytes + +getTotalBytes.(path:string):Promise<number> + +Obtains the total number of bytes of the specified file system in asynchronous mode. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---- | ------ | ---- | ---------------------------- | + | path | string | Yes| File path of the file system.| + +- Return values + + | Type| Description| + | --------------------- | ------------ | + | Promise<number> | Total number of bytes obtained.| + +- Example + + ``` + let num = await statfs.getTotalBytes(path); + ``` + +## statfs.getTotalBytes + +getTotalBytes(path:string, callback:AsyncCallback<number>): void + +Obtains the total number of bytes of the specified file system in asynchronous mode. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | --------------------------- | ---- | ---------------------------- | + | path | string | Yes| File path of the file system.| + | callback | AsyncCallback<number> | Yes| Callback invoked to return the total number of bytes obtained.| + +- Example + + ``` + statfs.getTotalBytes(path, function(err, number){ + //do something + }); + ``` -- Gitee From d917075fc7c36128c05dd24a89f19ebb05f359c5 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Fri, 11 Feb 2022 09:55:30 +0000 Subject: [PATCH 2/2] update en/application-dev/reference/apis/js-apis-statfs.md. Signed-off-by: Annie_wang --- en/application-dev/reference/apis/js-apis-statfs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-statfs.md b/en/application-dev/reference/apis/js-apis-statfs.md index c35b68d23a9..9e72201f750 100644 --- a/en/application-dev/reference/apis/js-apis-statfs.md +++ b/en/application-dev/reference/apis/js-apis-statfs.md @@ -65,7 +65,7 @@ Obtains the number of free bytes of the specified file system in asynchronous mo ``` statfs.getFreeBytes(path, function(err, number){ - //do something + // Do something. }); ``` @@ -110,6 +110,6 @@ Obtains the total number of bytes of the specified file system in asynchronous m ``` statfs.getTotalBytes(path, function(err, number){ - //do something + // Do something. }); ``` -- Gitee