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 filesystem statistics APIs 25 * 26 * @namespace statfs 27 * @syscap SystemCapability.FileManagement.File.FileIO 28 * @since 9 29 */ 30/** 31 * Provides filesystem statistics APIs 32 * 33 * @namespace statfs 34 * @syscap SystemCapability.FileManagement.File.FileIO 35 * @crossplatform 36 * @since 20 37 * @arkts 1.1&1.2 38 */ 39declare namespace statfs { 40 /** 41 * Get the number of free bytes on the specified path. 42 * 43 * @param { string } path - path 44 * @returns { Promise<number> } return Promise 45 * @throws { BusinessError } 13900002 - No such file or directory 46 * @throws { BusinessError } 13900004 - Interrupted system call 47 * @throws { BusinessError } 13900005 - I/O error 48 * @throws { BusinessError } 13900008 - Bad file descriptor 49 * @throws { BusinessError } 13900011 - Out of memory 50 * @throws { BusinessError } 13900012 - Permission denied 51 * @throws { BusinessError } 13900013 - Bad address 52 * @throws { BusinessError } 13900018 - Not a directory 53 * @throws { BusinessError } 13900030 - File name too long 54 * @throws { BusinessError } 13900031 - Function not implemented 55 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 56 * @throws { BusinessError } 13900038 - Value too large for defined data type 57 * @throws { BusinessError } 13900042 - Unknown error 58 * @syscap SystemCapability.FileManagement.File.FileIO 59 * @since 9 60 */ 61 /** 62 * Get the number of free bytes on the specified path. 63 * 64 * @param { string } path - path 65 * @returns { Promise<number> } return Promise 66 * @throws { BusinessError } 13900002 - No such file or directory 67 * @throws { BusinessError } 13900004 - Interrupted system call 68 * @throws { BusinessError } 13900005 - I/O error 69 * @throws { BusinessError } 13900008 - Bad file descriptor 70 * @throws { BusinessError } 13900011 - Out of memory 71 * @throws { BusinessError } 13900012 - Permission denied 72 * @throws { BusinessError } 13900013 - Bad address 73 * @throws { BusinessError } 13900018 - Not a directory 74 * @throws { BusinessError } 13900030 - File name too long 75 * @throws { BusinessError } 13900031 - Function not implemented 76 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 77 * @throws { BusinessError } 13900038 - Value too large for defined data type 78 * @throws { BusinessError } 13900042 - Unknown error 79 * @syscap SystemCapability.FileManagement.File.FileIO 80 * @crossplatform 81 * @since 20 82 * @arkts 1.1&1.2 83 */ 84 function getFreeSize(path: string): Promise<number>; 85 86 /** 87 * Get the number of free bytes on the specified path. 88 * 89 * @param { string } path - path 90 * @param { AsyncCallback<number> } [callback] - callback 91 * @throws { BusinessError } 13900002 - No such file or directory 92 * @throws { BusinessError } 13900004 - Interrupted system call 93 * @throws { BusinessError } 13900005 - I/O error 94 * @throws { BusinessError } 13900008 - Bad file descriptor 95 * @throws { BusinessError } 13900011 - Out of memory 96 * @throws { BusinessError } 13900012 - Permission denied 97 * @throws { BusinessError } 13900013 - Bad address 98 * @throws { BusinessError } 13900018 - Not a directory 99 * @throws { BusinessError } 13900030 - File name too long 100 * @throws { BusinessError } 13900031 - Function not implemented 101 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 102 * @throws { BusinessError } 13900038 - Value too large for defined data type 103 * @throws { BusinessError } 13900042 - Unknown error 104 * @syscap SystemCapability.FileManagement.File.FileIO 105 * @since 9 106 */ 107 /** 108 * Get the number of free bytes on the specified path. 109 * 110 * @param { string } path - path 111 * @param { AsyncCallback<number> } [callback] - callback 112 * @throws { BusinessError } 13900002 - No such file or directory 113 * @throws { BusinessError } 13900004 - Interrupted system call 114 * @throws { BusinessError } 13900005 - I/O error 115 * @throws { BusinessError } 13900008 - Bad file descriptor 116 * @throws { BusinessError } 13900011 - Out of memory 117 * @throws { BusinessError } 13900012 - Permission denied 118 * @throws { BusinessError } 13900013 - Bad address 119 * @throws { BusinessError } 13900018 - Not a directory 120 * @throws { BusinessError } 13900030 - File name too long 121 * @throws { BusinessError } 13900031 - Function not implemented 122 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 123 * @throws { BusinessError } 13900038 - Value too large for defined data type 124 * @throws { BusinessError } 13900042 - Unknown error 125 * @syscap SystemCapability.FileManagement.File.FileIO 126 * @crossplatform 127 * @since 20 128 * @arkts 1.1&1.2 129 */ 130 function getFreeSize(path: string, callback: AsyncCallback<number>): void; 131 132 /** 133 * Get the number of free bytes on the specified path with sync interface. 134 * 135 * @param { string } path - path 136 * @returns { number } return the number of free bytes on the specified path 137 * @throws { BusinessError } 13900002 - No such file or directory 138 * @throws { BusinessError } 13900004 - Interrupted system call 139 * @throws { BusinessError } 13900005 - I/O error 140 * @throws { BusinessError } 13900008 - Bad file descriptor 141 * @throws { BusinessError } 13900011 - Out of memory 142 * @throws { BusinessError } 13900012 - Permission denied 143 * @throws { BusinessError } 13900013 - Bad address 144 * @throws { BusinessError } 13900018 - Not a directory 145 * @throws { BusinessError } 13900030 - File name too long 146 * @throws { BusinessError } 13900031 - Function not implemented 147 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 148 * @throws { BusinessError } 13900038 - Value too large for defined data type 149 * @throws { BusinessError } 13900042 - Unknown error 150 * @syscap SystemCapability.FileManagement.File.FileIO 151 * @since 10 152 */ 153 /** 154 * Get the number of free bytes on the specified path with sync interface. 155 * 156 * @param { string } path - path 157 * @returns { number } return the number of free bytes on the specified path 158 * @throws { BusinessError } 13900002 - No such file or directory 159 * @throws { BusinessError } 13900004 - Interrupted system call 160 * @throws { BusinessError } 13900005 - I/O error 161 * @throws { BusinessError } 13900008 - Bad file descriptor 162 * @throws { BusinessError } 13900011 - Out of memory 163 * @throws { BusinessError } 13900012 - Permission denied 164 * @throws { BusinessError } 13900013 - Bad address 165 * @throws { BusinessError } 13900018 - Not a directory 166 * @throws { BusinessError } 13900030 - File name too long 167 * @throws { BusinessError } 13900031 - Function not implemented 168 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 169 * @throws { BusinessError } 13900038 - Value too large for defined data type 170 * @throws { BusinessError } 13900042 - Unknown error 171 * @syscap SystemCapability.FileManagement.File.FileIO 172 * @crossplatform 173 * @since 20 174 * @arkts 1.1&1.2 175 */ 176 function getFreeSizeSync(path: string): number; 177 178 /** 179 * Get the number of total bytes on the specified path. 180 * 181 * @param { string } path - path 182 * @returns { Promise<number> } return Promise 183 * @throws { BusinessError } 13900002 - No such file or directory 184 * @throws { BusinessError } 13900004 - Interrupted system call 185 * @throws { BusinessError } 13900005 - I/O error 186 * @throws { BusinessError } 13900008 - Bad file descriptor 187 * @throws { BusinessError } 13900011 - Out of memory 188 * @throws { BusinessError } 13900012 - Permission denied 189 * @throws { BusinessError } 13900013 - Bad address 190 * @throws { BusinessError } 13900018 - Not a directory 191 * @throws { BusinessError } 13900030 - File name too long 192 * @throws { BusinessError } 13900031 - Function not implemented 193 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 194 * @throws { BusinessError } 13900038 - Value too large for defined data type 195 * @throws { BusinessError } 13900042 - Unknown error 196 * @syscap SystemCapability.FileManagement.File.FileIO 197 * @since 9 198 */ 199 /** 200 * Get the number of total bytes on the specified path. 201 * 202 * @param { string } path - path 203 * @returns { Promise<number> } return Promise 204 * @throws { BusinessError } 13900002 - No such file or directory 205 * @throws { BusinessError } 13900004 - Interrupted system call 206 * @throws { BusinessError } 13900005 - I/O error 207 * @throws { BusinessError } 13900008 - Bad file descriptor 208 * @throws { BusinessError } 13900011 - Out of memory 209 * @throws { BusinessError } 13900012 - Permission denied 210 * @throws { BusinessError } 13900013 - Bad address 211 * @throws { BusinessError } 13900018 - Not a directory 212 * @throws { BusinessError } 13900030 - File name too long 213 * @throws { BusinessError } 13900031 - Function not implemented 214 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 215 * @throws { BusinessError } 13900038 - Value too large for defined data type 216 * @throws { BusinessError } 13900042 - Unknown error 217 * @syscap SystemCapability.FileManagement.File.FileIO 218 * @crossplatform 219 * @since 20 220 * @arkts 1.1&1.2 221 */ 222 function getTotalSize(path: string): Promise<number>; 223 224 /** 225 * Get the number of total bytes on the specified path. 226 * 227 * @param { string } path - path 228 * @param { AsyncCallback<number> } [callback] - callback 229 * @throws { BusinessError } 13900002 - No such file or directory 230 * @throws { BusinessError } 13900004 - Interrupted system call 231 * @throws { BusinessError } 13900005 - I/O error 232 * @throws { BusinessError } 13900008 - Bad file descriptor 233 * @throws { BusinessError } 13900011 - Out of memory 234 * @throws { BusinessError } 13900012 - Permission denied 235 * @throws { BusinessError } 13900013 - Bad address 236 * @throws { BusinessError } 13900018 - Not a directory 237 * @throws { BusinessError } 13900030 - File name too long 238 * @throws { BusinessError } 13900031 - Function not implemented 239 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 240 * @throws { BusinessError } 13900038 - Value too large for defined data type 241 * @throws { BusinessError } 13900042 - Unknown error 242 * @syscap SystemCapability.FileManagement.File.FileIO 243 * @since 9 244 */ 245 /** 246 * Get the number of total bytes on the specified path. 247 * 248 * @param { string } path - path 249 * @param { AsyncCallback<number> } [callback] - callback 250 * @throws { BusinessError } 13900002 - No such file or directory 251 * @throws { BusinessError } 13900004 - Interrupted system call 252 * @throws { BusinessError } 13900005 - I/O error 253 * @throws { BusinessError } 13900008 - Bad file descriptor 254 * @throws { BusinessError } 13900011 - Out of memory 255 * @throws { BusinessError } 13900012 - Permission denied 256 * @throws { BusinessError } 13900013 - Bad address 257 * @throws { BusinessError } 13900018 - Not a directory 258 * @throws { BusinessError } 13900030 - File name too long 259 * @throws { BusinessError } 13900031 - Function not implemented 260 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 261 * @throws { BusinessError } 13900038 - Value too large for defined data type 262 * @throws { BusinessError } 13900042 - Unknown error 263 * @syscap SystemCapability.FileManagement.File.FileIO 264 * @crossplatform 265 * @since 20 266 * @arkts 1.1&1.2 267 */ 268 function getTotalSize(path: string, callback: AsyncCallback<number>): void; 269 270 /** 271 * Get the number of total bytes on the specified path with sync interface. 272 * 273 * @param { string } path - path 274 * @returns { number } return the number of total bytes 275 * @throws { BusinessError } 13900002 - No such file or directory 276 * @throws { BusinessError } 13900004 - Interrupted system call 277 * @throws { BusinessError } 13900005 - I/O error 278 * @throws { BusinessError } 13900008 - Bad file descriptor 279 * @throws { BusinessError } 13900011 - Out of memory 280 * @throws { BusinessError } 13900012 - Permission denied 281 * @throws { BusinessError } 13900013 - Bad address 282 * @throws { BusinessError } 13900018 - Not a directory 283 * @throws { BusinessError } 13900030 - File name too long 284 * @throws { BusinessError } 13900031 - Function not implemented 285 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 286 * @throws { BusinessError } 13900038 - Value too large for defined data type 287 * @throws { BusinessError } 13900042 - Unknown error 288 * @syscap SystemCapability.FileManagement.File.FileIO 289 * @since 10 290 */ 291 /** 292 * Get the number of total bytes on the specified path with sync interface. 293 * 294 * @param { string } path - path 295 * @returns { number } return the number of total bytes 296 * @throws { BusinessError } 13900002 - No such file or directory 297 * @throws { BusinessError } 13900004 - Interrupted system call 298 * @throws { BusinessError } 13900005 - I/O error 299 * @throws { BusinessError } 13900008 - Bad file descriptor 300 * @throws { BusinessError } 13900011 - Out of memory 301 * @throws { BusinessError } 13900012 - Permission denied 302 * @throws { BusinessError } 13900013 - Bad address 303 * @throws { BusinessError } 13900018 - Not a directory 304 * @throws { BusinessError } 13900030 - File name too long 305 * @throws { BusinessError } 13900031 - Function not implemented 306 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 307 * @throws { BusinessError } 13900038 - Value too large for defined data type 308 * @throws { BusinessError } 13900042 - Unknown error 309 * @syscap SystemCapability.FileManagement.File.FileIO 310 * @crossplatform 311 * @since 20 312 * @arkts 1.1&1.2 313 */ 314 function getTotalSizeSync(path: string): number; 315} 316 317export default statfs; 318