• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022-2023 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 type { AsyncCallback } from './@ohos.base';
17
18/**
19 * Provides securityLabel APIs
20 *
21 * @namespace securityLabel
22 * @syscap SystemCapability.FileManagement.File.FileIO
23 * @since 9
24 */
25declare namespace securityLabel {
26  type DataLevel = 's0' | 's1' | 's2' | 's3' | 's4';
27  /**
28   * Set the SecurityLabel.
29   *
30   * @param { string } path - path
31   * @param { DataLevel } type - type
32   * @returns { Promise<void> } return Promise
33   * @throws { BusinessError } 13900001 - Operation not permitted
34   * @throws { BusinessError } 13900007 - Arg list too long
35   * @throws { BusinessError } 13900015 - File exists
36   * @throws { BusinessError } 13900020 - Invalid argument
37   * @throws { BusinessError } 13900025 - No space left on device
38   * @throws { BusinessError } 13900037 - No data available
39   * @throws { BusinessError } 13900041 - Quota exceeded
40   * @throws { BusinessError } 13900042 - Unknown error
41   * @syscap SystemCapability.FileManagement.File.FileIO
42   * @since 9
43   */
44  function setSecurityLabel(path: string, type: DataLevel): Promise<void>;
45
46  /**
47   * Set the SecurityLabel.
48   *
49   * @param { string } path - path
50   * @param { DataLevel } type - type
51   * @param { AsyncCallback<void> } [callback] - callback
52   * @throws { BusinessError } 13900001 - Operation not permitted
53   * @throws { BusinessError } 13900007 - Arg list too long
54   * @throws { BusinessError } 13900015 - File exists
55   * @throws { BusinessError } 13900020 - Invalid argument
56   * @throws { BusinessError } 13900025 - No space left on device
57   * @throws { BusinessError } 13900037 - No data available
58   * @throws { BusinessError } 13900041 - Quota exceeded
59   * @throws { BusinessError } 13900042 - Unknown error
60   * @syscap SystemCapability.FileManagement.File.FileIO
61   * @since 9
62   */
63  function setSecurityLabel(path: string, type: DataLevel, callback: AsyncCallback<void>): void;
64
65  /**
66   * Set the SecurityLabel with sync interface.
67   *
68   * @param { string } path - path
69   * @param { DataLevel } type - type
70   * @throws { BusinessError } 13900001 - Operation not permitted
71   * @throws { BusinessError } 13900007 - Arg list too long
72   * @throws { BusinessError } 13900015 - File exists
73   * @throws { BusinessError } 13900020 - Invalid argument
74   * @throws { BusinessError } 13900025 - No space left on device
75   * @throws { BusinessError } 13900037 - No data available
76   * @throws { BusinessError } 13900041 - Quota exceeded
77   * @throws { BusinessError } 13900042 - Unknown error
78   * @syscap SystemCapability.FileManagement.File.FileIO
79   * @since 9
80   */
81  function setSecurityLabelSync(path: string, type: DataLevel): void;
82
83  /**
84   * Get the SecurityLabel.
85   *
86   * @param { string } path - path
87   * @returns { Promise<string> } return Promise
88   * @throws { BusinessError } 13900001 - Operation not permitted
89   * @throws { BusinessError } 13900007 - Arg list too long
90   * @throws { BusinessError } 13900015 - File exists
91   * @throws { BusinessError } 13900020 - Invalid argument
92   * @throws { BusinessError } 13900025 - No space left on device
93   * @throws { BusinessError } 13900037 - No data available
94   * @throws { BusinessError } 13900041 - Quota exceeded
95   * @throws { BusinessError } 13900042 - Unknown error
96   * @syscap SystemCapability.FileManagement.File.FileIO
97   * @since 9
98   */
99  function getSecurityLabel(path: string): Promise<string>;
100
101  /**
102   * Get the SecurityLabel.
103   *
104   * @param { string } path - path
105   * @param { AsyncCallback<string> } [callback] - callback
106   * @throws { BusinessError } 13900001 - Operation not permitted
107   * @throws { BusinessError } 13900007 - Arg list too long
108   * @throws { BusinessError } 13900015 - File exists
109   * @throws { BusinessError } 13900020 - Invalid argument
110   * @throws { BusinessError } 13900025 - No space left on device
111   * @throws { BusinessError } 13900037 - No data available
112   * @throws { BusinessError } 13900041 - Quota exceeded
113   * @throws { BusinessError } 13900042 - Unknown error
114   * @syscap SystemCapability.FileManagement.File.FileIO
115   * @since 9
116   */
117  function getSecurityLabel(path: string, callback: AsyncCallback<string>): void;
118
119  /**
120   * Get the SecurityLabel with sync interface.
121   *
122   * @param { string } path - path
123   * @returns { string } security label name
124   * @throws { BusinessError } 13900001 - Operation not permitted
125   * @throws { BusinessError } 13900007 - Arg list too long
126   * @throws { BusinessError } 13900015 - File exists
127   * @throws { BusinessError } 13900020 - Invalid argument
128   * @throws { BusinessError } 13900025 - No space left on device
129   * @throws { BusinessError } 13900037 - No data available
130   * @throws { BusinessError } 13900041 - Quota exceeded
131   * @throws { BusinessError } 13900042 - Unknown error
132   * @syscap SystemCapability.FileManagement.File.FileIO
133   * @since 9
134   */
135  function getSecurityLabelSync(path: string): string;
136}
137
138export default securityLabel;
139