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