• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (C) 2022 Huawei Device Co., Ltd.
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7*     http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15
16import { AsyncCallback } from "./basic";
17
18/**
19 * Provides securityLabel APIs
20 *
21 * @since 9
22 * @syscap  SystemCapability.FileManagement.File.FileIO
23 */
24
25declare namespace securityLabel {
26
27  type DataLevel = 's0'|'s1'|'s2'|'s3'|'s4';
28  /**
29   * Set the SecurityLabel.
30   *
31   * @since 9
32   * @syscap  SystemCapability.FileManagement.File.FileIO
33   * @param {string} path - path
34   * @param {AsyncCallback<void>} [callback] - callback
35   * @returns {void | Promise<void>} no callback return Promise otherwise return void
36   * @throws { BusinessError } 13900001  - Operation not permitted
37   * @throws { BusinessError } 13900007  - Arg list too long
38   * @throws { BusinessError } 13900015  - File exists
39   * @throws { BusinessError } 13900020  - Invalid argument
40   * @throws { BusinessError } 13900025  - No space left on device
41   * @throws { BusinessError } 13900037  - No data available
42   * @throws { BusinessError } 13900041  - Quota exceeded
43   * @throws { BusinessError } 13900042  - Unknown error
44   */
45  function setSecurityLabel(path: string, type: DataLevel): Promise<void>;
46  function setSecurityLabel(path: string, type: DataLevel, callback: AsyncCallback<void>): void;
47
48  /**
49   * Set the SecurityLabel with sync interface.
50   *
51   * @since 9
52   * @syscap  SystemCapability.FileManagement.File.FileIO
53   * @param {string} path - path
54   * @param {AsyncCallback<void>} [callback] - callback
55   * @returns {void | Promise<void>} no callback return Promise otherwise return void
56   * @throws { BusinessError } 13900001  - Operation not permitted
57   * @throws { BusinessError } 13900007  - Arg list too long
58   * @throws { BusinessError } 13900015  - File exists
59   * @throws { BusinessError } 13900020  - Invalid argument
60   * @throws { BusinessError } 13900025  - No space left on device
61   * @throws { BusinessError } 13900037  - No data available
62   * @throws { BusinessError } 13900041  - Quota exceeded
63   * @throws { BusinessError } 13900042  - Unknown error
64   */
65  function setSecurityLabelSync(path: string, type: DataLevel): void;
66
67    /**
68   * Get the SecurityLabel.
69   *
70   * @since 9
71   * @syscap  SystemCapability.FileManagement.File.FileIO
72   * @param {string} path - path
73   * @param {AsyncCallback<void>} [callback] - callback
74   * @returns {void | Promise<void>} no callback return Promise otherwise return void
75   * @throws { BusinessError } 13900001  - Operation not permitted
76   * @throws { BusinessError } 13900007  - Arg list too long
77   * @throws { BusinessError } 13900015  - File exists
78   * @throws { BusinessError } 13900020  - Invalid argument
79   * @throws { BusinessError } 13900025  - No space left on device
80   * @throws { BusinessError } 13900037  - No data available
81   * @throws { BusinessError } 13900041  - Quota exceeded
82   * @throws { BusinessError } 13900042  - Unknown error
83   */
84  function getSecurityLabel(path: string): Promise<string>;
85  function getSecurityLabel(path: string, callback: AsyncCallback<string>): void;
86
87  /**
88   * Get the SecurityLabel with sync interface.
89   *
90   * @since 9
91   * @syscap  SystemCapability.FileManagement.File.FileIO
92   * @param {string} path - path
93   * @param {AsyncCallback<void>} [callback] - callback
94   * @returns {void | Promise<void>} no callback return Promise otherwise return void
95   * @throws { BusinessError } 13900001  - Operation not permitted
96   * @throws { BusinessError } 13900007  - Arg list too long
97   * @throws { BusinessError } 13900015  - File exists
98   * @throws { BusinessError } 13900020  - Invalid argument
99   * @throws { BusinessError } 13900025  - No space left on device
100   * @throws { BusinessError } 13900037  - No data available
101   * @throws { BusinessError } 13900041  - Quota exceeded
102   * @throws { BusinessError } 13900042  - Unknown error
103   */
104   function getSecurityLabelSync(path: string): string;
105}
106
107export default securityLabel;