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