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, Callback } from './@ohos.base'; 17import Want from './@ohos.app.ability.Want'; 18import Context from './application/Context'; 19import { Filter } from './@ohos.file.fs'; 20 21/** 22 * This module provides the capability to access user public files. 23 * 24 * @namespace fileAccess 25 * @syscap SystemCapability.FileManagement.UserFileService 26 * @since 9 27 */ 28declare namespace fileAccess { 29 /** 30 * Query the want information of HAP configured with fileaccess. 31 * 32 * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 33 * @param { AsyncCallback<Array<Want>> } callback - The callback is used to return a Array<Want> object. 34 * @throws { BusinessError } 13900001 - Operation not permitted 35 * @throws { BusinessError } 13900002 - No such file or directory 36 * @throws { BusinessError } 13900004 - Interrupted system call 37 * @throws { BusinessError } 13900006 - No such device or address 38 * @throws { BusinessError } 13900008 - Bad file descriptor 39 * @throws { BusinessError } 13900011 - Out of memory 40 * @throws { BusinessError } 13900012 - Permission denied 41 * @throws { BusinessError } 13900013 - Bad address 42 * @throws { BusinessError } 13900014 - Device or resource busy 43 * @throws { BusinessError } 13900015 - File exists 44 * @throws { BusinessError } 13900017 - No such device 45 * @throws { BusinessError } 13900018 - Not a directory 46 * @throws { BusinessError } 13900019 - Is a directory 47 * @throws { BusinessError } 13900020 - Invalid argument 48 * @throws { BusinessError } 13900022 - Too many open files 49 * @throws { BusinessError } 13900023 - Text file busy 50 * @throws { BusinessError } 13900024 - File too large 51 * @throws { BusinessError } 13900025 - No space left on device 52 * @throws { BusinessError } 13900027 - Read-only file system 53 * @throws { BusinessError } 13900029 - Resource deadlock would occur 54 * @throws { BusinessError } 13900030 - File name too long 55 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 56 * @throws { BusinessError } 13900034 - Operation would block 57 * @throws { BusinessError } 13900038 - Value too large for defined data type 58 * @throws { BusinessError } 13900041 - Quota exceeded 59 * @throws { BusinessError } 13900042 - Unknown error 60 * @throws { BusinessError } 14300001 - IPC error 61 * @throws { BusinessError } 14300002 - Invalid uri 62 * @throws { BusinessError } 14300003 - Fail to get fileextension info 63 * @throws { BusinessError } 14300004 - Get wrong result 64 * @syscap SystemCapability.FileManagement.UserFileService 65 * @systemapi 66 * @StageModelOnly 67 * @since 9 68 */ 69 function getFileAccessAbilityInfo(callback: AsyncCallback<Array<Want>>): void; 70 71 /** 72 * Query the want information of HAP configured with fileaccess. 73 * 74 * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 75 * @returns { Promise<Array<Want>> } Returns the wants. 76 * @throws { BusinessError } 13900001 - Operation not permitted 77 * @throws { BusinessError } 13900002 - No such file or directory 78 * @throws { BusinessError } 13900004 - Interrupted system call 79 * @throws { BusinessError } 13900006 - No such device or address 80 * @throws { BusinessError } 13900008 - Bad file descriptor 81 * @throws { BusinessError } 13900011 - Out of memory 82 * @throws { BusinessError } 13900012 - Permission denied 83 * @throws { BusinessError } 13900013 - Bad address 84 * @throws { BusinessError } 13900014 - Device or resource busy 85 * @throws { BusinessError } 13900015 - File exists 86 * @throws { BusinessError } 13900017 - No such device 87 * @throws { BusinessError } 13900018 - Not a directory 88 * @throws { BusinessError } 13900019 - Is a directory 89 * @throws { BusinessError } 13900020 - Invalid argument 90 * @throws { BusinessError } 13900022 - Too many open files 91 * @throws { BusinessError } 13900023 - Text file busy 92 * @throws { BusinessError } 13900024 - File too large 93 * @throws { BusinessError } 13900025 - No space left on device 94 * @throws { BusinessError } 13900027 - Read-only file system 95 * @throws { BusinessError } 13900029 - Resource deadlock would occur 96 * @throws { BusinessError } 13900030 - File name too long 97 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 98 * @throws { BusinessError } 13900034 - Operation would block 99 * @throws { BusinessError } 13900038 - Value too large for defined data type 100 * @throws { BusinessError } 13900041 - Quota exceeded 101 * @throws { BusinessError } 13900042 - Unknown error 102 * @throws { BusinessError } 14300001 - IPC error 103 * @throws { BusinessError } 14300002 - Invalid uri 104 * @throws { BusinessError } 14300003 - Fail to get fileextension info 105 * @throws { BusinessError } 14300004 - Get wrong result 106 * @syscap SystemCapability.FileManagement.UserFileService 107 * @systemapi 108 * @StageModelOnly 109 * @since 9 110 */ 111 function getFileAccessAbilityInfo(): Promise<Array<Want>>; 112 113 /** 114 * Obtains the fileAccessHelper that connects all fileaccess servers in the system. 115 * 116 * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 117 * @param { Context } context Indicates the application context. 118 * @returns { FileAccessHelper } Returns the fileAccessHelper. 119 * @throws { BusinessError } 13900001 - Operation not permitted 120 * @throws { BusinessError } 13900002 - No such file or directory 121 * @throws { BusinessError } 13900004 - Interrupted system call 122 * @throws { BusinessError } 13900006 - No such device or address 123 * @throws { BusinessError } 13900008 - Bad file descriptor 124 * @throws { BusinessError } 13900011 - Out of memory 125 * @throws { BusinessError } 13900012 - Permission denied 126 * @throws { BusinessError } 13900013 - Bad address 127 * @throws { BusinessError } 13900014 - Device or resource busy 128 * @throws { BusinessError } 13900015 - File exists 129 * @throws { BusinessError } 13900017 - No such device 130 * @throws { BusinessError } 13900018 - Not a directory 131 * @throws { BusinessError } 13900019 - Is a directory 132 * @throws { BusinessError } 13900020 - Invalid argument 133 * @throws { BusinessError } 13900022 - Too many open files 134 * @throws { BusinessError } 13900023 - Text file busy 135 * @throws { BusinessError } 13900024 - File too large 136 * @throws { BusinessError } 13900025 - No space left on device 137 * @throws { BusinessError } 13900027 - Read-only file system 138 * @throws { BusinessError } 13900029 - Resource deadlock would occur 139 * @throws { BusinessError } 13900030 - File name too long 140 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 141 * @throws { BusinessError } 13900034 - Operation would block 142 * @throws { BusinessError } 13900038 - Value too large for defined data type 143 * @throws { BusinessError } 13900041 - Quota exceeded 144 * @throws { BusinessError } 13900042 - Unknown error 145 * @throws { BusinessError } 14300001 - IPC error 146 * @throws { BusinessError } 14300002 - Invalid uri 147 * @throws { BusinessError } 14300003 - Fail to get fileextension info 148 * @throws { BusinessError } 14300004 - Get wrong result 149 * @syscap SystemCapability.FileManagement.UserFileService 150 * @systemapi 151 * @StageModelOnly 152 * @since 9 153 */ 154 function createFileAccessHelper(context: Context): FileAccessHelper; 155 156 /** 157 * Obtains the fileAccessHelper that connects some specified fileaccess servers in the system. 158 * 159 * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 160 * @param { Context } context Indicates the application context. 161 * @param { Array<Want> } wants Represents the connected data provider. 162 * @returns { FileAccessHelper } Returns the fileAccessHelper. 163 * @throws { BusinessError } 13900001 - Operation not permitted 164 * @throws { BusinessError } 13900002 - No such file or directory 165 * @throws { BusinessError } 13900004 - Interrupted system call 166 * @throws { BusinessError } 13900006 - No such device or address 167 * @throws { BusinessError } 13900008 - Bad file descriptor 168 * @throws { BusinessError } 13900011 - Out of memory 169 * @throws { BusinessError } 13900012 - Permission denied 170 * @throws { BusinessError } 13900013 - Bad address 171 * @throws { BusinessError } 13900014 - Device or resource busy 172 * @throws { BusinessError } 13900015 - File exists 173 * @throws { BusinessError } 13900017 - No such device 174 * @throws { BusinessError } 13900018 - Not a directory 175 * @throws { BusinessError } 13900019 - Is a directory 176 * @throws { BusinessError } 13900020 - Invalid argument 177 * @throws { BusinessError } 13900022 - Too many open files 178 * @throws { BusinessError } 13900023 - Text file busy 179 * @throws { BusinessError } 13900024 - File too large 180 * @throws { BusinessError } 13900025 - No space left on device 181 * @throws { BusinessError } 13900027 - Read-only file system 182 * @throws { BusinessError } 13900029 - Resource deadlock would occur 183 * @throws { BusinessError } 13900030 - File name too long 184 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 185 * @throws { BusinessError } 13900034 - Operation would block 186 * @throws { BusinessError } 13900038 - Value too large for defined data type 187 * @throws { BusinessError } 13900041 - Quota exceeded 188 * @throws { BusinessError } 13900042 - Unknown error 189 * @throws { BusinessError } 14300001 - IPC error 190 * @throws { BusinessError } 14300002 - Invalid uri 191 * @throws { BusinessError } 14300003 - Fail to get fileextension info 192 * @throws { BusinessError } 14300004 - Get wrong result 193 * @syscap SystemCapability.FileManagement.UserFileService 194 * @systemapi 195 * @StageModelOnly 196 * @since 9 197 */ 198 function createFileAccessHelper(context: Context, wants: Array<Want>): FileAccessHelper; 199 200 /** 201 * File Object 202 * 203 * @interface FileInfo 204 * @permission ohos.permission.FILE_ACCESS_MANAGER 205 * @syscap SystemCapability.FileManagement.UserFileService 206 * @systemapi 207 * @StageModelOnly 208 * @since 9 209 */ 210 interface FileInfo { 211 /** 212 * Indicates the path of the file. 213 * 214 * @permission ohos.permission.FILE_ACCESS_MANAGER 215 * @type { string } 216 * @readonly 217 * @syscap SystemCapability.FileManagement.UserFileService 218 * @systemapi 219 * @StageModelOnly 220 * @since 9 221 */ 222 uri: string; 223 /** 224 * Indicates the relativePath of the file. 225 * 226 * @permission ohos.permission.FILE_ACCESS_MANAGER 227 * @type { string } 228 * @readonly 229 * @syscap SystemCapability.FileManagement.UserFileService 230 * @systemapi 231 * @StageModelOnly 232 * @since 10 233 */ 234 relativePath: string; 235 /** 236 * Indicates the name of the file. 237 * 238 * @permission ohos.permission.FILE_ACCESS_MANAGER 239 * @type { string } 240 * @readonly 241 * @syscap SystemCapability.FileManagement.UserFileService 242 * @systemapi 243 * @StageModelOnly 244 * @since 9 245 */ 246 fileName: string; 247 /** 248 * Indicates the mode of the file. 249 * 250 * @permission ohos.permission.FILE_ACCESS_MANAGER 251 * @type { number } 252 * @readonly 253 * @syscap SystemCapability.FileManagement.UserFileService 254 * @systemapi 255 * @StageModelOnly 256 * @since 9 257 */ 258 mode: number; 259 /** 260 * Indicates the size of the file. 261 * 262 * @permission ohos.permission.FILE_ACCESS_MANAGER 263 * @type { number } 264 * @readonly 265 * @syscap SystemCapability.FileManagement.UserFileService 266 * @systemapi 267 * @StageModelOnly 268 * @since 9 269 */ 270 size: number; 271 /** 272 * Indicates the mtime of the file. 273 * 274 * @permission ohos.permission.FILE_ACCESS_MANAGER 275 * @type { number } 276 * @readonly 277 * @syscap SystemCapability.FileManagement.UserFileService 278 * @systemapi 279 * @StageModelOnly 280 * @since 9 281 */ 282 mtime: number; 283 /** 284 * Indicates the mimeType of the file. 285 * 286 * @permission ohos.permission.FILE_ACCESS_MANAGER 287 * @type { string } 288 * @readonly 289 * @syscap SystemCapability.FileManagement.UserFileService 290 * @systemapi 291 * @StageModelOnly 292 * @since 9 293 */ 294 mimeType: string; 295 296 /** 297 * List files in the current directory. 298 * 299 * @permission ohos.permission.FILE_ACCESS_MANAGER 300 * @param { Filter } filter Indicates the filter of file. 301 * @returns { FileIterator } Returns the FileIterator Object. 302 * @throws { BusinessError } 13900001 - Operation not permitted 303 * @throws { BusinessError } 13900002 - No such file or directory 304 * @throws { BusinessError } 13900004 - Interrupted system call 305 * @throws { BusinessError } 13900006 - No such device or address 306 * @throws { BusinessError } 13900008 - Bad file descriptor 307 * @throws { BusinessError } 13900011 - Out of memory 308 * @throws { BusinessError } 13900012 - Permission denied 309 * @throws { BusinessError } 13900013 - Bad address 310 * @throws { BusinessError } 13900014 - Device or resource busy 311 * @throws { BusinessError } 13900015 - File exists 312 * @throws { BusinessError } 13900017 - No such device 313 * @throws { BusinessError } 13900018 - Not a directory 314 * @throws { BusinessError } 13900019 - Is a directory 315 * @throws { BusinessError } 13900020 - Invalid argument 316 * @throws { BusinessError } 13900022 - Too many open files 317 * @throws { BusinessError } 13900023 - Text file busy 318 * @throws { BusinessError } 13900024 - File too large 319 * @throws { BusinessError } 13900025 - No space left on device 320 * @throws { BusinessError } 13900027 - Read-only file system 321 * @throws { BusinessError } 13900029 - Resource deadlock would occur 322 * @throws { BusinessError } 13900030 - File name too long 323 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 324 * @throws { BusinessError } 13900034 - Operation would block 325 * @throws { BusinessError } 13900038 - Value too large for defined data type 326 * @throws { BusinessError } 13900041 - Quota exceeded 327 * @throws { BusinessError } 13900042 - Unknown error 328 * @throws { BusinessError } 14000001 - Invalid display name 329 * @throws { BusinessError } 14000002 - Invalid uri 330 * @throws { BusinessError } 14000003 - Invalid file extension 331 * @throws { BusinessError } 14000004 - File has been put into trash bin 332 * @throws { BusinessError } 14300001 - IPC error 333 * @throws { BusinessError } 14300002 - Invalid uri 334 * @throws { BusinessError } 14300003 - Fail to get fileextension info 335 * @throws { BusinessError } 14300004 - Get wrong result 336 * @syscap SystemCapability.FileManagement.UserFileService 337 * @systemapi 338 * @StageModelOnly 339 * @since 9 340 */ 341 listFile(filter?: Filter): FileIterator; 342 343 /** 344 * Recursively list all files in the current directory. 345 * 346 * @permission ohos.permission.FILE_ACCESS_MANAGER 347 * @param { Filter } filter Indicates the filter of file. 348 * @returns { FileIterator } Returns the FileIterator Object. 349 * @throws { BusinessError } 13900001 - Operation not permitted 350 * @throws { BusinessError } 13900002 - No such file or directory 351 * @throws { BusinessError } 13900004 - Interrupted system call 352 * @throws { BusinessError } 13900006 - No such device or address 353 * @throws { BusinessError } 13900008 - Bad file descriptor 354 * @throws { BusinessError } 13900011 - Out of memory 355 * @throws { BusinessError } 13900012 - Permission denied 356 * @throws { BusinessError } 13900013 - Bad address 357 * @throws { BusinessError } 13900014 - Device or resource busy 358 * @throws { BusinessError } 13900015 - File exists 359 * @throws { BusinessError } 13900017 - No such device 360 * @throws { BusinessError } 13900018 - Not a directory 361 * @throws { BusinessError } 13900019 - Is a directory 362 * @throws { BusinessError } 13900020 - Invalid argument 363 * @throws { BusinessError } 13900022 - Too many open files 364 * @throws { BusinessError } 13900023 - Text file busy 365 * @throws { BusinessError } 13900024 - File too large 366 * @throws { BusinessError } 13900025 - No space left on device 367 * @throws { BusinessError } 13900027 - Read-only file system 368 * @throws { BusinessError } 13900029 - Resource deadlock would occur 369 * @throws { BusinessError } 13900030 - File name too long 370 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 371 * @throws { BusinessError } 13900034 - Operation would block 372 * @throws { BusinessError } 13900038 - Value too large for defined data type 373 * @throws { BusinessError } 13900041 - Quota exceeded 374 * @throws { BusinessError } 13900042 - Unknown error 375 * @throws { BusinessError } 14000001 - Invalid display name 376 * @throws { BusinessError } 14000002 - Invalid uri 377 * @throws { BusinessError } 14000003 - Invalid file extension 378 * @throws { BusinessError } 14000004 - File has been put into trash bin 379 * @throws { BusinessError } 14300001 - IPC error 380 * @throws { BusinessError } 14300002 - Invalid uri 381 * @throws { BusinessError } 14300003 - Fail to get fileextension info 382 * @throws { BusinessError } 14300004 - Get wrong result 383 * @syscap SystemCapability.FileManagement.UserFileService 384 * @systemapi 385 * @StageModelOnly 386 * @since 9 387 */ 388 scanFile(filter?: Filter): FileIterator; 389 } 390 391 /** 392 * FileIterator Object 393 * 394 * @interface FileIterator 395 * @permission ohos.permission.FILE_ACCESS_MANAGER 396 * @syscap SystemCapability.FileManagement.UserFileService 397 * @systemapi 398 * @StageModelOnly 399 * @since 9 400 */ 401 interface FileIterator { 402 /** 403 * Get the next fileInfo. 404 * 405 * @permission ohos.permission.FILE_ACCESS_MANAGER 406 * @returns { { value: FileInfo, done: boolean } } Returns FileInfo Object and boolean flag. 407 * @throws { BusinessError } 13900001 - Operation not permitted 408 * @throws { BusinessError } 13900002 - No such file or directory 409 * @throws { BusinessError } 13900004 - Interrupted system call 410 * @throws { BusinessError } 13900006 - No such device or address 411 * @throws { BusinessError } 13900008 - Bad file descriptor 412 * @throws { BusinessError } 13900011 - Out of memory 413 * @throws { BusinessError } 13900012 - Permission denied 414 * @throws { BusinessError } 13900013 - Bad address 415 * @throws { BusinessError } 13900014 - Device or resource busy 416 * @throws { BusinessError } 13900015 - File exists 417 * @throws { BusinessError } 13900017 - No such device 418 * @throws { BusinessError } 13900018 - Not a directory 419 * @throws { BusinessError } 13900019 - Is a directory 420 * @throws { BusinessError } 13900020 - Invalid argument 421 * @throws { BusinessError } 13900022 - Too many open files 422 * @throws { BusinessError } 13900023 - Text file busy 423 * @throws { BusinessError } 13900024 - File too large 424 * @throws { BusinessError } 13900025 - No space left on device 425 * @throws { BusinessError } 13900027 - Read-only file system 426 * @throws { BusinessError } 13900029 - Resource deadlock would occur 427 * @throws { BusinessError } 13900030 - File name too long 428 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 429 * @throws { BusinessError } 13900034 - Operation would block 430 * @throws { BusinessError } 13900038 - Value too large for defined data type 431 * @throws { BusinessError } 13900041 - Quota exceeded 432 * @throws { BusinessError } 13900042 - Unknown error 433 * @throws { BusinessError } 14000001 - Invalid display name 434 * @throws { BusinessError } 14000002 - Invalid uri 435 * @throws { BusinessError } 14000003 - Invalid file extension 436 * @throws { BusinessError } 14000004 - File has been put into trash bin 437 * @throws { BusinessError } 14300001 - IPC error 438 * @throws { BusinessError } 14300002 - Invalid uri 439 * @throws { BusinessError } 14300003 - Fail to get fileextension info 440 * @throws { BusinessError } 14300004 - Get wrong result 441 * @syscap SystemCapability.FileManagement.UserFileService 442 * @systemapi 443 * @StageModelOnly 444 * @since 9 445 */ 446 next(): { value: FileInfo, done: boolean }; 447 } 448 449 /** 450 * Root Object 451 * 452 * @interface RootInfo 453 * @permission ohos.permission.FILE_ACCESS_MANAGER 454 * @syscap SystemCapability.FileManagement.UserFileService 455 * @systemapi 456 * @StageModelOnly 457 * @since 9 458 */ 459 interface RootInfo { 460 /** 461 * @permission ohos.permission.FILE_ACCESS_MANAGER 462 * @type { number } 463 * @readonly 464 * @syscap SystemCapability.FileManagement.UserFileService 465 * @systemapi 466 * @StageModelOnly 467 * @since 9 468 */ 469 deviceType: number; 470 /** 471 * @permission ohos.permission.FILE_ACCESS_MANAGER 472 * @type { string } 473 * @readonly 474 * @syscap SystemCapability.FileManagement.UserFileService 475 * @systemapi 476 * @StageModelOnly 477 * @since 9 478 */ 479 uri: string; 480 /** 481 * File or directory relative path 482 * 483 * @permission ohos.permission.FILE_ACCESS_MANAGER 484 * @type { string } 485 * @readonly 486 * @syscap SystemCapability.FileManagement.UserFileService 487 * @systemapi 488 * @StageModelOnly 489 * @since 10 490 */ 491 relativePath: string; 492 /** 493 * @permission ohos.permission.FILE_ACCESS_MANAGER 494 * @type { string } 495 * @readonly 496 * @syscap SystemCapability.FileManagement.UserFileService 497 * @systemapi 498 * @StageModelOnly 499 * @since 9 500 */ 501 displayName: string; 502 /** 503 * @permission ohos.permission.FILE_ACCESS_MANAGER 504 * @type { number } 505 * @readonly 506 * @syscap SystemCapability.FileManagement.UserFileService 507 * @systemapi 508 * @StageModelOnly 509 * @since 9 510 */ 511 deviceFlags: number; 512 513 /** 514 * List files in the current directory. 515 * 516 * @permission ohos.permission.FILE_ACCESS_MANAGER 517 * @param { Filter } filter Indicates the filter of file. 518 * @returns { FileIterator } Returns the FileIterator Object. 519 * @throws { BusinessError } 13900001 - Operation not permitted 520 * @throws { BusinessError } 13900002 - No such file or directory 521 * @throws { BusinessError } 13900004 - Interrupted system call 522 * @throws { BusinessError } 13900006 - No such device or address 523 * @throws { BusinessError } 13900008 - Bad file descriptor 524 * @throws { BusinessError } 13900011 - Out of memory 525 * @throws { BusinessError } 13900012 - Permission denied 526 * @throws { BusinessError } 13900013 - Bad address 527 * @throws { BusinessError } 13900014 - Device or resource busy 528 * @throws { BusinessError } 13900015 - File exists 529 * @throws { BusinessError } 13900017 - No such device 530 * @throws { BusinessError } 13900018 - Not a directory 531 * @throws { BusinessError } 13900019 - Is a directory 532 * @throws { BusinessError } 13900020 - Invalid argument 533 * @throws { BusinessError } 13900022 - Too many open files 534 * @throws { BusinessError } 13900023 - Text file busy 535 * @throws { BusinessError } 13900024 - File too large 536 * @throws { BusinessError } 13900025 - No space left on device 537 * @throws { BusinessError } 13900027 - Read-only file system 538 * @throws { BusinessError } 13900029 - Resource deadlock would occur 539 * @throws { BusinessError } 13900030 - File name too long 540 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 541 * @throws { BusinessError } 13900034 - Operation would block 542 * @throws { BusinessError } 13900038 - Value too large for defined data type 543 * @throws { BusinessError } 13900041 - Quota exceeded 544 * @throws { BusinessError } 13900042 - Unknown error 545 * @throws { BusinessError } 14000001 - Invalid display name 546 * @throws { BusinessError } 14000002 - Invalid uri 547 * @throws { BusinessError } 14000003 - Invalid file extension 548 * @throws { BusinessError } 14000004 - File has been put into trash bin 549 * @throws { BusinessError } 14300001 - IPC error 550 * @throws { BusinessError } 14300002 - Invalid uri 551 * @throws { BusinessError } 14300003 - Fail to get fileextension info 552 * @throws { BusinessError } 14300004 - Get wrong result 553 * @syscap SystemCapability.FileManagement.UserFileService 554 * @systemapi 555 * @StageModelOnly 556 * @since 9 557 */ 558 listFile(filter?: Filter): FileIterator; 559 560 /** 561 * Recursively list all files in the current directory. 562 * 563 * @permission ohos.permission.FILE_ACCESS_MANAGER 564 * @param { Filter } filter Indicates the filter of file. 565 * @returns { FileIterator } Returns the RootIterator Object. 566 * @throws { BusinessError } 13900001 - Operation not permitted 567 * @throws { BusinessError } 13900002 - No such file or directory 568 * @throws { BusinessError } 13900004 - Interrupted system call 569 * @throws { BusinessError } 13900006 - No such device or address 570 * @throws { BusinessError } 13900008 - Bad file descriptor 571 * @throws { BusinessError } 13900011 - Out of memory 572 * @throws { BusinessError } 13900012 - Permission denied 573 * @throws { BusinessError } 13900013 - Bad address 574 * @throws { BusinessError } 13900014 - Device or resource busy 575 * @throws { BusinessError } 13900015 - File exists 576 * @throws { BusinessError } 13900017 - No such device 577 * @throws { BusinessError } 13900018 - Not a directory 578 * @throws { BusinessError } 13900019 - Is a directory 579 * @throws { BusinessError } 13900020 - Invalid argument 580 * @throws { BusinessError } 13900022 - Too many open files 581 * @throws { BusinessError } 13900023 - Text file busy 582 * @throws { BusinessError } 13900024 - File too large 583 * @throws { BusinessError } 13900025 - No space left on device 584 * @throws { BusinessError } 13900027 - Read-only file system 585 * @throws { BusinessError } 13900029 - Resource deadlock would occur 586 * @throws { BusinessError } 13900030 - File name too long 587 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 588 * @throws { BusinessError } 13900034 - Operation would block 589 * @throws { BusinessError } 13900038 - Value too large for defined data type 590 * @throws { BusinessError } 13900041 - Quota exceeded 591 * @throws { BusinessError } 13900042 - Unknown error 592 * @throws { BusinessError } 14000001 - Invalid display name 593 * @throws { BusinessError } 14000002 - Invalid uri 594 * @throws { BusinessError } 14000003 - Invalid file extension 595 * @throws { BusinessError } 14000004 - File has been put into trash bin 596 * @throws { BusinessError } 14300001 - IPC error 597 * @throws { BusinessError } 14300002 - Invalid uri 598 * @throws { BusinessError } 14300003 - Fail to get fileextension info 599 * @throws { BusinessError } 14300004 - Get wrong result 600 * @syscap SystemCapability.FileManagement.UserFileService 601 * @systemapi 602 * @StageModelOnly 603 * @since 9 604 */ 605 scanFile(filter?: Filter): FileIterator; 606 } 607 608 /** 609 * RootIterator Object 610 * 611 * @interface RootIterator 612 * @permission ohos.permission.FILE_ACCESS_MANAGER 613 * @syscap SystemCapability.FileManagement.UserFileService 614 * @systemapi 615 * @StageModelOnly 616 * @since 9 617 */ 618 interface RootIterator { 619 /** 620 * Get a next RootInfo. 621 * 622 * @permission ohos.permission.FILE_ACCESS_MANAGER 623 * @returns { { value: RootInfo, done: boolean } } Returns RootInfo Object and boolean flag. 624 * @throws { BusinessError } 13900001 - Operation not permitted 625 * @throws { BusinessError } 13900002 - No such file or directory 626 * @throws { BusinessError } 13900004 - Interrupted system call 627 * @throws { BusinessError } 13900006 - No such device or address 628 * @throws { BusinessError } 13900008 - Bad file descriptor 629 * @throws { BusinessError } 13900011 - Out of memory 630 * @throws { BusinessError } 13900012 - Permission denied 631 * @throws { BusinessError } 13900013 - Bad address 632 * @throws { BusinessError } 13900014 - Device or resource busy 633 * @throws { BusinessError } 13900015 - File exists 634 * @throws { BusinessError } 13900017 - No such device 635 * @throws { BusinessError } 13900018 - Not a directory 636 * @throws { BusinessError } 13900019 - Is a directory 637 * @throws { BusinessError } 13900020 - Invalid argument 638 * @throws { BusinessError } 13900022 - Too many open files 639 * @throws { BusinessError } 13900023 - Text file busy 640 * @throws { BusinessError } 13900024 - File too large 641 * @throws { BusinessError } 13900025 - No space left on device 642 * @throws { BusinessError } 13900027 - Read-only file system 643 * @throws { BusinessError } 13900029 - Resource deadlock would occur 644 * @throws { BusinessError } 13900030 - File name too long 645 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 646 * @throws { BusinessError } 13900034 - Operation would block 647 * @throws { BusinessError } 13900038 - Value too large for defined data type 648 * @throws { BusinessError } 13900041 - Quota exceeded 649 * @throws { BusinessError } 13900042 - Unknown error 650 * @throws { BusinessError } 14000001 - Invalid display name 651 * @throws { BusinessError } 14000002 - Invalid uri 652 * @throws { BusinessError } 14000003 - Invalid file extension 653 * @throws { BusinessError } 14000004 - File has been put into trash bin 654 * @throws { BusinessError } 14300001 - IPC error 655 * @throws { BusinessError } 14300002 - Invalid uri 656 * @throws { BusinessError } 14300003 - Fail to get fileextension info 657 * @throws { BusinessError } 14300004 - Get wrong result 658 * @syscap SystemCapability.FileManagement.UserFileService 659 * @systemapi 660 * @StageModelOnly 661 * @since 9 662 */ 663 next(): { value: RootInfo, done: boolean }; 664 } 665 666 /** 667 * Describes the return information of the copy operation. 668 * 669 * @interface CopyResult 670 * @permission ohos.permission.FILE_ACCESS_MANAGER 671 * @syscap SystemCapability.FileManagement.UserFileService 672 * @systemapi 673 * @since 10 674 */ 675 interface CopyResult { 676 sourceUri: string; 677 destUri: string; 678 errCode: number; 679 errMsg: string; 680 } 681 682 /** 683 * OPENFLAGS represents the way to open the file. 684 * 685 * @enum { number } OPENFLAGS 686 * @syscap SystemCapability.FileManagement.UserFileService 687 * @systemapi 688 * @StageModelOnly 689 * @since 9 690 */ 691 enum OPENFLAGS { 692 /** 693 * Open the file by Read-only mode. 694 * 695 * @syscap SystemCapability.FileManagement.UserFileService 696 * @systemapi 697 * @StageModelOnly 698 * @since 9 699 */ 700 READ = 0o0, 701 702 /** 703 * Open the file by Write-only mode. 704 * 705 * @syscap SystemCapability.FileManagement.UserFileService 706 * @systemapi 707 * @StageModelOnly 708 * @since 9 709 */ 710 WRITE = 0o1, 711 712 /** 713 * Open the file by Write-Read mode. 714 * 715 * @syscap SystemCapability.FileManagement.UserFileService 716 * @systemapi 717 * @StageModelOnly 718 * @since 9 719 */ 720 WRITE_READ = 0o2 721 } 722 723 /** 724 * Property elements that support the file queries. 725 * 726 * @enum { string } FileKey 727 * @syscap SystemCapability.FileManagement.UserFileService 728 * @systemapi 729 * @StageModelOnly 730 * @since 10 731 */ 732 enum FileKey { 733 /** 734 * The key represents the file name. 735 * 736 * @syscap SystemCapability.FileManagement.UserFileService 737 * @systemapi 738 * @StageModelOnly 739 * @since 10 740 */ 741 DISPLAY_NAME = 'display_name', 742 743 /** 744 * The key represents the date of the file creation. 745 * 746 * @syscap SystemCapability.FileManagement.UserFileService 747 * @systemapi 748 * @StageModelOnly 749 * @since 10 750 */ 751 DATE_ADDED = 'date_added', 752 753 /** 754 * The key represents the modify date of the file. 755 * 756 * @syscap SystemCapability.FileManagement.UserFileService 757 * @systemapi 758 * @StageModelOnly 759 * @since 10 760 */ 761 DATE_MODIFIED = 'date_modified', 762 763 /** 764 * The key represents the relative path. 765 * 766 * @syscap SystemCapability.FileManagement.UserFileService 767 * @systemapi 768 * @StageModelOnly 769 * @since 10 770 */ 771 RELATIVE_PATH = 'relative_path', 772 773 /** 774 * The key represents the file size. 775 * 776 * @syscap SystemCapability.FileManagement.UserFileService 777 * @systemapi 778 * @StageModelOnly 779 * @since 10 780 */ 781 FILE_SIZE = 'size' 782 } 783 784 /** 785 * Describes the notifyType. 786 * 787 * @enum { number } NotifyType 788 * @syscap SystemCapability.FileManagement.UserFileService 789 * @systemapi 790 * @StageModelOnly 791 * @since 10 792 */ 793 enum NotifyType { 794 /** 795 * Type for add notification 796 * 797 * @syscap SystemCapability.FileManagement.UserFileService 798 * @systemapi 799 * @StageModelOnly 800 * @since 10 801 */ 802 NOTIFY_ADD, 803 804 /** 805 * Type for delete notification 806 * 807 * @syscap SystemCapability.FileManagement.UserFileService 808 * @systemapi 809 * @StageModelOnly 810 * @since 10 811 */ 812 NOTIFY_DELETE, 813 814 /** 815 * The file was moved into the monitored directory. 816 * 817 * @syscap SystemCapability.FileManagement.UserFileService 818 * @systemapi 819 * @StageModelOnly 820 * @since 10 821 */ 822 NOTIFY_MOVED_TO, 823 824 /** 825 * The file in the monitored directory was moved. 826 * 827 * @syscap SystemCapability.FileManagement.UserFileService 828 * @systemapi 829 * @StageModelOnly 830 * @since 10 831 */ 832 NOTIFY_MOVED_FROM, 833 834 /** 835 * The monitored file or directory was moved. 836 * 837 * @syscap SystemCapability.FileManagement.UserFileService 838 * @systemapi 839 * @StageModelOnly 840 * @since 10 841 */ 842 NOTIFY_MOVE_SELF 843 } 844 845 /** 846 * The value of the notify callback function 847 * 848 * @interface NotifyMessage 849 * @permission ohos.permission.FILE_ACCESS_MANAGER 850 * @syscap SystemCapability.FileManagement.UserFileService 851 * @systemapi 852 * @StageModelOnly 853 * @since 10 854 */ 855 interface NotifyMessage { 856 /** 857 * Indicates the change type. 858 * 859 * @permission ohos.permission.FILE_ACCESS_MANAGER 860 * @type { NotifyType } 861 * @readonly 862 * @syscap SystemCapability.FileManagement.UserFileService 863 * @systemapi 864 * @StageModelOnly 865 * @since 10 866 */ 867 type: NotifyType; 868 869 /** 870 * Indicates the uris generated the change event. 871 * 872 * @permission ohos.permission.FILE_ACCESS_MANAGER 873 * @type { Array<string> } 874 * @readonly 875 * @syscap SystemCapability.FileManagement.UserFileService 876 * @systemapi 877 * @StageModelOnly 878 * @since 10 879 */ 880 uris: Array<string>; 881 } 882 883 /** 884 * FileAccessHelper Object 885 * 886 * @interface FileAccessHelper 887 * @permission ohos.permission.FILE_ACCESS_MANAGER 888 * @syscap SystemCapability.FileManagement.UserFileService 889 * @systemapi 890 * @since 9 891 */ 892 interface FileAccessHelper { 893 /** 894 * Open a file. 895 * 896 * @permission ohos.permission.FILE_ACCESS_MANAGER 897 * @param { string } uri Indicates the path of the file to open. 898 * @param { OPENFLAGS } flags Indicate options of opening a file. The default value is read-only. 899 * @returns { Promise<number> } Returns the file descriptor. 900 * @throws { BusinessError } 13900001 - Operation not permitted 901 * @throws { BusinessError } 13900002 - No such file or directory 902 * @throws { BusinessError } 13900004 - Interrupted system call 903 * @throws { BusinessError } 13900006 - No such device or address 904 * @throws { BusinessError } 13900008 - Bad file descriptor 905 * @throws { BusinessError } 13900011 - Out of memory 906 * @throws { BusinessError } 13900012 - Permission denied 907 * @throws { BusinessError } 13900013 - Bad address 908 * @throws { BusinessError } 13900014 - Device or resource busy 909 * @throws { BusinessError } 13900015 - File exists 910 * @throws { BusinessError } 13900017 - No such device 911 * @throws { BusinessError } 13900018 - Not a directory 912 * @throws { BusinessError } 13900019 - Is a directory 913 * @throws { BusinessError } 13900020 - Invalid argument 914 * @throws { BusinessError } 13900022 - Too many open files 915 * @throws { BusinessError } 13900023 - Text file busy 916 * @throws { BusinessError } 13900024 - File too large 917 * @throws { BusinessError } 13900025 - No space left on device 918 * @throws { BusinessError } 13900027 - Read-only file system 919 * @throws { BusinessError } 13900029 - Resource deadlock would occur 920 * @throws { BusinessError } 13900030 - File name too long 921 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 922 * @throws { BusinessError } 13900034 - Operation would block 923 * @throws { BusinessError } 13900038 - Value too large for defined data type 924 * @throws { BusinessError } 13900041 - Quota exceeded 925 * @throws { BusinessError } 13900042 - Unknown error 926 * @throws { BusinessError } 14000001 - Invalid display name 927 * @throws { BusinessError } 14000002 - Invalid uri 928 * @throws { BusinessError } 14000003 - Invalid file extension 929 * @throws { BusinessError } 14000004 - File has been put into trash bin 930 * @throws { BusinessError } 14300001 - IPC error 931 * @throws { BusinessError } 14300002 - Invalid uri 932 * @throws { BusinessError } 14300003 - Fail to get fileextension info 933 * @throws { BusinessError } 14300004 - Get wrong result 934 * @syscap SystemCapability.FileManagement.UserFileService 935 * @systemapi 936 * @since 9 937 */ 938 openFile(uri: string, flags: OPENFLAGS): Promise<number>; 939 940 /** 941 * Open a file. 942 * 943 * @permission ohos.permission.FILE_ACCESS_MANAGER 944 * @param { string } uri Indicates the path of the file to open. 945 * @param { OPENFLAGS } flags Indicate options of opening a file. The default value is read-only. 946 * @param { AsyncCallback<number> } callback - The callback is used to return the file descriptor. 947 * @throws { BusinessError } 13900001 - Operation not permitted 948 * @throws { BusinessError } 13900002 - No such file or directory 949 * @throws { BusinessError } 13900004 - Interrupted system call 950 * @throws { BusinessError } 13900006 - No such device or address 951 * @throws { BusinessError } 13900008 - Bad file descriptor 952 * @throws { BusinessError } 13900011 - Out of memory 953 * @throws { BusinessError } 13900012 - Permission denied 954 * @throws { BusinessError } 13900013 - Bad address 955 * @throws { BusinessError } 13900014 - Device or resource busy 956 * @throws { BusinessError } 13900015 - File exists 957 * @throws { BusinessError } 13900017 - No such device 958 * @throws { BusinessError } 13900018 - Not a directory 959 * @throws { BusinessError } 13900019 - Is a directory 960 * @throws { BusinessError } 13900020 - Invalid argument 961 * @throws { BusinessError } 13900022 - Too many open files 962 * @throws { BusinessError } 13900023 - Text file busy 963 * @throws { BusinessError } 13900024 - File too large 964 * @throws { BusinessError } 13900025 - No space left on device 965 * @throws { BusinessError } 13900027 - Read-only file system 966 * @throws { BusinessError } 13900029 - Resource deadlock would occur 967 * @throws { BusinessError } 13900030 - File name too long 968 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 969 * @throws { BusinessError } 13900034 - Operation would block 970 * @throws { BusinessError } 13900038 - Value too large for defined data type 971 * @throws { BusinessError } 13900041 - Quota exceeded 972 * @throws { BusinessError } 13900042 - Unknown error 973 * @throws { BusinessError } 14000001 - Invalid display name 974 * @throws { BusinessError } 14000002 - Invalid uri 975 * @throws { BusinessError } 14000003 - Invalid file extension 976 * @throws { BusinessError } 14000004 - File has been put into trash bin 977 * @throws { BusinessError } 14300001 - IPC error 978 * @throws { BusinessError } 14300002 - Invalid uri 979 * @throws { BusinessError } 14300003 - Fail to get fileextension info 980 * @throws { BusinessError } 14300004 - Get wrong result 981 * @syscap SystemCapability.FileManagement.UserFileService 982 * @systemapi 983 * @since 9 984 */ 985 openFile(uri: string, flags: OPENFLAGS, callback: AsyncCallback<number>): void; 986 987 /** 988 * Create a file. 989 * 990 * @permission ohos.permission.FILE_ACCESS_MANAGER 991 * @param { string } uri Represents a specific parent directory. 992 * @param { string } displayName Indicates the new file name, and supports with suffix. 993 * @returns { Promise<string> } Returns the new file's URI. 994 * @throws { BusinessError } 13900001 - Operation not permitted 995 * @throws { BusinessError } 13900002 - No such file or directory 996 * @throws { BusinessError } 13900004 - Interrupted system call 997 * @throws { BusinessError } 13900006 - No such device or address 998 * @throws { BusinessError } 13900008 - Bad file descriptor 999 * @throws { BusinessError } 13900011 - Out of memory 1000 * @throws { BusinessError } 13900012 - Permission denied 1001 * @throws { BusinessError } 13900013 - Bad address 1002 * @throws { BusinessError } 13900014 - Device or resource busy 1003 * @throws { BusinessError } 13900015 - File exists 1004 * @throws { BusinessError } 13900017 - No such device 1005 * @throws { BusinessError } 13900018 - Not a directory 1006 * @throws { BusinessError } 13900019 - Is a directory 1007 * @throws { BusinessError } 13900020 - Invalid argument 1008 * @throws { BusinessError } 13900022 - Too many open files 1009 * @throws { BusinessError } 13900023 - Text file busy 1010 * @throws { BusinessError } 13900024 - File too large 1011 * @throws { BusinessError } 13900025 - No space left on device 1012 * @throws { BusinessError } 13900027 - Read-only file system 1013 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1014 * @throws { BusinessError } 13900030 - File name too long 1015 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1016 * @throws { BusinessError } 13900034 - Operation would block 1017 * @throws { BusinessError } 13900038 - Value too large for defined data type 1018 * @throws { BusinessError } 13900041 - Quota exceeded 1019 * @throws { BusinessError } 13900042 - Unknown error 1020 * @throws { BusinessError } 14000001 - Invalid display name 1021 * @throws { BusinessError } 14000002 - Invalid uri 1022 * @throws { BusinessError } 14000003 - Invalid file extension 1023 * @throws { BusinessError } 14000004 - File has been put into trash bin 1024 * @throws { BusinessError } 14300001 - IPC error 1025 * @throws { BusinessError } 14300002 - Invalid uri 1026 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1027 * @throws { BusinessError } 14300004 - Get wrong result 1028 * @syscap SystemCapability.FileManagement.UserFileService 1029 * @systemapi 1030 * @since 9 1031 */ 1032 createFile(uri: string, displayName: string): Promise<string>; 1033 1034 /** 1035 * Create a file. 1036 * 1037 * @permission ohos.permission.FILE_ACCESS_MANAGER 1038 * @param { string } uri Represents a specific parent directory. 1039 * @param { string } displayName Indicates the new file name, and supports with suffix. 1040 * @param { AsyncCallback<string> } callback - The callback is used to return the new file's URI. 1041 * @throws { BusinessError } 13900001 - Operation not permitted 1042 * @throws { BusinessError } 13900002 - No such file or directory 1043 * @throws { BusinessError } 13900004 - Interrupted system call 1044 * @throws { BusinessError } 13900006 - No such device or address 1045 * @throws { BusinessError } 13900008 - Bad file descriptor 1046 * @throws { BusinessError } 13900011 - Out of memory 1047 * @throws { BusinessError } 13900012 - Permission denied 1048 * @throws { BusinessError } 13900013 - Bad address 1049 * @throws { BusinessError } 13900014 - Device or resource busy 1050 * @throws { BusinessError } 13900015 - File exists 1051 * @throws { BusinessError } 13900017 - No such device 1052 * @throws { BusinessError } 13900018 - Not a directory 1053 * @throws { BusinessError } 13900019 - Is a directory 1054 * @throws { BusinessError } 13900020 - Invalid argument 1055 * @throws { BusinessError } 13900022 - Too many open files 1056 * @throws { BusinessError } 13900023 - Text file busy 1057 * @throws { BusinessError } 13900024 - File too large 1058 * @throws { BusinessError } 13900025 - No space left on device 1059 * @throws { BusinessError } 13900027 - Read-only file system 1060 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1061 * @throws { BusinessError } 13900030 - File name too long 1062 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1063 * @throws { BusinessError } 13900034 - Operation would block 1064 * @throws { BusinessError } 13900038 - Value too large for defined data type 1065 * @throws { BusinessError } 13900041 - Quota exceeded 1066 * @throws { BusinessError } 13900042 - Unknown error 1067 * @throws { BusinessError } 14000001 - Invalid display name 1068 * @throws { BusinessError } 14000002 - Invalid uri 1069 * @throws { BusinessError } 14000003 - Invalid file extension 1070 * @throws { BusinessError } 14000004 - File has been put into trash bin 1071 * @throws { BusinessError } 14300001 - IPC error 1072 * @throws { BusinessError } 14300002 - Invalid uri 1073 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1074 * @throws { BusinessError } 14300004 - Get wrong result 1075 * @syscap SystemCapability.FileManagement.UserFileService 1076 * @systemapi 1077 * @since 9 1078 */ 1079 createFile(uri: string, displayName: string, callback: AsyncCallback<string>): void; 1080 1081 /** 1082 * Create a Directory. 1083 * 1084 * @permission ohos.permission.FILE_ACCESS_MANAGER 1085 * @param { string } parentUri Represents a specific parent directory. 1086 * @param { string } displayName Indicates the new directory name. 1087 * @returns { Promise<string> } Returns the new directory's URI. 1088 * @throws { BusinessError } 13900001 - Operation not permitted 1089 * @throws { BusinessError } 13900002 - No such file or directory 1090 * @throws { BusinessError } 13900004 - Interrupted system call 1091 * @throws { BusinessError } 13900006 - No such device or address 1092 * @throws { BusinessError } 13900008 - Bad file descriptor 1093 * @throws { BusinessError } 13900011 - Out of memory 1094 * @throws { BusinessError } 13900012 - Permission denied 1095 * @throws { BusinessError } 13900013 - Bad address 1096 * @throws { BusinessError } 13900014 - Device or resource busy 1097 * @throws { BusinessError } 13900015 - File exists 1098 * @throws { BusinessError } 13900017 - No such device 1099 * @throws { BusinessError } 13900018 - Not a directory 1100 * @throws { BusinessError } 13900019 - Is a directory 1101 * @throws { BusinessError } 13900020 - Invalid argument 1102 * @throws { BusinessError } 13900022 - Too many open files 1103 * @throws { BusinessError } 13900023 - Text file busy 1104 * @throws { BusinessError } 13900024 - File too large 1105 * @throws { BusinessError } 13900025 - No space left on device 1106 * @throws { BusinessError } 13900027 - Read-only file system 1107 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1108 * @throws { BusinessError } 13900030 - File name too long 1109 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1110 * @throws { BusinessError } 13900034 - Operation would block 1111 * @throws { BusinessError } 13900038 - Value too large for defined data type 1112 * @throws { BusinessError } 13900041 - Quota exceeded 1113 * @throws { BusinessError } 13900042 - Unknown error 1114 * @throws { BusinessError } 14000001 - Invalid display name 1115 * @throws { BusinessError } 14000002 - Invalid uri 1116 * @throws { BusinessError } 14000003 - Invalid file extension 1117 * @throws { BusinessError } 14000004 - File has been put into trash bin 1118 * @throws { BusinessError } 14300001 - IPC error 1119 * @throws { BusinessError } 14300002 - Invalid uri 1120 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1121 * @throws { BusinessError } 14300004 - Get wrong result 1122 * @syscap SystemCapability.FileManagement.UserFileService 1123 * @systemapi 1124 * @since 9 1125 */ 1126 mkDir(parentUri: string, displayName: string): Promise<string>; 1127 1128 /** 1129 * Create a Directory. 1130 * 1131 * @permission ohos.permission.FILE_ACCESS_MANAGER 1132 * @param { string } parentUri Represents a specific parent directory. 1133 * @param { string } displayName Indicates the new directory name. 1134 * @param { AsyncCallback<string> } callback - The callback is used to return the new directory's URI. 1135 * @throws { BusinessError } 13900001 - Operation not permitted 1136 * @throws { BusinessError } 13900002 - No such file or directory 1137 * @throws { BusinessError } 13900004 - Interrupted system call 1138 * @throws { BusinessError } 13900006 - No such device or address 1139 * @throws { BusinessError } 13900008 - Bad file descriptor 1140 * @throws { BusinessError } 13900011 - Out of memory 1141 * @throws { BusinessError } 13900012 - Permission denied 1142 * @throws { BusinessError } 13900013 - Bad address 1143 * @throws { BusinessError } 13900014 - Device or resource busy 1144 * @throws { BusinessError } 13900015 - File exists 1145 * @throws { BusinessError } 13900017 - No such device 1146 * @throws { BusinessError } 13900018 - Not a directory 1147 * @throws { BusinessError } 13900019 - Is a directory 1148 * @throws { BusinessError } 13900020 - Invalid argument 1149 * @throws { BusinessError } 13900022 - Too many open files 1150 * @throws { BusinessError } 13900023 - Text file busy 1151 * @throws { BusinessError } 13900024 - File too large 1152 * @throws { BusinessError } 13900025 - No space left on device 1153 * @throws { BusinessError } 13900027 - Read-only file system 1154 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1155 * @throws { BusinessError } 13900030 - File name too long 1156 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1157 * @throws { BusinessError } 13900034 - Operation would block 1158 * @throws { BusinessError } 13900038 - Value too large for defined data type 1159 * @throws { BusinessError } 13900041 - Quota exceeded 1160 * @throws { BusinessError } 13900042 - Unknown error 1161 * @throws { BusinessError } 14000001 - Invalid display name 1162 * @throws { BusinessError } 14000002 - Invalid uri 1163 * @throws { BusinessError } 14000003 - Invalid file extension 1164 * @throws { BusinessError } 14000004 - File has been put into trash bin 1165 * @throws { BusinessError } 14300001 - IPC error 1166 * @throws { BusinessError } 14300002 - Invalid uri 1167 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1168 * @throws { BusinessError } 14300004 - Get wrong result 1169 * @syscap SystemCapability.FileManagement.UserFileService 1170 * @systemapi 1171 * @since 9 1172 */ 1173 mkDir(parentUri: string, displayName: string, callback: AsyncCallback<string>): void; 1174 1175 /** 1176 * Delete a file or delete a directory recursively. 1177 * 1178 * @permission ohos.permission.FILE_ACCESS_MANAGER 1179 * @param { string } uri Indicates the file or directory to be deleted. 1180 * @returns { Promise<number> } 1181 * @throws { BusinessError } 13900001 - Operation not permitted 1182 * @throws { BusinessError } 13900002 - No such file or directory 1183 * @throws { BusinessError } 13900004 - Interrupted system call 1184 * @throws { BusinessError } 13900006 - No such device or address 1185 * @throws { BusinessError } 13900008 - Bad file descriptor 1186 * @throws { BusinessError } 13900011 - Out of memory 1187 * @throws { BusinessError } 13900012 - Permission denied 1188 * @throws { BusinessError } 13900013 - Bad address 1189 * @throws { BusinessError } 13900014 - Device or resource busy 1190 * @throws { BusinessError } 13900015 - File exists 1191 * @throws { BusinessError } 13900017 - No such device 1192 * @throws { BusinessError } 13900018 - Not a directory 1193 * @throws { BusinessError } 13900019 - Is a directory 1194 * @throws { BusinessError } 13900020 - Invalid argument 1195 * @throws { BusinessError } 13900022 - Too many open files 1196 * @throws { BusinessError } 13900023 - Text file busy 1197 * @throws { BusinessError } 13900024 - File too large 1198 * @throws { BusinessError } 13900025 - No space left on device 1199 * @throws { BusinessError } 13900027 - Read-only file system 1200 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1201 * @throws { BusinessError } 13900030 - File name too long 1202 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1203 * @throws { BusinessError } 13900034 - Operation would block 1204 * @throws { BusinessError } 13900038 - Value too large for defined data type 1205 * @throws { BusinessError } 13900041 - Quota exceeded 1206 * @throws { BusinessError } 13900042 - Unknown error 1207 * @throws { BusinessError } 14000001 - Invalid display name 1208 * @throws { BusinessError } 14000002 - Invalid uri 1209 * @throws { BusinessError } 14000003 - Invalid file extension 1210 * @throws { BusinessError } 14000004 - File has been put into trash bin 1211 * @throws { BusinessError } 14300001 - IPC error 1212 * @throws { BusinessError } 14300002 - Invalid uri 1213 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1214 * @throws { BusinessError } 14300004 - Get wrong result 1215 * @syscap SystemCapability.FileManagement.UserFileService 1216 * @systemapi 1217 * @since 9 1218 */ 1219 delete(uri: string): Promise<number>; 1220 1221 /** 1222 * Delete a file or delete a directory recursively. 1223 * 1224 * @permission ohos.permission.FILE_ACCESS_MANAGER 1225 * @param { string } uri Indicates the file or directory to be deleted. 1226 * @param { AsyncCallback<number> } callback 1227 * @throws { BusinessError } 13900001 - Operation not permitted 1228 * @throws { BusinessError } 13900002 - No such file or directory 1229 * @throws { BusinessError } 13900004 - Interrupted system call 1230 * @throws { BusinessError } 13900006 - No such device or address 1231 * @throws { BusinessError } 13900008 - Bad file descriptor 1232 * @throws { BusinessError } 13900011 - Out of memory 1233 * @throws { BusinessError } 13900012 - Permission denied 1234 * @throws { BusinessError } 13900013 - Bad address 1235 * @throws { BusinessError } 13900014 - Device or resource busy 1236 * @throws { BusinessError } 13900015 - File exists 1237 * @throws { BusinessError } 13900017 - No such device 1238 * @throws { BusinessError } 13900018 - Not a directory 1239 * @throws { BusinessError } 13900019 - Is a directory 1240 * @throws { BusinessError } 13900020 - Invalid argument 1241 * @throws { BusinessError } 13900022 - Too many open files 1242 * @throws { BusinessError } 13900023 - Text file busy 1243 * @throws { BusinessError } 13900024 - File too large 1244 * @throws { BusinessError } 13900025 - No space left on device 1245 * @throws { BusinessError } 13900027 - Read-only file system 1246 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1247 * @throws { BusinessError } 13900030 - File name too long 1248 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1249 * @throws { BusinessError } 13900034 - Operation would block 1250 * @throws { BusinessError } 13900038 - Value too large for defined data type 1251 * @throws { BusinessError } 13900041 - Quota exceeded 1252 * @throws { BusinessError } 13900042 - Unknown error 1253 * @throws { BusinessError } 14000001 - Invalid display name 1254 * @throws { BusinessError } 14000002 - Invalid uri 1255 * @throws { BusinessError } 14000003 - Invalid file extension 1256 * @throws { BusinessError } 14000004 - File has been put into trash bin 1257 * @throws { BusinessError } 14300001 - IPC error 1258 * @throws { BusinessError } 14300002 - Invalid uri 1259 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1260 * @throws { BusinessError } 14300004 - Get wrong result 1261 * @syscap SystemCapability.FileManagement.UserFileService 1262 * @systemapi 1263 * @since 9 1264 */ 1265 delete(uri: string, callback: AsyncCallback<number>): void; 1266 1267 /** 1268 * Move a file or move a directory recursively. 1269 * 1270 * @permission ohos.permission.FILE_ACCESS_MANAGER 1271 * @param { string } sourceFile Indicates the file or directory to be moved. 1272 * @param { string } destFile Represents the destination folder. 1273 * @returns { Promise<string> } Returns the generated new file or directory. 1274 * @throws { BusinessError } 13900001 - Operation not permitted 1275 * @throws { BusinessError } 13900002 - No such file or directory 1276 * @throws { BusinessError } 13900004 - Interrupted system call 1277 * @throws { BusinessError } 13900006 - No such device or address 1278 * @throws { BusinessError } 13900008 - Bad file descriptor 1279 * @throws { BusinessError } 13900011 - Out of memory 1280 * @throws { BusinessError } 13900012 - Permission denied 1281 * @throws { BusinessError } 13900013 - Bad address 1282 * @throws { BusinessError } 13900014 - Device or resource busy 1283 * @throws { BusinessError } 13900015 - File exists 1284 * @throws { BusinessError } 13900017 - No such device 1285 * @throws { BusinessError } 13900018 - Not a directory 1286 * @throws { BusinessError } 13900019 - Is a directory 1287 * @throws { BusinessError } 13900020 - Invalid argument 1288 * @throws { BusinessError } 13900022 - Too many open files 1289 * @throws { BusinessError } 13900023 - Text file busy 1290 * @throws { BusinessError } 13900024 - File too large 1291 * @throws { BusinessError } 13900025 - No space left on device 1292 * @throws { BusinessError } 13900027 - Read-only file system 1293 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1294 * @throws { BusinessError } 13900030 - File name too long 1295 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1296 * @throws { BusinessError } 13900034 - Operation would block 1297 * @throws { BusinessError } 13900038 - Value too large for defined data type 1298 * @throws { BusinessError } 13900041 - Quota exceeded 1299 * @throws { BusinessError } 13900042 - Unknown error 1300 * @throws { BusinessError } 14000001 - Invalid display name 1301 * @throws { BusinessError } 14000002 - Invalid uri 1302 * @throws { BusinessError } 14000003 - Invalid file extension 1303 * @throws { BusinessError } 14000004 - File has been put into trash bin 1304 * @throws { BusinessError } 14300001 - IPC error 1305 * @throws { BusinessError } 14300002 - Invalid uri 1306 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1307 * @throws { BusinessError } 14300004 - Get wrong result 1308 * @syscap SystemCapability.FileManagement.UserFileService 1309 * @systemapi 1310 * @since 9 1311 */ 1312 move(sourceFile: string, destFile: string): Promise<string>; 1313 1314 /** 1315 * Move a file or move a directory recursively. 1316 * 1317 * @permission ohos.permission.FILE_ACCESS_MANAGER 1318 * @param { string } sourceFile Indicates the file or directory to be moved. 1319 * @param { string } destFile Represents the destination folder. 1320 * @param { AsyncCallback<string> } callback - The callback is used to return the generated new file or directory. 1321 * @throws { BusinessError } 13900001 - Operation not permitted 1322 * @throws { BusinessError } 13900002 - No such file or directory 1323 * @throws { BusinessError } 13900004 - Interrupted system call 1324 * @throws { BusinessError } 13900006 - No such device or address 1325 * @throws { BusinessError } 13900008 - Bad file descriptor 1326 * @throws { BusinessError } 13900011 - Out of memory 1327 * @throws { BusinessError } 13900012 - Permission denied 1328 * @throws { BusinessError } 13900013 - Bad address 1329 * @throws { BusinessError } 13900014 - Device or resource busy 1330 * @throws { BusinessError } 13900015 - File exists 1331 * @throws { BusinessError } 13900017 - No such device 1332 * @throws { BusinessError } 13900018 - Not a directory 1333 * @throws { BusinessError } 13900019 - Is a directory 1334 * @throws { BusinessError } 13900020 - Invalid argument 1335 * @throws { BusinessError } 13900022 - Too many open files 1336 * @throws { BusinessError } 13900023 - Text file busy 1337 * @throws { BusinessError } 13900024 - File too large 1338 * @throws { BusinessError } 13900025 - No space left on device 1339 * @throws { BusinessError } 13900027 - Read-only file system 1340 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1341 * @throws { BusinessError } 13900030 - File name too long 1342 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1343 * @throws { BusinessError } 13900034 - Operation would block 1344 * @throws { BusinessError } 13900038 - Value too large for defined data type 1345 * @throws { BusinessError } 13900041 - Quota exceeded 1346 * @throws { BusinessError } 13900042 - Unknown error 1347 * @throws { BusinessError } 14000001 - Invalid display name 1348 * @throws { BusinessError } 14000002 - Invalid uri 1349 * @throws { BusinessError } 14000003 - Invalid file extension 1350 * @throws { BusinessError } 14000004 - File has been put into trash bin 1351 * @throws { BusinessError } 14300001 - IPC error 1352 * @throws { BusinessError } 14300002 - Invalid uri 1353 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1354 * @throws { BusinessError } 14300004 - Get wrong result 1355 * @syscap SystemCapability.FileManagement.UserFileService 1356 * @systemapi 1357 * @since 9 1358 */ 1359 move(sourceFile: string, destFile: string, callback: AsyncCallback<string>): void; 1360 1361 /** 1362 * Copy file or directory in the promise way. 1363 * 1364 * @permission ohos.permission.FILE_ACCESS_MANAGER 1365 * @param { string } sourceUri - Indicates the file or directory to be copied. 1366 * @param { string } destUri - Represents the destination directory. 1367 * @param { boolean } force - Optional parameter that determines whether to forcibly copy files. 1368 * @returns { Promise<Array<CopyResult>> } Returns the file information where the error occurred. 1369 * @syscap SystemCapability.FileManagement.UserFileService 1370 * @systemapi 1371 * @since 10 1372 */ 1373 copy(sourceUri: string, destUri: string, force?: boolean): Promise<Array<CopyResult>>; 1374 1375 /** 1376 * Copy file or directory in the asyncCallback way. 1377 * 1378 * @permission ohos.permission.FILE_ACCESS_MANAGER 1379 * @param { string } sourceUri - Indicates the file or directory to be copied. 1380 * @param { string } destUri - Represents the destination directory. 1381 * @param { AsyncCallback<Array<CopyResult>> } callback - The callback is used to return the file information where the error occurred. 1382 * @syscap SystemCapability.FileManagement.UserFileService 1383 * @systemapi 1384 * @since 10 1385 */ 1386 copy(sourceUri: string, destUri: string, callback: AsyncCallback<Array<CopyResult>>): void; 1387 1388 /** 1389 * Copy file or directory in the asyncCallback way. 1390 * 1391 * @permission ohos.permission.FILE_ACCESS_MANAGER 1392 * @param { string } sourceUri - Indicates the file or directory to be copied. 1393 * @param { string } destUri - Represents the destination directory. 1394 * @param { boolean } force - Determines whether to forcibly copy files. 1395 * @param { AsyncCallback<Array<CopyResult>> } callback - The callback is used to return the file information where the error occurred. 1396 * @syscap SystemCapability.FileManagement.UserFileService 1397 * @systemapi 1398 * @since 10 1399 */ 1400 copy(sourceUri: string, destUri: string, force: boolean, callback: AsyncCallback<Array<CopyResult>>): void; 1401 1402 /** 1403 * Rename the selected file or directory. 1404 * 1405 * @permission ohos.permission.FILE_ACCESS_MANAGER 1406 * @param { string } uri Indicates the selected file or directory. 1407 * @param { string } displayName Indicates the new directory or file name. 1408 * @returns { Promise<string> } Returns a URI representing the new file or directory. 1409 * @throws { BusinessError } 13900001 - Operation not permitted 1410 * @throws { BusinessError } 13900002 - No such file or directory 1411 * @throws { BusinessError } 13900004 - Interrupted system call 1412 * @throws { BusinessError } 13900006 - No such device or address 1413 * @throws { BusinessError } 13900008 - Bad file descriptor 1414 * @throws { BusinessError } 13900011 - Out of memory 1415 * @throws { BusinessError } 13900012 - Permission denied 1416 * @throws { BusinessError } 13900013 - Bad address 1417 * @throws { BusinessError } 13900014 - Device or resource busy 1418 * @throws { BusinessError } 13900015 - File exists 1419 * @throws { BusinessError } 13900017 - No such device 1420 * @throws { BusinessError } 13900018 - Not a directory 1421 * @throws { BusinessError } 13900019 - Is a directory 1422 * @throws { BusinessError } 13900020 - Invalid argument 1423 * @throws { BusinessError } 13900022 - Too many open files 1424 * @throws { BusinessError } 13900023 - Text file busy 1425 * @throws { BusinessError } 13900024 - File too large 1426 * @throws { BusinessError } 13900025 - No space left on device 1427 * @throws { BusinessError } 13900027 - Read-only file system 1428 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1429 * @throws { BusinessError } 13900030 - File name too long 1430 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1431 * @throws { BusinessError } 13900034 - Operation would block 1432 * @throws { BusinessError } 13900038 - Value too large for defined data type 1433 * @throws { BusinessError } 13900041 - Quota exceeded 1434 * @throws { BusinessError } 13900042 - Unknown error 1435 * @throws { BusinessError } 14000001 - Invalid display name 1436 * @throws { BusinessError } 14000002 - Invalid uri 1437 * @throws { BusinessError } 14000003 - Invalid file extension 1438 * @throws { BusinessError } 14000004 - File has been put into trash bin 1439 * @throws { BusinessError } 14300001 - IPC error 1440 * @throws { BusinessError } 14300002 - Invalid uri 1441 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1442 * @throws { BusinessError } 14300004 - Get wrong result 1443 * @syscap SystemCapability.FileManagement.UserFileService 1444 * @systemapi 1445 * @since 9 1446 */ 1447 rename(uri: string, displayName: string): Promise<string>; 1448 1449 /** 1450 * Rename the selected file or directory. 1451 * 1452 * @permission ohos.permission.FILE_ACCESS_MANAGER 1453 * @param { string } uri Indicates the selected file or directory. 1454 * @param { string } displayName Indicates the new directory or file name. 1455 * @param { AsyncCallback<string> } callback - The callback is used to return a URI representing the new file or directory. 1456 * @throws { BusinessError } 13900001 - Operation not permitted 1457 * @throws { BusinessError } 13900002 - No such file or directory 1458 * @throws { BusinessError } 13900004 - Interrupted system call 1459 * @throws { BusinessError } 13900006 - No such device or address 1460 * @throws { BusinessError } 13900008 - Bad file descriptor 1461 * @throws { BusinessError } 13900011 - Out of memory 1462 * @throws { BusinessError } 13900012 - Permission denied 1463 * @throws { BusinessError } 13900013 - Bad address 1464 * @throws { BusinessError } 13900014 - Device or resource busy 1465 * @throws { BusinessError } 13900015 - File exists 1466 * @throws { BusinessError } 13900017 - No such device 1467 * @throws { BusinessError } 13900018 - Not a directory 1468 * @throws { BusinessError } 13900019 - Is a directory 1469 * @throws { BusinessError } 13900020 - Invalid argument 1470 * @throws { BusinessError } 13900022 - Too many open files 1471 * @throws { BusinessError } 13900023 - Text file busy 1472 * @throws { BusinessError } 13900024 - File too large 1473 * @throws { BusinessError } 13900025 - No space left on device 1474 * @throws { BusinessError } 13900027 - Read-only file system 1475 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1476 * @throws { BusinessError } 13900030 - File name too long 1477 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1478 * @throws { BusinessError } 13900034 - Operation would block 1479 * @throws { BusinessError } 13900038 - Value too large for defined data type 1480 * @throws { BusinessError } 13900041 - Quota exceeded 1481 * @throws { BusinessError } 13900042 - Unknown error 1482 * @throws { BusinessError } 14000001 - Invalid display name 1483 * @throws { BusinessError } 14000002 - Invalid uri 1484 * @throws { BusinessError } 14000003 - Invalid file extension 1485 * @throws { BusinessError } 14000004 - File has been put into trash bin 1486 * @throws { BusinessError } 14300001 - IPC error 1487 * @throws { BusinessError } 14300002 - Invalid uri 1488 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1489 * @throws { BusinessError } 14300004 - Get wrong result 1490 * @syscap SystemCapability.FileManagement.UserFileService 1491 * @systemapi 1492 * @since 9 1493 */ 1494 rename(uri: string, displayName: string, callback: AsyncCallback<string>): void; 1495 1496 /** 1497 * Obtain the status of a file or directory. 1498 * 1499 * @permission ohos.permission.FILE_ACCESS_MANAGER 1500 * @param { string } sourceFileUri Indicates the selected file or directory. 1501 * @returns { Promise<boolean> } Returns whether it exists. 1502 * @throws { BusinessError } 13900001 - Operation not permitted 1503 * @throws { BusinessError } 13900002 - No such file or directory 1504 * @throws { BusinessError } 13900004 - Interrupted system call 1505 * @throws { BusinessError } 13900006 - No such device or address 1506 * @throws { BusinessError } 13900008 - Bad file descriptor 1507 * @throws { BusinessError } 13900011 - Out of memory 1508 * @throws { BusinessError } 13900012 - Permission denied 1509 * @throws { BusinessError } 13900013 - Bad address 1510 * @throws { BusinessError } 13900014 - Device or resource busy 1511 * @throws { BusinessError } 13900015 - File exists 1512 * @throws { BusinessError } 13900017 - No such device 1513 * @throws { BusinessError } 13900018 - Not a directory 1514 * @throws { BusinessError } 13900019 - Is a directory 1515 * @throws { BusinessError } 13900020 - Invalid argument 1516 * @throws { BusinessError } 13900022 - Too many open files 1517 * @throws { BusinessError } 13900023 - Text file busy 1518 * @throws { BusinessError } 13900024 - File too large 1519 * @throws { BusinessError } 13900025 - No space left on device 1520 * @throws { BusinessError } 13900027 - Read-only file system 1521 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1522 * @throws { BusinessError } 13900030 - File name too long 1523 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1524 * @throws { BusinessError } 13900034 - Operation would block 1525 * @throws { BusinessError } 13900038 - Value too large for defined data type 1526 * @throws { BusinessError } 13900041 - Quota exceeded 1527 * @throws { BusinessError } 13900042 - Unknown error 1528 * @throws { BusinessError } 14000001 - Invalid display name 1529 * @throws { BusinessError } 14000002 - Invalid uri 1530 * @throws { BusinessError } 14000003 - Invalid file extension 1531 * @throws { BusinessError } 14000004 - File has been put into trash bin 1532 * @throws { BusinessError } 14300001 - IPC error 1533 * @throws { BusinessError } 14300002 - Invalid uri 1534 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1535 * @throws { BusinessError } 14300004 - Get wrong result 1536 * @syscap SystemCapability.FileManagement.UserFileService 1537 * @systemapi 1538 * @since 9 1539 */ 1540 access(sourceFileUri: string): Promise<boolean>; 1541 1542 /** 1543 * Obtain the status of a file or directory. 1544 * 1545 * @permission ohos.permission.FILE_ACCESS_MANAGER 1546 * @param { string } sourceFileUri Indicates the selected file or directory. 1547 * @param { AsyncCallback<boolean> } callback - The callback is used to return whether it exists. 1548 * @throws { BusinessError } 13900001 - Operation not permitted 1549 * @throws { BusinessError } 13900002 - No such file or directory 1550 * @throws { BusinessError } 13900004 - Interrupted system call 1551 * @throws { BusinessError } 13900006 - No such device or address 1552 * @throws { BusinessError } 13900008 - Bad file descriptor 1553 * @throws { BusinessError } 13900011 - Out of memory 1554 * @throws { BusinessError } 13900012 - Permission denied 1555 * @throws { BusinessError } 13900013 - Bad address 1556 * @throws { BusinessError } 13900014 - Device or resource busy 1557 * @throws { BusinessError } 13900015 - File exists 1558 * @throws { BusinessError } 13900017 - No such device 1559 * @throws { BusinessError } 13900018 - Not a directory 1560 * @throws { BusinessError } 13900019 - Is a directory 1561 * @throws { BusinessError } 13900020 - Invalid argument 1562 * @throws { BusinessError } 13900022 - Too many open files 1563 * @throws { BusinessError } 13900023 - Text file busy 1564 * @throws { BusinessError } 13900024 - File too large 1565 * @throws { BusinessError } 13900025 - No space left on device 1566 * @throws { BusinessError } 13900027 - Read-only file system 1567 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1568 * @throws { BusinessError } 13900030 - File name too long 1569 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1570 * @throws { BusinessError } 13900034 - Operation would block 1571 * @throws { BusinessError } 13900038 - Value too large for defined data type 1572 * @throws { BusinessError } 13900041 - Quota exceeded 1573 * @throws { BusinessError } 13900042 - Unknown error 1574 * @throws { BusinessError } 14000001 - Invalid display name 1575 * @throws { BusinessError } 14000002 - Invalid uri 1576 * @throws { BusinessError } 14000003 - Invalid file extension 1577 * @throws { BusinessError } 14000004 - File has been put into trash bin 1578 * @throws { BusinessError } 14300001 - IPC error 1579 * @throws { BusinessError } 14300002 - Invalid uri 1580 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1581 * @throws { BusinessError } 14300004 - Get wrong result 1582 * @syscap SystemCapability.FileManagement.UserFileService 1583 * @systemapi 1584 * @since 9 1585 */ 1586 access(sourceFileUri: string, callback: AsyncCallback<boolean>): void; 1587 1588 /** 1589 * Query file related information by the uri in the promise way. 1590 * 1591 * @permission ohos.permission.FILE_ACCESS_MANAGER 1592 * @param { string } uri - Indicates the selected file or directory. 1593 * @param { string } metaJson The json string includes query property. 1594 * @returns { Promise<string> } Returns the json string, includes query property and value. 1595 * @syscap SystemCapability.FileManagement.UserFileService 1596 * @systemapi 1597 * @since 10 1598 */ 1599 query(uri: string, metaJson: string): Promise<string>; 1600 1601 /** 1602 * Query file related information by the uri in the asyncCallback way. 1603 * 1604 * @permission ohos.permission.FILE_ACCESS_MANAGER 1605 * @param { string } uri - Indicates the selected file or directory. 1606 * @param { string } metaJson The json string includes query property. 1607 * @param { AsyncCallback<string> } callback - Returns the json string, includes query property and value. 1608 * @syscap SystemCapability.FileManagement.UserFileService 1609 * @systemapi 1610 * @since 10 1611 */ 1612 query(uri: string, metaJson: string, callback: AsyncCallback<string>): void; 1613 1614 /** 1615 * Get a FileInfo by the uri in the promise way. 1616 * 1617 * @permission ohos.permission.FILE_ACCESS_MANAGER 1618 * @param { string } uri - Indicates the selected file or directory. 1619 * @returns { Promise<FileInfo> } Returns a FileInfo. 1620 * @syscap SystemCapability.FileManagement.UserFileService 1621 * @systemapi 1622 * @since 10 1623 */ 1624 getFileInfoFromUri(uri: string): Promise<FileInfo>; 1625 1626 /** 1627 * Get a FileInfo by the uri in the asyncCallback way. 1628 * 1629 * @permission ohos.permission.FILE_ACCESS_MANAGER 1630 * @param { string } uri - Indicates the selected file or directory. 1631 * @param { AsyncCallback<FileInfo> } callback - The callback is used to return a fileinfo object. 1632 * @syscap SystemCapability.FileManagement.UserFileService 1633 * @systemapi 1634 * @since 10 1635 */ 1636 getFileInfoFromUri(uri: string, callback: AsyncCallback<FileInfo>): void; 1637 1638 /** 1639 * Get a FileInfo by the relative path in the promise way. 1640 * 1641 * @permission ohos.permission.FILE_ACCESS_MANAGER 1642 * @param { string } relativePath - Indicates the selected file or directory. 1643 * @returns { Promise<FileInfo> } Returns a FileInfo. 1644 * @syscap SystemCapability.FileManagement.UserFileService 1645 * @systemapi 1646 * @since 10 1647 */ 1648 getFileInfoFromRelativePath(relativePath: string): Promise<FileInfo>; 1649 1650 /** 1651 * Get a FileInfo by the relative path in the asyncCallback way. 1652 * 1653 * @permission ohos.permission.FILE_ACCESS_MANAGER 1654 * @param { string } relativePath - Indicates the selected file or directory. 1655 * @param { AsyncCallback<FileInfo> } callback - The callback is used to return a fileinfo object. 1656 * @syscap SystemCapability.FileManagement.UserFileService 1657 * @systemapi 1658 * @since 10 1659 */ 1660 getFileInfoFromRelativePath(relativePath: string, callback: AsyncCallback<FileInfo>): void; 1661 1662 /** 1663 * Get a RootIterator. 1664 * 1665 * @permission ohos.permission.FILE_ACCESS_MANAGER 1666 * @returns { Promise<RootIterator> } Returns a RootIterator. 1667 * @throws { BusinessError } 13900001 - Operation not permitted 1668 * @throws { BusinessError } 13900002 - No such file or directory 1669 * @throws { BusinessError } 13900004 - Interrupted system call 1670 * @throws { BusinessError } 13900006 - No such device or address 1671 * @throws { BusinessError } 13900008 - Bad file descriptor 1672 * @throws { BusinessError } 13900011 - Out of memory 1673 * @throws { BusinessError } 13900012 - Permission denied 1674 * @throws { BusinessError } 13900013 - Bad address 1675 * @throws { BusinessError } 13900014 - Device or resource busy 1676 * @throws { BusinessError } 13900015 - File exists 1677 * @throws { BusinessError } 13900017 - No such device 1678 * @throws { BusinessError } 13900018 - Not a directory 1679 * @throws { BusinessError } 13900019 - Is a directory 1680 * @throws { BusinessError } 13900020 - Invalid argument 1681 * @throws { BusinessError } 13900022 - Too many open files 1682 * @throws { BusinessError } 13900023 - Text file busy 1683 * @throws { BusinessError } 13900024 - File too large 1684 * @throws { BusinessError } 13900025 - No space left on device 1685 * @throws { BusinessError } 13900027 - Read-only file system 1686 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1687 * @throws { BusinessError } 13900030 - File name too long 1688 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1689 * @throws { BusinessError } 13900034 - Operation would block 1690 * @throws { BusinessError } 13900038 - Value too large for defined data type 1691 * @throws { BusinessError } 13900041 - Quota exceeded 1692 * @throws { BusinessError } 13900042 - Unknown error 1693 * @throws { BusinessError } 14000001 - Invalid display name 1694 * @throws { BusinessError } 14000002 - Invalid uri 1695 * @throws { BusinessError } 14000003 - Invalid file extension 1696 * @throws { BusinessError } 14000004 - File has been put into trash bin 1697 * @throws { BusinessError } 14300001 - IPC error 1698 * @throws { BusinessError } 14300002 - Invalid uri 1699 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1700 * @throws { BusinessError } 14300004 - Get wrong result 1701 * @syscap SystemCapability.FileManagement.UserFileService 1702 * @systemapi 1703 * @since 9 1704 */ 1705 getRoots(): Promise<RootIterator>; 1706 1707 /** 1708 * Get a RootIterator. 1709 * 1710 * @permission ohos.permission.FILE_ACCESS_MANAGER 1711 * @param { AsyncCallback<RootIterator> } callback - The callback is used to return a RootIterator. 1712 * @throws { BusinessError } 13900001 - Operation not permitted 1713 * @throws { BusinessError } 13900002 - No such file or directory 1714 * @throws { BusinessError } 13900004 - Interrupted system call 1715 * @throws { BusinessError } 13900006 - No such device or address 1716 * @throws { BusinessError } 13900008 - Bad file descriptor 1717 * @throws { BusinessError } 13900011 - Out of memory 1718 * @throws { BusinessError } 13900012 - Permission denied 1719 * @throws { BusinessError } 13900013 - Bad address 1720 * @throws { BusinessError } 13900014 - Device or resource busy 1721 * @throws { BusinessError } 13900015 - File exists 1722 * @throws { BusinessError } 13900017 - No such device 1723 * @throws { BusinessError } 13900018 - Not a directory 1724 * @throws { BusinessError } 13900019 - Is a directory 1725 * @throws { BusinessError } 13900020 - Invalid argument 1726 * @throws { BusinessError } 13900022 - Too many open files 1727 * @throws { BusinessError } 13900023 - Text file busy 1728 * @throws { BusinessError } 13900024 - File too large 1729 * @throws { BusinessError } 13900025 - No space left on device 1730 * @throws { BusinessError } 13900027 - Read-only file system 1731 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1732 * @throws { BusinessError } 13900030 - File name too long 1733 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1734 * @throws { BusinessError } 13900034 - Operation would block 1735 * @throws { BusinessError } 13900038 - Value too large for defined data type 1736 * @throws { BusinessError } 13900041 - Quota exceeded 1737 * @throws { BusinessError } 13900042 - Unknown error 1738 * @throws { BusinessError } 14000001 - Invalid display name 1739 * @throws { BusinessError } 14000002 - Invalid uri 1740 * @throws { BusinessError } 14000003 - Invalid file extension 1741 * @throws { BusinessError } 14000004 - File has been put into trash bin 1742 * @throws { BusinessError } 14300001 - IPC error 1743 * @throws { BusinessError } 14300002 - Invalid uri 1744 * @throws { BusinessError } 14300003 - Fail to get fileextension info 1745 * @throws { BusinessError } 14300004 - Get wrong result 1746 * @syscap SystemCapability.FileManagement.UserFileService 1747 * @systemapi 1748 * @since 9 1749 */ 1750 getRoots(callback: AsyncCallback<RootIterator>): void; 1751 1752 /** 1753 * Turn on monitor the specified uri. 1754 * 1755 * @permission ohos.permission.FILE_ACCESS_MANAGER 1756 * @param { string } uri - Indicates the file or directory to be monitored. 1757 * @param { boolean } notifyForDescendants - Indicates Whether to monitor changes in descendants. 1758 * @param { Callback<NotifyMessage> } callback - The callback is used to return the notify message. 1759 * @throws { BusinessError } 14300002 - Invalid uri 1760 * @syscap SystemCapability.FileManagement.UserFileService 1761 * @systemapi 1762 * @since 10 1763 */ 1764 registerObserver(uri: string, notifyForDescendants: boolean, callback: Callback<NotifyMessage>): void; 1765 1766 /** 1767 * Turn off monitor the specified uri. 1768 * 1769 * @permission ohos.permission.FILE_ACCESS_MANAGER 1770 * @param { string } uri - Indicates the file or directory the file that will cancel monitored. 1771 * @param { Callback<NotifyMessage> } callback - The object bound to the uri. 1772 * @throws { BusinessError } 14300002 - Invalid uri 1773 * @syscap SystemCapability.FileManagement.UserFileService 1774 * @systemapi 1775 * @since 10 1776 */ 1777 unregisterObserver(uri: string, callback?: Callback<NotifyMessage>): void; 1778 } 1779} 1780 1781export default fileAccess; 1782