From 14a2b2181cd1a54789a4b36dc232c0fa28c0fd55 Mon Sep 17 00:00:00 2001 From: raoxian Date: Wed, 16 Feb 2022 14:57:59 +0800 Subject: [PATCH 1/2] add js-apis-securitylabel.md Signed-off-by: raoxian --- .../reference/apis/Readme-CN.md | 1 + .../reference/apis/js-apis-securitylabel.md | 134 ++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 zh-cn/application-dev/reference/apis/js-apis-securitylabel.md diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 517a47807a3..edb1904c9e4 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -35,6 +35,7 @@ - [公共文件访问与管理](js-apis-filemanager.md) - [应用空间统计](js-apis-storage-statistics.md) - [卷管理](js-apis-volumemanager.md) + - [数据标签](js-apis-securitylabel.md) - 账号管理 - [分布式帐号管理](js-apis-distributed-account.md) - [应用帐号管理](js-apis-appAccount.md) 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 00000000000..06bcc0ca9bd --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-securitylabel.md @@ -0,0 +1,134 @@ +# 数据标签 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import securitylabel from '@ohos.securitylabel'; +``` + +## 使用说明 + +使用该功能模块对文件/目录进行操作前,需要先获取其绝对路径,获取方式及其接口用法请参考:[Context模块的接口getOrCreateLocalDir](js-apis-Context.md)。 + +“文件/目录绝对路径”=“应用目录路径”+“文件/目录名” + +通过上述接口获取到应用目录路径dir,文件名为“xxx.txt”,文件所在绝对路径为: + +```js +let path = dir + "/xxx.txt"; +``` + +文件描述符fd: + +```js +let fd = fileio.openSync(path, 0o102, 0o666); +``` + +## 系统能力 + +SystemCapability.FileManagement.File.DistributedFile + +## securitylabel.setSecurityLabel + +setSecurityLabel(path:string, dataLevel:string):Promise<void> + +异步方法判断是否设置数据标签,以promise形式返回结果。 + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------ | ---- | ------------ | + | path | string | 是 | 文件路径 | + | dataLevel | string | 是 | 文件等级属性 | + +- 返回值: + + | 类型 | 说明 | + | ------------------- | ---------------- | + | Promise<void> | 是否设置数据标签 | + +- 示例: + + ```js + 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形式返回结果。 + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------------------------- | ---- | -------------------------- | + | path | string | 是 | 文件路径 | + | dataLevel | string | 是 | 文件等级属性 | + | callback | AsyncCallback<void> | 是 | 是否设置数据标签之后的回调 | + +- 示例: + + ```js + securitylabel.setSecurityLabel(path, dataLevel, function(error){ + console.info("setSecurityLabel:" + JSON.stringify(error)); + // do something + }); + ``` + +## securitylabel.getSecurityLabel + +getSecurityLabel(path:string):Promise<string> + +异步方法获取数据标签,以promise形式返回结果。 + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------- | + | path | string | 是 | 文件路径 | + +- 返回值: + + | 类型 | 说明 | + | --------------------- | ------------ | + | Promise<string> | 返回数据标签 | + +- 示例: + + ```js + securitylabel.getSecurityLabel(path).then(function(dataLevel){ + console.info("getSecurityLabel successfully:" + dataLevel); + }).catch(function(error){ + console.info("getSecurityLabel failed with error:" + error); + }); + ``` + +## securitylabel.getSecurityLabel + +getSecurityLabel(path:string, callback:AsyncCallback<string>): void + +异步方法获取数据标签,以callback形式返回结果。 + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------- | ---- | -------------------------- | + | path | string | 是 | 文件路径 | + | callback | AsyncCallback<string> | 是 | 异步获取数据标签之后的回调 | + +- 示例: + + ```js + securitylabel.getSecurityLabel(function(error, dataLevel){ + // do something + }); + ``` + -- Gitee From 35bbcedb425ec419cdbd5a44b3333ac2f124acf6 Mon Sep 17 00:00:00 2001 From: raoxian Date: Thu, 17 Feb 2022 14:58:00 +0800 Subject: [PATCH 2/2] update js-apis-securitylabel.md Signed-off-by: raoxian --- .../reference/apis/js-apis-securitylabel.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-securitylabel.md b/zh-cn/application-dev/reference/apis/js-apis-securitylabel.md index 06bcc0ca9bd..070d4ecda30 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-securitylabel.md +++ b/zh-cn/application-dev/reference/apis/js-apis-securitylabel.md @@ -6,7 +6,7 @@ ## 导入模块 ```js -import securitylabel from '@ohos.securitylabel'; +import remoteFileShare from '@ohos.securitylabel'; ``` ## 使用说明 @@ -31,7 +31,7 @@ let fd = fileio.openSync(path, 0o102, 0o666); SystemCapability.FileManagement.File.DistributedFile -## securitylabel.setSecurityLabel +## remoteFileShare.setSecurityLabel setSecurityLabel(path:string, dataLevel:string):Promise<void> @@ -53,14 +53,14 @@ setSecurityLabel(path:string, dataLevel:string):Promise<void> - 示例: ```js - securitylabel.setSecurityLabel(path, dataLevel).then(function(){ + remoteFileShare.setSecurityLabel(path, dataLevel).then(function(){ console.info("setSecurityLabel successfully"); }).catch(function(error){ console.info("setSecurityLabel failed with error:" + error); }); ``` -## securitylabel.setSecurityLabel +## remoteFileShare.setSecurityLabel setSecurityLabel(path:string, dataLevel:string, callback: AsyncCallback<void>):void @@ -77,13 +77,13 @@ setSecurityLabel(path:string, dataLevel:string, callback: AsyncCallback<void& - 示例: ```js - securitylabel.setSecurityLabel(path, dataLevel, function(error){ + remoteFileShare.setSecurityLabel(path, dataLevel, function(error){ console.info("setSecurityLabel:" + JSON.stringify(error)); // do something }); ``` -## securitylabel.getSecurityLabel +## remoteFileShare.getSecurityLabel getSecurityLabel(path:string):Promise<string> @@ -104,14 +104,14 @@ getSecurityLabel(path:string):Promise<string> - 示例: ```js - securitylabel.getSecurityLabel(path).then(function(dataLevel){ + remoteFileShare.getSecurityLabel(path).then(function(dataLevel){ console.info("getSecurityLabel successfully:" + dataLevel); }).catch(function(error){ console.info("getSecurityLabel failed with error:" + error); }); ``` -## securitylabel.getSecurityLabel +## remoteFileShare.getSecurityLabel getSecurityLabel(path:string, callback:AsyncCallback<string>): void @@ -127,7 +127,7 @@ getSecurityLabel(path:string, callback:AsyncCallback<string>): void - 示例: ```js - securitylabel.getSecurityLabel(function(error, dataLevel){ + remoteFileShare.getSecurityLabel(function(error, dataLevel){ // do something }); ``` -- Gitee