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 { AsyncCallback } from './@ohos.base'; 22import stream from './@ohos.util.stream'; 23 24export default fileIo; 25 26/** 27 * FileIO 28 * 29 * @namespace fileIo 30 * @syscap SystemCapability.FileManagement.File.FileIO 31 * @since 9 32 */ 33/** 34 * FileIO 35 * 36 * @namespace fileIo 37 * @syscap SystemCapability.FileManagement.File.FileIO 38 * @crossplatform 39 * @since 10 40 */ 41/** 42 * FileIO 43 * 44 * @namespace fileIo 45 * @syscap SystemCapability.FileManagement.File.FileIO 46 * @crossplatform 47 * @atomicservice 48 * @since 11 49 */ 50/** 51 * FileIO 52 * 53 * @namespace fileIo 54 * @syscap SystemCapability.FileManagement.File.FileIO 55 * @crossplatform 56 * @atomicservice 57 * @since 12 58 */ 59declare namespace fileIo { 60 61 export { access }; 62 63 export { accessSync }; 64 65 export { close }; 66 67 export { closeSync }; 68 69 export { copy }; 70 71 export { copyDir }; 72 73 export { copyDirSync }; 74 75 export { copyFile }; 76 77 export { copyFileSync }; 78 79 export { createRandomAccessFile }; 80 81 export { createRandomAccessFileSync }; 82 83 export { createStream }; 84 85 export { createStreamSync }; 86 87 export { createReadStream }; 88 89 export { createWriteStream }; 90 91 export { createWatcher }; 92 93 export { dup }; 94 95 export { fdatasync }; 96 97 export { fdatasyncSync }; 98 99 export { fdopenStream }; 100 101 export { fdopenStreamSync }; 102 103 export { fsync }; 104 105 export { fsyncSync }; 106 107 export { getxattr }; 108 109 export { getxattrSync }; 110 111 export { listFile }; 112 113 export { listFileSync }; 114 115 export { lseek }; 116 117 export { lstat }; 118 119 export { lstatSync }; 120 121 export { mkdir }; 122 123 export { mkdirSync }; 124 125 export { mkdtemp }; 126 127 export { mkdtempSync }; 128 129 export { moveDir }; 130 131 export { moveDirSync }; 132 133 export { moveFile }; 134 135 export { moveFileSync }; 136 137 export { open }; 138 139 export { openSync }; 140 141 export { read }; 142 143 export { readSync }; 144 145 export { readLines }; 146 147 export { readLinesSync }; 148 149 export { readText }; 150 151 export { readTextSync }; 152 153 export { rename }; 154 155 export { renameSync }; 156 157 export { rmdir }; 158 159 export { rmdirSync }; 160 161 export { setxattr }; 162 163 export { setxattrSync }; 164 165 export { stat }; 166 167 export { statSync }; 168 169 export { symlink }; 170 171 export { symlinkSync }; 172 173 export { truncate }; 174 175 export { truncateSync }; 176 177 export { unlink }; 178 179 export { unlinkSync }; 180 181 export { utimes }; 182 183 export { write }; 184 185 export { writeSync }; 186 187 export { AccessModeType }; 188 189 export { AccessFlagType }; 190 191 export { File }; 192 193 export { OpenMode }; 194 195 export { RandomAccessFile }; 196 197 export { ReaderIterator }; 198 199 export { Stat }; 200 201 export { Stream }; 202 203 export { ReadStream }; 204 205 export { WriteStream }; 206 207 export { AtomicFile }; 208 209 export { Watcher }; 210 211 export { WhenceType }; 212 213 export { TaskSignal }; 214 215 export { connectDfs }; 216 217 export { disconnectDfs }; 218 219 export type { Progress }; 220 221 export type { CopyOptions }; 222 223 export type { ProgressListener }; 224 225 export type { DfsListeners }; 226 227 /** 228 * Mode Indicates the open flags. 229 * 230 * @namespace OpenMode 231 * @syscap SystemCapability.FileManagement.File.FileIO 232 * @since 9 233 */ 234 /** 235 * Mode Indicates the open flags. 236 * 237 * @namespace OpenMode 238 * @syscap SystemCapability.FileManagement.File.FileIO 239 * @crossplatform 240 * @since 10 241 */ 242 /** 243 * Mode Indicates the open flags. 244 * 245 * @namespace OpenMode 246 * @syscap SystemCapability.FileManagement.File.FileIO 247 * @crossplatform 248 * @atomicservice 249 * @since 11 250 */ 251 namespace OpenMode { 252 /** 253 * Read only Permission. 254 * 255 * @constant 256 * @syscap SystemCapability.FileManagement.File.FileIO 257 * @since 9 258 */ 259 /** 260 * Read only Permission. 261 * 262 * @constant 263 * @syscap SystemCapability.FileManagement.File.FileIO 264 * @crossplatform 265 * @since 10 266 */ 267 /** 268 * Read only Permission. 269 * 270 * @constant 271 * @syscap SystemCapability.FileManagement.File.FileIO 272 * @crossplatform 273 * @atomicservice 274 * @since 11 275 */ 276 const READ_ONLY = 0o0; 277 /** 278 * Write only Permission. 279 * 280 * @constant 281 * @syscap SystemCapability.FileManagement.File.FileIO 282 * @since 9 283 */ 284 /** 285 * Write only Permission. 286 * 287 * @constant 288 * @syscap SystemCapability.FileManagement.File.FileIO 289 * @crossplatform 290 * @since 10 291 */ 292 /** 293 * Write only Permission. 294 * 295 * @constant 296 * @syscap SystemCapability.FileManagement.File.FileIO 297 * @crossplatform 298 * @atomicservice 299 * @since 11 300 */ 301 const WRITE_ONLY = 0o1; 302 /** 303 * Write and Read Permission. 304 * 305 * @constant 306 * @syscap SystemCapability.FileManagement.File.FileIO 307 * @since 9 308 */ 309 /** 310 * Write and Read Permission. 311 * 312 * @constant 313 * @syscap SystemCapability.FileManagement.File.FileIO 314 * @crossplatform 315 * @since 10 316 */ 317 /** 318 * Write and Read Permission. 319 * 320 * @constant 321 * @syscap SystemCapability.FileManagement.File.FileIO 322 * @crossplatform 323 * @atomicservice 324 * @since 11 325 */ 326 const READ_WRITE = 0o2; 327 /** 328 * If not exist, create file. 329 * 330 * @constant 331 * @syscap SystemCapability.FileManagement.File.FileIO 332 * @since 9 333 */ 334 /** 335 * If not exist, create file. 336 * 337 * @constant 338 * @syscap SystemCapability.FileManagement.File.FileIO 339 * @crossplatform 340 * @since 10 341 */ 342 /** 343 * If not exist, create file. 344 * 345 * @constant 346 * @syscap SystemCapability.FileManagement.File.FileIO 347 * @crossplatform 348 * @atomicservice 349 * @since 11 350 */ 351 const CREATE = 0o100; 352 /** 353 * File truncate len 0. 354 * 355 * @constant 356 * @syscap SystemCapability.FileManagement.File.FileIO 357 * @since 9 358 */ 359 /** 360 * File truncate len 0. 361 * 362 * @constant 363 * @syscap SystemCapability.FileManagement.File.FileIO 364 * @crossplatform 365 * @since 10 366 */ 367 /** 368 * File truncate len 0. 369 * 370 * @constant 371 * @syscap SystemCapability.FileManagement.File.FileIO 372 * @crossplatform 373 * @atomicservice 374 * @since 11 375 */ 376 const TRUNC = 0o1000; 377 /** 378 * File append write. 379 * 380 * @constant 381 * @syscap SystemCapability.FileManagement.File.FileIO 382 * @since 9 383 */ 384 /** 385 * File append write. 386 * 387 * @constant 388 * @syscap SystemCapability.FileManagement.File.FileIO 389 * @crossplatform 390 * @since 10 391 */ 392 /** 393 * File append write. 394 * 395 * @constant 396 * @syscap SystemCapability.FileManagement.File.FileIO 397 * @crossplatform 398 * @atomicservice 399 * @since 11 400 */ 401 const APPEND = 0o2000; 402 /** 403 * File open in nonblocking mode. 404 * 405 * @constant 406 * @syscap SystemCapability.FileManagement.File.FileIO 407 * @since 9 408 */ 409 /** 410 * File open in nonblocking mode. 411 * 412 * @constant 413 * @syscap SystemCapability.FileManagement.File.FileIO 414 * @crossplatform 415 * @since 10 416 */ 417 const NONBLOCK = 0o4000; 418 /** 419 * File is Dir. 420 * 421 * @constant 422 * @syscap SystemCapability.FileManagement.File.FileIO 423 * @since 9 424 */ 425 /** 426 * File is Dir. 427 * 428 * @constant 429 * @syscap SystemCapability.FileManagement.File.FileIO 430 * @crossplatform 431 * @since 10 432 */ 433 const DIR = 0o200000; 434 /** 435 * File is not symbolic link. 436 * 437 * @constant 438 * @syscap SystemCapability.FileManagement.File.FileIO 439 * @since 9 440 */ 441 /** 442 * File is not symbolic link. 443 * 444 * @constant 445 * @syscap SystemCapability.FileManagement.File.FileIO 446 * @crossplatform 447 * @since 10 448 */ 449 const NOFOLLOW = 0o400000; 450 /** 451 * SYNC IO. 452 * 453 * @constant 454 * @syscap SystemCapability.FileManagement.File.FileIO 455 * @since 9 456 */ 457 /** 458 * SYNC IO. 459 * 460 * @constant 461 * @syscap SystemCapability.FileManagement.File.FileIO 462 * @crossplatform 463 * @since 10 464 */ 465 const SYNC = 0o4010000; 466 } 467} 468 469/** 470 * Access file. 471 * 472 * @param { string } path - path. 473 * @returns { Promise<boolean> } return Promise 474 * @throws { BusinessError } 13900002 - No such file or directory 475 * @throws { BusinessError } 13900005 - I/O error 476 * @throws { BusinessError } 13900008 - Bad file descriptor 477 * @throws { BusinessError } 13900011 - Out of memory 478 * @throws { BusinessError } 13900012 - Permission denied 479 * @throws { BusinessError } 13900013 - Bad address 480 * @throws { BusinessError } 13900018 - Not a directory 481 * @throws { BusinessError } 13900020 - Invalid argument 482 * @throws { BusinessError } 13900023 - Text file busy 483 * @throws { BusinessError } 13900030 - File name too long 484 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 485 * @throws { BusinessError } 13900042 - Unknown error 486 * @syscap SystemCapability.FileManagement.File.FileIO 487 * @since 9 488 */ 489/** 490 * Access file. 491 * 492 * @param { string } path - path. 493 * @returns { Promise<boolean> } Returns the file is accessible or not in promise mode. 494 * @throws { BusinessError } 13900002 - No such file or directory 495 * @throws { BusinessError } 13900005 - I/O error 496 * @throws { BusinessError } 13900008 - Bad file descriptor 497 * @throws { BusinessError } 13900011 - Out of memory 498 * @throws { BusinessError } 13900012 - Permission denied 499 * @throws { BusinessError } 13900013 - Bad address 500 * @throws { BusinessError } 13900018 - Not a directory 501 * @throws { BusinessError } 13900020 - Invalid argument 502 * @throws { BusinessError } 13900023 - Text file busy 503 * @throws { BusinessError } 13900030 - File name too long 504 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 505 * @throws { BusinessError } 13900042 - Unknown error 506 * @syscap SystemCapability.FileManagement.File.FileIO 507 * @crossplatform 508 * @since 10 509 */ 510/** 511 * Access file. 512 * 513 * @param { string } path - path. 514 * @returns { Promise<boolean> } Returns the file is accessible or not in promise mode. 515 * @throws { BusinessError } 13900002 - No such file or directory 516 * @throws { BusinessError } 13900005 - I/O error 517 * @throws { BusinessError } 13900008 - Bad file descriptor 518 * @throws { BusinessError } 13900011 - Out of memory 519 * @throws { BusinessError } 13900012 - Permission denied 520 * @throws { BusinessError } 13900013 - Bad address 521 * @throws { BusinessError } 13900018 - Not a directory 522 * @throws { BusinessError } 13900020 - Invalid argument 523 * @throws { BusinessError } 13900023 - Text file busy 524 * @throws { BusinessError } 13900030 - File name too long 525 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 526 * @throws { BusinessError } 13900042 - Unknown error 527 * @syscap SystemCapability.FileManagement.File.FileIO 528 * @crossplatform 529 * @atomicservice 530 * @since 11 531 */ 532/** 533 * Checks whether the file or directory exists or has the operation permission. 534 * This API uses a promise to return the result. 535 * If the read, write, or read and write permission verification fails, 536 * the error code 13900012 (Permission denied) will be thrown. 537 * 538 * @param { string } path - Application sandbox path of the file to check. 539 * @param { AccessModeType } [mode = fs.AccessModeType.EXIST] - Permission on the file to verify. 540 * <br>If this parameter is left blank, the system checks whether the file exists. 541 * @returns { Promise<boolean> } Promise used to return a Boolean value. 542 * <br>Returns true if the file exists; returns false otherwise. 543 * @throws { BusinessError } 13900002 - No such file or directory 544 * @throws { BusinessError } 13900005 - I/O error 545 * @throws { BusinessError } 13900008 - Bad file descriptor 546 * @throws { BusinessError } 13900011 - Out of memory 547 * @throws { BusinessError } 13900012 - Permission denied 548 * @throws { BusinessError } 13900013 - Bad address 549 * @throws { BusinessError } 13900018 - Not a directory 550 * @throws { BusinessError } 13900020 - Invalid argument 551 * @throws { BusinessError } 13900023 - Text file busy 552 * @throws { BusinessError } 13900030 - File name too long 553 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 554 * @throws { BusinessError } 13900042 - Unknown error 555 * @syscap SystemCapability.FileManagement.File.FileIO 556 * @crossplatform 557 * @atomicservice 558 * @since 12 559 */ 560declare function access(path: string, mode?: AccessModeType): Promise<boolean>; 561 562/** 563 * Access file. 564 * 565 * @param { string } path - path. 566 * @param { AsyncCallback<boolean> } callback - The callback is used to return the file is accessible or not. 567 * @throws { BusinessError } 13900002 - No such file or directory 568 * @throws { BusinessError } 13900005 - I/O error 569 * @throws { BusinessError } 13900008 - Bad file descriptor 570 * @throws { BusinessError } 13900011 - Out of memory 571 * @throws { BusinessError } 13900012 - Permission denied 572 * @throws { BusinessError } 13900013 - Bad address 573 * @throws { BusinessError } 13900018 - Not a directory 574 * @throws { BusinessError } 13900020 - Invalid argument 575 * @throws { BusinessError } 13900023 - Text file busy 576 * @throws { BusinessError } 13900030 - File name too long 577 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 578 * @throws { BusinessError } 13900042 - Unknown error 579 * @syscap SystemCapability.FileManagement.File.FileIO 580 * @since 9 581 */ 582/** 583 * Access file. 584 * 585 * @param { string } path - path. 586 * @param { AsyncCallback<boolean> } callback - The callback is used to return the file is accessible or not. 587 * @throws { BusinessError } 13900002 - No such file or directory 588 * @throws { BusinessError } 13900005 - I/O error 589 * @throws { BusinessError } 13900008 - Bad file descriptor 590 * @throws { BusinessError } 13900011 - Out of memory 591 * @throws { BusinessError } 13900012 - Permission denied 592 * @throws { BusinessError } 13900013 - Bad address 593 * @throws { BusinessError } 13900018 - Not a directory 594 * @throws { BusinessError } 13900020 - Invalid argument 595 * @throws { BusinessError } 13900023 - Text file busy 596 * @throws { BusinessError } 13900030 - File name too long 597 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 598 * @throws { BusinessError } 13900042 - Unknown error 599 * @syscap SystemCapability.FileManagement.File.FileIO 600 * @crossplatform 601 * @since 10 602 */ 603/** 604 * Checks whether a file or directory exists. This API uses an asynchronous callback to return the result. 605 * 606 * @param { string } path - Application sandbox path of the file to check. 607 * @param { AsyncCallback<boolean> } callback - Callback invoked to return the result. 608 * <br>The value true means the file exists; the value false means the opposite. 609 * @throws { BusinessError } 13900002 - No such file or directory 610 * @throws { BusinessError } 13900005 - I/O error 611 * @throws { BusinessError } 13900008 - Bad file descriptor 612 * @throws { BusinessError } 13900011 - Out of memory 613 * @throws { BusinessError } 13900012 - Permission denied 614 * @throws { BusinessError } 13900013 - Bad address 615 * @throws { BusinessError } 13900018 - Not a directory 616 * @throws { BusinessError } 13900020 - Invalid argument 617 * @throws { BusinessError } 13900023 - Text file busy 618 * @throws { BusinessError } 13900030 - File name too long 619 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 620 * @throws { BusinessError } 13900042 - Unknown error 621 * @syscap SystemCapability.FileManagement.File.FileIO 622 * @crossplatform 623 * @atomicservice 624 * @since 11 625 */ 626declare function access(path: string, callback: AsyncCallback<boolean>): void; 627 628/** 629 * Checks whether the file or directory is stored locally or has the operation permission. 630 * This API uses a promise to return the result.If the read, write, or read and write permission verification fails, 631 * the error code 13900012 (Permission denied) will be thrown. 632 * 633 * @param { string } path - Application sandbox path of the file to check. 634 * @param { AccessModeType } mode - Permission on the file to verify. 635 * @param { AccessFlagType } flag - Location of the file to verify. 636 * @returns { Promise<boolean> } Promise used to return a Boolean value. 637 * <br>The value true means the file is a local file and has the related permission. 638 * <br>The value false means the file does not exist or is on the cloud or a distributed device. 639 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 640 * <br>2.Incorrect parameter types. 641 * @throws { BusinessError } 13900005 - I/O error 642 * @throws { BusinessError } 13900011 - Out of memory 643 * @throws { BusinessError } 13900012 - Permission denied 644 * @throws { BusinessError } 13900013 - Bad address 645 * @throws { BusinessError } 13900018 - Not a directory 646 * @throws { BusinessError } 13900020 - Invalid argument 647 * @throws { BusinessError } 13900023 - Text file busy 648 * @throws { BusinessError } 13900030 - File name too long 649 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 650 * @syscap SystemCapability.FileManagement.File.FileIO 651 * @since 12 652 */ 653declare function access(path: string, mode: AccessModeType, flag: AccessFlagType): Promise<boolean>; 654 655/** 656 * Access file with sync interface. 657 * 658 * @param { string } path - path. 659 * @returns { boolean } Returns the file is accessible or not. 660 * @throws { BusinessError } 13900002 - No such file or directory 661 * @throws { BusinessError } 13900005 - I/O error 662 * @throws { BusinessError } 13900008 - Bad file descriptor 663 * @throws { BusinessError } 13900011 - Out of memory 664 * @throws { BusinessError } 13900012 - Permission denied 665 * @throws { BusinessError } 13900013 - Bad address 666 * @throws { BusinessError } 13900018 - Not a directory 667 * @throws { BusinessError } 13900020 - Invalid argument 668 * @throws { BusinessError } 13900023 - Text file busy 669 * @throws { BusinessError } 13900030 - File name too long 670 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 671 * @throws { BusinessError } 13900042 - Unknown error 672 * @syscap SystemCapability.FileManagement.File.FileIO 673 * @since 9 674 */ 675/** 676 * Access file with sync interface. 677 * 678 * @param { string } path - path. 679 * @returns { boolean } Returns the file is accessible or not. 680 * @throws { BusinessError } 13900002 - No such file or directory 681 * @throws { BusinessError } 13900005 - I/O error 682 * @throws { BusinessError } 13900008 - Bad file descriptor 683 * @throws { BusinessError } 13900011 - Out of memory 684 * @throws { BusinessError } 13900012 - Permission denied 685 * @throws { BusinessError } 13900013 - Bad address 686 * @throws { BusinessError } 13900018 - Not a directory 687 * @throws { BusinessError } 13900020 - Invalid argument 688 * @throws { BusinessError } 13900023 - Text file busy 689 * @throws { BusinessError } 13900030 - File name too long 690 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 691 * @throws { BusinessError } 13900042 - Unknown error 692 * @syscap SystemCapability.FileManagement.File.FileIO 693 * @crossplatform 694 * @since 10 695 */ 696/** 697 * Access file with sync interface. 698 * 699 * @param { string } path - path. 700 * @returns { boolean } Returns the file is accessible or not. 701 * @throws { BusinessError } 13900002 - No such file or directory 702 * @throws { BusinessError } 13900005 - I/O error 703 * @throws { BusinessError } 13900008 - Bad file descriptor 704 * @throws { BusinessError } 13900011 - Out of memory 705 * @throws { BusinessError } 13900012 - Permission denied 706 * @throws { BusinessError } 13900013 - Bad address 707 * @throws { BusinessError } 13900018 - Not a directory 708 * @throws { BusinessError } 13900020 - Invalid argument 709 * @throws { BusinessError } 13900023 - Text file busy 710 * @throws { BusinessError } 13900030 - File name too long 711 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 712 * @throws { BusinessError } 13900042 - Unknown error 713 * @syscap SystemCapability.FileManagement.File.FileIO 714 * @crossplatform 715 * @atomicservice 716 * @since 11 717 */ 718/** 719 * 720 * Checks whether a file or directory exists or has the operation permission. 721 * This API returns the result synchronously.If the read, write, or read and write permission verification fails, 722 * the error code 13900012 (Permission denied) will be thrown. 723 * 724 * @param { string } path - Application sandbox path of the file to check. 725 * @param { AccessModeType } [mode = fs.AccessModeType.EXIST] - Permission on the file to verify. 726 * <br>If this parameter is left blank, the system checks whether the file exists. 727 * @returns { boolean } Returns true if the file exists; returns false otherwise. 728 * @throws { BusinessError } 13900002 - No such file or directory 729 * @throws { BusinessError } 13900005 - I/O error 730 * @throws { BusinessError } 13900008 - Bad file descriptor 731 * @throws { BusinessError } 13900011 - Out of memory 732 * @throws { BusinessError } 13900012 - Permission denied 733 * @throws { BusinessError } 13900013 - Bad address 734 * @throws { BusinessError } 13900018 - Not a directory 735 * @throws { BusinessError } 13900020 - Invalid argument 736 * @throws { BusinessError } 13900023 - Text file busy 737 * @throws { BusinessError } 13900030 - File name too long 738 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 739 * @throws { BusinessError } 13900042 - Unknown error 740 * @syscap SystemCapability.FileManagement.File.FileIO 741 * @crossplatform 742 * @atomicservice 743 * @since 12 744 */ 745declare function accessSync(path: string, mode?: AccessModeType): boolean; 746 747/** 748 * Checks whether a file or directory is stored locally or has the operation permission. This API returns the result synchronously. 749 * If the read, write, or read and write permission verification fails, 750 * the error code 13900012 (Permission denied) will be thrown. 751 * 752 * @param { string } path - Application sandbox path of the file to check. 753 * @param { AccessModeType } mode - Permission on the file to verify. 754 * @param { AccessFlagType } flag - Location of the file to verify. 755 * @returns { boolean } Returns true if the file is a local file and has the related permission; 756 * <br>returns false if the file does not exist or is on the cloud or a distributed device. 757 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 758 * <br>2.Incorrect parameter types. 759 * @throws { BusinessError } 13900005 - I/O error 760 * @throws { BusinessError } 13900011 - Out of memory 761 * @throws { BusinessError } 13900012 - Permission denied 762 * @throws { BusinessError } 13900013 - Bad address 763 * @throws { BusinessError } 13900018 - Not a directory 764 * @throws { BusinessError } 13900020 - Invalid argument 765 * @throws { BusinessError } 13900023 - Text file busy 766 * @throws { BusinessError } 13900030 - File name too long 767 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 768 * @syscap SystemCapability.FileManagement.File.FileIO 769 * @since 12 770 */ 771declare function accessSync(path: string, mode: AccessModeType, flag: AccessFlagType): boolean; 772 773/** 774 * Close file or fd. 775 * 776 * @param { number | File } file - file object or fd. 777 * @returns { Promise<void> } The promise returned by the function. 778 * @throws { BusinessError } 13900004 - Interrupted system call 779 * @throws { BusinessError } 13900005 - I/O error 780 * @throws { BusinessError } 13900008 - Bad file descriptor 781 * @throws { BusinessError } 13900025 - No space left on device 782 * @throws { BusinessError } 13900041 - Quota exceeded 783 * @throws { BusinessError } 13900042 - Unknown error 784 * @syscap SystemCapability.FileManagement.File.FileIO 785 * @since 9 786 */ 787/** 788 * Close file or fd. 789 * 790 * @param { number | File } file - file object or fd. 791 * @returns { Promise<void> } The promise returned by the function. 792 * @throws { BusinessError } 13900004 - Interrupted system call 793 * @throws { BusinessError } 13900005 - I/O error 794 * @throws { BusinessError } 13900008 - Bad file descriptor 795 * @throws { BusinessError } 13900025 - No space left on device 796 * @throws { BusinessError } 13900041 - Quota exceeded 797 * @throws { BusinessError } 13900042 - Unknown error 798 * @syscap SystemCapability.FileManagement.File.FileIO 799 * @crossplatform 800 * @since 10 801 */ 802/** 803 * Closes a file or directory. This API uses a promise to return the result. 804 * 805 * @param { number | File } file - File object or FD of the file to close. 806 * <br>Once closed, the File object or FD cannot be used for read or write operations. 807 * @returns { Promise<void> } Promise that returns no value. 808 * @throws { BusinessError } 13900004 - Interrupted system call 809 * @throws { BusinessError } 13900005 - I/O error 810 * @throws { BusinessError } 13900008 - Bad file descriptor 811 * @throws { BusinessError } 13900025 - No space left on device 812 * @throws { BusinessError } 13900041 - Quota exceeded 813 * @throws { BusinessError } 13900042 - Unknown error 814 * @syscap SystemCapability.FileManagement.File.FileIO 815 * @crossplatform 816 * @atomicservice 817 * @since 11 818 */ 819declare function close(file: number | File): Promise<void>; 820 821/** 822 * Close file or fd. 823 * 824 * @param { number | File } file - file object or fd. 825 * @param { AsyncCallback<void> } callback - Return the callback function. 826 * @throws { BusinessError } 13900004 - Interrupted system call 827 * @throws { BusinessError } 13900005 - I/O error 828 * @throws { BusinessError } 13900008 - Bad file descriptor 829 * @throws { BusinessError } 13900025 - No space left on device 830 * @throws { BusinessError } 13900041 - Quota exceeded 831 * @throws { BusinessError } 13900042 - Unknown error 832 * @syscap SystemCapability.FileManagement.File.FileIO 833 * @since 9 834 */ 835/** 836 * Close file or fd. 837 * 838 * @param { number | File } file - file object or fd. 839 * @param { AsyncCallback<void> } callback - Return the callback function. 840 * @throws { BusinessError } 13900004 - Interrupted system call 841 * @throws { BusinessError } 13900005 - I/O error 842 * @throws { BusinessError } 13900008 - Bad file descriptor 843 * @throws { BusinessError } 13900025 - No space left on device 844 * @throws { BusinessError } 13900041 - Quota exceeded 845 * @throws { BusinessError } 13900042 - Unknown error 846 * @syscap SystemCapability.FileManagement.File.FileIO 847 * @crossplatform 848 * @since 10 849 */ 850/** 851 * Closes a file or directory. This API uses an asynchronous callback to return the result. 852 * 853 * @param { number | File } file - File object or FD of the file to close. 854 * <br>Once closed, the File object or FD cannot be used for read or write operations. 855 * @param { AsyncCallback<void> } callback - Callback invoked immediately after the file is closed. 856 * @throws { BusinessError } 13900004 - Interrupted system call 857 * @throws { BusinessError } 13900005 - I/O error 858 * @throws { BusinessError } 13900008 - Bad file descriptor 859 * @throws { BusinessError } 13900025 - No space left on device 860 * @throws { BusinessError } 13900041 - Quota exceeded 861 * @throws { BusinessError } 13900042 - Unknown error 862 * @syscap SystemCapability.FileManagement.File.FileIO 863 * @crossplatform 864 * @atomicservice 865 * @since 11 866 */ 867declare function close(file: number | File, callback: AsyncCallback<void>): void; 868 869/** 870 * Close file or fd with sync interface. 871 * 872 * @param { number | File } file - file object or fd. 873 * @throws { BusinessError } 13900004 - Interrupted system call 874 * @throws { BusinessError } 13900005 - I/O error 875 * @throws { BusinessError } 13900008 - Bad file descriptor 876 * @throws { BusinessError } 13900025 - No space left on device 877 * @throws { BusinessError } 13900041 - Quota exceeded 878 * @throws { BusinessError } 13900042 - Unknown error 879 * @syscap SystemCapability.FileManagement.File.FileIO 880 * @since 9 881 */ 882/** 883 * Close file or fd with sync interface. 884 * 885 * @param { number | File } file - file object or fd. 886 * @throws { BusinessError } 13900004 - Interrupted system call 887 * @throws { BusinessError } 13900005 - I/O error 888 * @throws { BusinessError } 13900008 - Bad file descriptor 889 * @throws { BusinessError } 13900025 - No space left on device 890 * @throws { BusinessError } 13900041 - Quota exceeded 891 * @throws { BusinessError } 13900042 - Unknown error 892 * @syscap SystemCapability.FileManagement.File.FileIO 893 * @crossplatform 894 * @since 10 895 */ 896/** 897 * Closes a file or directory. This API returns the result synchronously. 898 * 899 * @param { number | File } file - File object or FD of the file to close. 900 * <br>Once closed, the File object or FD cannot be used for read or write operations. 901 * @throws { BusinessError } 13900004 - Interrupted system call 902 * @throws { BusinessError } 13900005 - I/O error 903 * @throws { BusinessError } 13900008 - Bad file descriptor 904 * @throws { BusinessError } 13900025 - No space left on device 905 * @throws { BusinessError } 13900041 - Quota exceeded 906 * @throws { BusinessError } 13900042 - Unknown error 907 * @syscap SystemCapability.FileManagement.File.FileIO 908 * @crossplatform 909 * @atomicservice 910 * @since 11 911 */ 912declare function closeSync(file: number | File): void; 913 914/** 915 * Copy file or directory. 916 * 917 * @param { string } srcUri - src uri. 918 * @param { string } destUri - dest uri. 919 * @param { CopyOptions } [options] - options. 920 * @returns { Promise<void> } The promise returned by the function. 921 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 922 * <br>2.Incorrect parameter types. 923 * @throws { BusinessError } 13900001 - Operation not permitted 924 * @throws { BusinessError } 13900002 - No such file or directory 925 * @throws { BusinessError } 13900004 - Interrupted system call 926 * @throws { BusinessError } 13900005 - I/O error 927 * @throws { BusinessError } 13900008 - Bad file descriptor 928 * @throws { BusinessError } 13900010 - Try again 929 * @throws { BusinessError } 13900011 - Out of memory 930 * @throws { BusinessError } 13900012 - Permission denied by the file system 931 * @throws { BusinessError } 13900015 - File exists 932 * @throws { BusinessError } 13900018 - Not a directory 933 * @throws { BusinessError } 13900019 - Is a directory 934 * @throws { BusinessError } 13900020 - Invalid argument 935 * @throws { BusinessError } 13900021 - File table overflow 936 * @throws { BusinessError } 13900022 - Too many open files 937 * @throws { BusinessError } 13900024 - File too large 938 * @throws { BusinessError } 13900025 - No space left on device 939 * @throws { BusinessError } 13900027 - Read-only file system 940 * @throws { BusinessError } 13900028 - Too many links 941 * @throws { BusinessError } 13900030 - File name too long 942 * @throws { BusinessError } 13900031 - Function not implemented 943 * @throws { BusinessError } 13900034 - Operation would block 944 * @throws { BusinessError } 13900038 - Value too large for defined data type 945 * @throws { BusinessError } 13900041 - Quota exceeded 946 * @throws { BusinessError } 13900042 - Unknown error 947 * @syscap SystemCapability.FileManagement.File.FileIO 948 * @since 11 949 */ 950/** 951 * Copies a file or directory. This API uses a promise to return the result. 952 * File copy across devices is supported. This API forcibly overwrites the file or directory. 953 * The input parameter can be the URI of the file or directory. A maximum of 10 cross-device copy tasks are allowed at the same time, 954 * and the number of files to be copied at a time cannot exceed 500. 955 * 956 * @param { string } srcUri - URI of the file or directory to copy. 957 * @param { string } destUri - URI of the destination file or directory. 958 * @param { CopyOptions } [options] - Callback invoked to provide the copy progress. 959 * <br>If this parameter is not set, the callback will not be invoked. 960 * @returns { Promise<void> } Promise that returns no value. 961 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 962 * <br>2.Incorrect parameter types. 963 * @throws { BusinessError } 13900001 - Operation not permitted 964 * @throws { BusinessError } 13900002 - No such file or directory 965 * @throws { BusinessError } 13900004 - Interrupted system call 966 * @throws { BusinessError } 13900005 - I/O error 967 * @throws { BusinessError } 13900008 - Bad file descriptor 968 * @throws { BusinessError } 13900010 - Try again 969 * @throws { BusinessError } 13900011 - Out of memory 970 * @throws { BusinessError } 13900012 - Permission denied by the file system 971 * @throws { BusinessError } 13900015 - File exists 972 * @throws { BusinessError } 13900018 - Not a directory 973 * @throws { BusinessError } 13900019 - Is a directory 974 * @throws { BusinessError } 13900020 - Invalid argument 975 * @throws { BusinessError } 13900021 - File table overflow 976 * @throws { BusinessError } 13900022 - Too many open files 977 * @throws { BusinessError } 13900024 - File too large 978 * @throws { BusinessError } 13900025 - No space left on device 979 * @throws { BusinessError } 13900027 - Read-only file system 980 * @throws { BusinessError } 13900028 - Too many links 981 * @throws { BusinessError } 13900030 - File name too long 982 * @throws { BusinessError } 13900031 - Function not implemented 983 * @throws { BusinessError } 13900034 - Operation would block 984 * @throws { BusinessError } 13900038 - Value too large for defined data type 985 * @throws { BusinessError } 13900041 - Quota exceeded 986 * @throws { BusinessError } 13900042 - Unknown error 987 * @throws { BusinessError } 13900044 - Network is unreachable 988 * @syscap SystemCapability.FileManagement.File.FileIO 989 * @since 12 990 */ 991declare function copy(srcUri: string, destUri: string, options?: CopyOptions): Promise<void>; 992 993/** 994 * Copies a file or directory. This API uses an asynchronous callback to return the result. 995 * File copy across devices is supported. This API forcibly overwrites the file or directory. The file or directory URI is supported. 996 * A maximum of 10 cross-device copy tasks are allowed at the same time, 997 * and the number of files to be copied at a time cannot exceed 500. 998 * 999 * @param { string } srcUri - URI of the file or directory to copy. 1000 * @param { string } destUri - URI of the destination file or directory. 1001 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1002 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1003 * <br>2.Incorrect parameter types. 1004 * @throws { BusinessError } 13900001 - Operation not permitted 1005 * @throws { BusinessError } 13900002 - No such file or directory 1006 * @throws { BusinessError } 13900004 - Interrupted system call 1007 * @throws { BusinessError } 13900005 - I/O error 1008 * @throws { BusinessError } 13900008 - Bad file descriptor 1009 * @throws { BusinessError } 13900010 - Try again 1010 * @throws { BusinessError } 13900011 - Out of memory 1011 * @throws { BusinessError } 13900012 - Permission denied by the file system 1012 * @throws { BusinessError } 13900015 - File exists 1013 * @throws { BusinessError } 13900018 - Not a directory 1014 * @throws { BusinessError } 13900019 - Is a directory 1015 * @throws { BusinessError } 13900020 - Invalid argument 1016 * @throws { BusinessError } 13900021 - File table overflow 1017 * @throws { BusinessError } 13900022 - Too many open files 1018 * @throws { BusinessError } 13900024 - File too large 1019 * @throws { BusinessError } 13900025 - No space left on device 1020 * @throws { BusinessError } 13900027 - Read-only file system 1021 * @throws { BusinessError } 13900028 - Too many links 1022 * @throws { BusinessError } 13900030 - File name too long 1023 * @throws { BusinessError } 13900031 - Function not implemented 1024 * @throws { BusinessError } 13900034 - Operation would block 1025 * @throws { BusinessError } 13900038 - Value too large for defined data type 1026 * @throws { BusinessError } 13900041 - Quota exceeded 1027 * @throws { BusinessError } 13900042 - Unknown error 1028 * @syscap SystemCapability.FileManagement.File.FileIO 1029 * @since 11 1030 */ 1031declare function copy(srcUri: string, destUri: string, callback: AsyncCallback<void>): void; 1032 1033/** 1034 * Copies a file or directory. This API uses an asynchronous callback to return the result. 1035 * File copy across devices is supported. This API forcibly overwrites the file or directory. The file or directory URI is supported. 1036 * A maximum of 10 cross-device copy tasks are allowed at the same time, 1037 * and the number of files to be copied at a time cannot exceed 500. 1038 * 1039 * @param { string } srcUri - URI of the file or directory to copy. 1040 * @param { string } destUri - URI of the destination file or directory. 1041 * @param { CopyOptions } options - Callback used to return the copy progress. 1042 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1043 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 1044 * <br>2.Incorrect parameter types. 1045 * @throws { BusinessError } 13900001 - Operation not permitted 1046 * @throws { BusinessError } 13900002 - No such file or directory 1047 * @throws { BusinessError } 13900004 - Interrupted system call 1048 * @throws { BusinessError } 13900005 - I/O error 1049 * @throws { BusinessError } 13900008 - Bad file descriptor 1050 * @throws { BusinessError } 13900010 - Try again 1051 * @throws { BusinessError } 13900011 - Out of memory 1052 * @throws { BusinessError } 13900012 - Permission denied by the file system 1053 * @throws { BusinessError } 13900015 - File exists 1054 * @throws { BusinessError } 13900018 - Not a directory 1055 * @throws { BusinessError } 13900019 - Is a directory 1056 * @throws { BusinessError } 13900020 - Invalid argument 1057 * @throws { BusinessError } 13900021 - File table overflow 1058 * @throws { BusinessError } 13900022 - Too many open files 1059 * @throws { BusinessError } 13900024 - File too large 1060 * @throws { BusinessError } 13900025 - No space left on device 1061 * @throws { BusinessError } 13900027 - Read-only file system 1062 * @throws { BusinessError } 13900028 - Too many links 1063 * @throws { BusinessError } 13900030 - File name too long 1064 * @throws { BusinessError } 13900031 - Function not implemented 1065 * @throws { BusinessError } 13900034 - Operation would block 1066 * @throws { BusinessError } 13900038 - Value too large for defined data type 1067 * @throws { BusinessError } 13900041 - Quota exceeded 1068 * @throws { BusinessError } 13900042 - Unknown error 1069 * @syscap SystemCapability.FileManagement.File.FileIO 1070 * @since 11 1071 */ 1072declare function copy(srcUri: string, destUri: string, options: CopyOptions, callback: AsyncCallback<void>): void; 1073 1074/** 1075 * Copy directory. 1076 * 1077 * @param { string } src - source path. 1078 * @param { string } dest - destination path. 1079 * @param { number } [mode = 0] - mode. 1080 * @returns { Promise<void> } The promise returned by the function. 1081 * @throws { BusinessError } 13900002 - No such file or directory 1082 * @throws { BusinessError } 13900004 - Interrupted system call 1083 * @throws { BusinessError } 13900005 - I/O error 1084 * @throws { BusinessError } 13900008 - Bad file descriptor 1085 * @throws { BusinessError } 13900010 - Try again 1086 * @throws { BusinessError } 13900011 - Out of memory 1087 * @throws { BusinessError } 13900012 - Permission denied 1088 * @throws { BusinessError } 13900013 - Bad address 1089 * @throws { BusinessError } 13900018 - Not a directory 1090 * @throws { BusinessError } 13900019 - Is a directory 1091 * @throws { BusinessError } 13900020 - Invalid argument 1092 * @throws { BusinessError } 13900030 - File name too long 1093 * @throws { BusinessError } 13900031 - Function not implemented 1094 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1095 * @throws { BusinessError } 13900034 - Operation would block 1096 * @throws { BusinessError } 13900038 - Value too large for defined data type 1097 * @throws { BusinessError } 13900042 - Unknown error 1098 * @syscap SystemCapability.FileManagement.File.FileIO 1099 * @since 10 1100 */ 1101/** 1102 * Copies the source directory to the destination directory. This API uses a promise to return the result. 1103 * 1104 * @param { string } src - Application sandbox path of the source directory. 1105 * @param { string } dest - Application sandbox path of the destination folder. 1106 * @param { number } [mode = 0] - Copy mode. The default value is 0. 1107 * <br>0: Throw an exception if a file conflict occurs. 1108 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 1109 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory will be moved 1110 * <br>to the destination directory, and the non-conflicting files in the destination directory will be retained. 1111 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 1112 * <br>1: Forcibly overwrite the files with the same name in the destination directory. 1113 * <br>When the destination directory contains a directory with the same name as the source directory, 1114 * <br>the files with the same names in the destination directory are overwritten forcibly; 1115 * <br>the files without conflicts in the destination directory are retained. 1116 * @returns { Promise<void> } Promise that returns no value. 1117 * @throws { BusinessError } 13900002 - No such file or directory 1118 * @throws { BusinessError } 13900004 - Interrupted system call 1119 * @throws { BusinessError } 13900005 - I/O error 1120 * @throws { BusinessError } 13900008 - Bad file descriptor 1121 * @throws { BusinessError } 13900010 - Try again 1122 * @throws { BusinessError } 13900011 - Out of memory 1123 * @throws { BusinessError } 13900012 - Permission denied 1124 * @throws { BusinessError } 13900013 - Bad address 1125 * @throws { BusinessError } 13900018 - Not a directory 1126 * @throws { BusinessError } 13900019 - Is a directory 1127 * @throws { BusinessError } 13900020 - Invalid argument 1128 * @throws { BusinessError } 13900030 - File name too long 1129 * @throws { BusinessError } 13900031 - Function not implemented 1130 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1131 * @throws { BusinessError } 13900034 - Operation would block 1132 * @throws { BusinessError } 13900038 - Value too large for defined data type 1133 * @throws { BusinessError } 13900042 - Unknown error 1134 * @throws { BusinessError } 13900044 - Network is unreachable 1135 * @syscap SystemCapability.FileManagement.File.FileIO 1136 * @since 12 1137 */ 1138/** 1139 * Copies the source directory to the destination directory. This API uses a promise to return the result. 1140 * 1141 * @param { string } src - Application sandbox path of the source directory. 1142 * @param { string } dest - Application sandbox path of the destination folder. 1143 * @param { number } [mode = 0] - Copy mode. The default value is 0. 1144 * <br>0: Throw an exception if a file conflict occurs. 1145 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 1146 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory will be moved 1147 * <br>to the destination directory, and the non-conflicting files in the destination directory will be retained. 1148 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 1149 * <br>1: Forcibly overwrite the files with the same name in the destination directory. 1150 * <br>When the destination directory contains a directory with the same name as the source directory, 1151 * <br>the files with the same names in the destination directory are overwritten forcibly; 1152 * <br>the files without conflicts in the destination directory are retained. 1153 * @returns { Promise<void> } Promise that returns no value. 1154 * @throws { BusinessError } 13900002 - No such file or directory 1155 * @throws { BusinessError } 13900004 - Interrupted system call 1156 * @throws { BusinessError } 13900005 - I/O error 1157 * @throws { BusinessError } 13900008 - Bad file descriptor 1158 * @throws { BusinessError } 13900010 - Try again 1159 * @throws { BusinessError } 13900011 - Out of memory 1160 * @throws { BusinessError } 13900012 - Permission denied 1161 * @throws { BusinessError } 13900013 - Bad address 1162 * @throws { BusinessError } 13900018 - Not a directory 1163 * @throws { BusinessError } 13900019 - Is a directory 1164 * @throws { BusinessError } 13900020 - Invalid argument 1165 * @throws { BusinessError } 13900030 - File name too long 1166 * @throws { BusinessError } 13900031 - Function not implemented 1167 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1168 * @throws { BusinessError } 13900034 - Operation would block 1169 * @throws { BusinessError } 13900038 - Value too large for defined data type 1170 * @throws { BusinessError } 13900042 - Unknown error 1171 * @throws { BusinessError } 13900044 - Network is unreachable 1172 * @syscap SystemCapability.FileManagement.File.FileIO 1173 * @crossplatform 1174 * @since 20 1175 */ 1176declare function copyDir(src: string, dest: string, mode?: number): Promise<void>; 1177 1178/** 1179 * Copies the source directory to the destination directory. 1180 * This API uses an asynchronous callback to return the result. 1181 * 1182 * @param { string } src - Application sandbox path of the source directory. 1183 * @param { string } dest - Application sandbox path of the destination directory. 1184 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1185 * @throws { BusinessError } 13900002 - No such file or directory 1186 * @throws { BusinessError } 13900004 - Interrupted system call 1187 * @throws { BusinessError } 13900005 - I/O error 1188 * @throws { BusinessError } 13900008 - Bad file descriptor 1189 * @throws { BusinessError } 13900010 - Try again 1190 * @throws { BusinessError } 13900011 - Out of memory 1191 * @throws { BusinessError } 13900012 - Permission denied 1192 * @throws { BusinessError } 13900013 - Bad address 1193 * @throws { BusinessError } 13900018 - Not a directory 1194 * @throws { BusinessError } 13900019 - Is a directory 1195 * @throws { BusinessError } 13900020 - Invalid argument 1196 * @throws { BusinessError } 13900030 - File name too long 1197 * @throws { BusinessError } 13900031 - Function not implemented 1198 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1199 * @throws { BusinessError } 13900034 - Operation would block 1200 * @throws { BusinessError } 13900038 - Value too large for defined data type 1201 * @throws { BusinessError } 13900042 - Unknown error 1202 * @syscap SystemCapability.FileManagement.File.FileIO 1203 * @since 10 1204 */ 1205/** 1206 * Copies the source directory to the destination directory. 1207 * This API uses an asynchronous callback to return the result. 1208 * 1209 * @param { string } src - Application sandbox path of the source directory. 1210 * @param { string } dest - Application sandbox path of the destination directory. 1211 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1212 * @throws { BusinessError } 13900002 - No such file or directory 1213 * @throws { BusinessError } 13900004 - Interrupted system call 1214 * @throws { BusinessError } 13900005 - I/O error 1215 * @throws { BusinessError } 13900008 - Bad file descriptor 1216 * @throws { BusinessError } 13900010 - Try again 1217 * @throws { BusinessError } 13900011 - Out of memory 1218 * @throws { BusinessError } 13900012 - Permission denied 1219 * @throws { BusinessError } 13900013 - Bad address 1220 * @throws { BusinessError } 13900018 - Not a directory 1221 * @throws { BusinessError } 13900019 - Is a directory 1222 * @throws { BusinessError } 13900020 - Invalid argument 1223 * @throws { BusinessError } 13900030 - File name too long 1224 * @throws { BusinessError } 13900031 - Function not implemented 1225 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1226 * @throws { BusinessError } 13900034 - Operation would block 1227 * @throws { BusinessError } 13900038 - Value too large for defined data type 1228 * @throws { BusinessError } 13900042 - Unknown error 1229 * @syscap SystemCapability.FileManagement.File.FileIO 1230 * @crossplatform 1231 * @since 20 1232 */ 1233declare function copyDir(src: string, dest: string, callback: AsyncCallback<void>): void; 1234 1235/** 1236 * Copies the source directory to the destination directory. 1237 * This API uses an asynchronous callback to return the result. 1238 * 1239 * @param { string } src - Application sandbox path of the source directory. 1240 * @param { string } dest - Application sandbox path of the destination directory. 1241 * @param { AsyncCallback<void, Array<ConflictFiles>> } callback - Callback used to return the result. 1242 * @throws { BusinessError } 13900015 - File exists 1243 * @syscap SystemCapability.FileManagement.File.FileIO 1244 * @since 10 1245 */ 1246/** 1247 * Copies the source directory to the destination directory. 1248 * This API uses an asynchronous callback to return the result. 1249 * 1250 * @param { string } src - Application sandbox path of the source directory. 1251 * @param { string } dest - Application sandbox path of the destination directory. 1252 * @param { AsyncCallback<void, Array<ConflictFiles>> } callback - Callback used to return the result. 1253 * @throws { BusinessError } 13900015 - File exists 1254 * @syscap SystemCapability.FileManagement.File.FileIO 1255 * @crossplatform 1256 * @since 20 1257 */ 1258declare function copyDir(src: string, dest: string, callback: AsyncCallback<void, Array<ConflictFiles>>): void; 1259 1260 1261/** 1262 * Copies the source directory to the destination directory. You can set the copy mode. 1263 * This API uses an asynchronous callback to return the result. 1264 * 1265 * @param { string } src - Application sandbox path of the source directory. 1266 * @param { string } dest - Application sandbox path of the destination directory. 1267 * @param { number } mode - Copy mode. The default value is 0. 1268 * <br>0: Throw an exception if a file conflict occurs. 1269 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 1270 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory will be moved 1271 * <br>to the destination directory, and the non-conflicting files in the destination directory will be retained. 1272 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 1273 * <br>1: Forcibly overwrite the files with the same name in the destination directory. 1274 * <br>When the destination directory contains a directory with the same name as the source directory, 1275 * <br>the files with the same names in the destination directory are overwritten forcibly; 1276 * <br>the files without conflicts in the destination directory are retained. 1277 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1278 * @throws { BusinessError } 13900002 - No such file or directory 1279 * @throws { BusinessError } 13900004 - Interrupted system call 1280 * @throws { BusinessError } 13900005 - I/O error 1281 * @throws { BusinessError } 13900008 - Bad file descriptor 1282 * @throws { BusinessError } 13900010 - Try again 1283 * @throws { BusinessError } 13900011 - Out of memory 1284 * @throws { BusinessError } 13900012 - Permission denied 1285 * @throws { BusinessError } 13900013 - Bad address 1286 * @throws { BusinessError } 13900018 - Not a directory 1287 * @throws { BusinessError } 13900019 - Is a directory 1288 * @throws { BusinessError } 13900020 - Invalid argument 1289 * @throws { BusinessError } 13900030 - File name too long 1290 * @throws { BusinessError } 13900031 - Function not implemented 1291 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1292 * @throws { BusinessError } 13900034 - Operation would block 1293 * @throws { BusinessError } 13900038 - Value too large for defined data type 1294 * @throws { BusinessError } 13900042 - Unknown error 1295 * @syscap SystemCapability.FileManagement.File.FileIO 1296 * @since 10 1297 */ 1298/** 1299 * Copies the source directory to the destination directory. You can set the copy mode. 1300 * This API uses an asynchronous callback to return the result. 1301 * 1302 * @param { string } src - Application sandbox path of the source directory. 1303 * @param { string } dest - Application sandbox path of the destination directory. 1304 * @param { number } mode - Copy mode. The default value is 0. 1305 * <br>0: Throw an exception if a file conflict occurs. 1306 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 1307 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory will be moved 1308 * <br>to the destination directory, and the non-conflicting files in the destination directory will be retained. 1309 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 1310 * <br>1: Forcibly overwrite the files with the same name in the destination directory. 1311 * <br>When the destination directory contains a directory with the same name as the source directory, 1312 * <br>the files with the same names in the destination directory are overwritten forcibly; 1313 * <br>the files without conflicts in the destination directory are retained. 1314 * @param { AsyncCallback<void> } callback - Callback used to return the result. 1315 * @throws { BusinessError } 13900002 - No such file or directory 1316 * @throws { BusinessError } 13900004 - Interrupted system call 1317 * @throws { BusinessError } 13900005 - I/O error 1318 * @throws { BusinessError } 13900008 - Bad file descriptor 1319 * @throws { BusinessError } 13900010 - Try again 1320 * @throws { BusinessError } 13900011 - Out of memory 1321 * @throws { BusinessError } 13900012 - Permission denied 1322 * @throws { BusinessError } 13900013 - Bad address 1323 * @throws { BusinessError } 13900018 - Not a directory 1324 * @throws { BusinessError } 13900019 - Is a directory 1325 * @throws { BusinessError } 13900020 - Invalid argument 1326 * @throws { BusinessError } 13900030 - File name too long 1327 * @throws { BusinessError } 13900031 - Function not implemented 1328 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1329 * @throws { BusinessError } 13900034 - Operation would block 1330 * @throws { BusinessError } 13900038 - Value too large for defined data type 1331 * @throws { BusinessError } 13900042 - Unknown error 1332 * @syscap SystemCapability.FileManagement.File.FileIO 1333 * @crossplatform 1334 * @since 20 1335 */ 1336declare function copyDir(src: string, dest: string, mode: number, callback: AsyncCallback<void>): void; 1337 1338/** 1339 * Copies the source directory to the destination directory. You can set the copy mode. 1340 * This API uses an asynchronous callback to return the result. 1341 * 1342 * @param { string } src - Application sandbox path of the source directory. 1343 * @param { string } dest - Application sandbox path of the destination directory. 1344 * @param { number } mode - Copy mode. The default value is 0. 1345 * <br>0: Throw an exception if a file conflict occurs. 1346 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 1347 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory will be moved 1348 * <br>to the destination directory, and the non-conflicting files in the destination directory will be retained. 1349 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 1350 * <br>1: Forcibly overwrite the files with the same name in the destination directory. 1351 * <br>When the destination directory contains a directory with the same name as the source directory, 1352 * <br>the files with the same names in the destination directory are overwritten forcibly; 1353 * <br>the files without conflicts in the destination directory are retained. 1354 * @param { AsyncCallback<void, Array<ConflictFiles>> } callback - Callback used to return the result. 1355 * @throws { BusinessError } 13900015 - File exists 1356 * @syscap SystemCapability.FileManagement.File.FileIO 1357 * @since 10 1358 */ 1359/** 1360 * Copies the source directory to the destination directory. You can set the copy mode. 1361 * This API uses an asynchronous callback to return the result. 1362 * 1363 * @param { string } src - Application sandbox path of the source directory. 1364 * @param { string } dest - Application sandbox path of the destination directory. 1365 * @param { number } mode - Copy mode. The default value is 0. 1366 * <br>0: Throw an exception if a file conflict occurs. 1367 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 1368 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory will be moved 1369 * <br>to the destination directory, and the non-conflicting files in the destination directory will be retained. 1370 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 1371 * <br>1: Forcibly overwrite the files with the same name in the destination directory. 1372 * <br>When the destination directory contains a directory with the same name as the source directory, 1373 * <br>the files with the same names in the destination directory are overwritten forcibly; 1374 * <br>the files without conflicts in the destination directory are retained. 1375 * @param { AsyncCallback<void, Array<ConflictFiles>> } callback - Callback used to return the result. 1376 * @throws { BusinessError } 13900015 - File exists 1377 * @syscap SystemCapability.FileManagement.File.FileIO 1378 * @crossplatform 1379 * @since 20 1380 */ 1381declare function copyDir(src: string, dest: string, mode: number, callback: AsyncCallback<void, Array<ConflictFiles>>): void; 1382 1383/** 1384 * Copy directory with sync interface. 1385 * 1386 * @param { string } src - source path. 1387 * @param { string } dest - destination path. 1388 * @param { number } [mode = 0] - mode. 1389 * @throws { BusinessError } 13900002 - No such file or directory 1390 * @throws { BusinessError } 13900004 - Interrupted system call 1391 * @throws { BusinessError } 13900005 - I/O error 1392 * @throws { BusinessError } 13900008 - Bad file descriptor 1393 * @throws { BusinessError } 13900010 - Try again 1394 * @throws { BusinessError } 13900011 - Out of memory 1395 * @throws { BusinessError } 13900012 - Permission denied 1396 * @throws { BusinessError } 13900013 - Bad address 1397 * @throws { BusinessError } 13900015 - File exists 1398 * @throws { BusinessError } 13900018 - Not a directory 1399 * @throws { BusinessError } 13900019 - Is a directory 1400 * @throws { BusinessError } 13900020 - Invalid argument 1401 * @throws { BusinessError } 13900030 - File name too long 1402 * @throws { BusinessError } 13900031 - Function not implemented 1403 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1404 * @throws { BusinessError } 13900034 - Operation would block 1405 * @throws { BusinessError } 13900038 - Value too large for defined data type 1406 * @throws { BusinessError } 13900042 - Unknown error 1407 * @syscap SystemCapability.FileManagement.File.FileIO 1408 * @since 10 1409 */ 1410/** 1411 * Copies the source directory to the destination directory. This API returns the result synchronously. 1412 * 1413 * @param { string } src - Application sandbox path of the source directory. 1414 * @param { string } dest - Application sandbox path of the source directory. 1415 * @param { number } [mode = 0] - Copy mode. The default value is 0. 1416 * <br>0: Throw an exception if a file conflict occurs. 1417 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 1418 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory will be moved 1419 * <br>to the destination directory, and the non-conflicting files in the destination directory will be retained. 1420 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 1421 * <br>1: Forcibly overwrite the files with the same name in the destination directory. 1422 * <br>When the destination directory contains a directory with the same name as the source directory, 1423 * <br>the files with the same names in the destination directory are overwritten forcibly; 1424 * <br>the files without conflicts in the destination directory are retained. 1425 * @throws { BusinessError } 13900002 - No such file or directory 1426 * @throws { BusinessError } 13900004 - Interrupted system call 1427 * @throws { BusinessError } 13900005 - I/O error 1428 * @throws { BusinessError } 13900008 - Bad file descriptor 1429 * @throws { BusinessError } 13900010 - Try again 1430 * @throws { BusinessError } 13900011 - Out of memory 1431 * @throws { BusinessError } 13900012 - Permission denied 1432 * @throws { BusinessError } 13900013 - Bad address 1433 * @throws { BusinessError } 13900015 - File exists 1434 * @throws { BusinessError } 13900018 - Not a directory 1435 * @throws { BusinessError } 13900019 - Is a directory 1436 * @throws { BusinessError } 13900020 - Invalid argument 1437 * @throws { BusinessError } 13900030 - File name too long 1438 * @throws { BusinessError } 13900031 - Function not implemented 1439 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1440 * @throws { BusinessError } 13900034 - Operation would block 1441 * @throws { BusinessError } 13900038 - Value too large for defined data type 1442 * @throws { BusinessError } 13900042 - Unknown error 1443 * @throws { BusinessError } 13900044 - Network is unreachable 1444 * @syscap SystemCapability.FileManagement.File.FileIO 1445 * @since 12 1446 */ 1447/** 1448 * Copies the source directory to the destination directory. This API returns the result synchronously. 1449 * 1450 * @param { string } src - Application sandbox path of the source directory. 1451 * @param { string } dest - Application sandbox path of the source directory. 1452 * @param { number } [mode = 0] - Copy mode. The default value is 0. 1453 * <br>0: Throw an exception if a file conflict occurs. 1454 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 1455 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory will be moved 1456 * <br>to the destination directory, and the non-conflicting files in the destination directory will be retained. 1457 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 1458 * <br>1: Forcibly overwrite the files with the same name in the destination directory. 1459 * <br>When the destination directory contains a directory with the same name as the source directory, 1460 * <br>the files with the same names in the destination directory are overwritten forcibly; 1461 * <br>the files without conflicts in the destination directory are retained. 1462 * @throws { BusinessError } 13900002 - No such file or directory 1463 * @throws { BusinessError } 13900004 - Interrupted system call 1464 * @throws { BusinessError } 13900005 - I/O error 1465 * @throws { BusinessError } 13900008 - Bad file descriptor 1466 * @throws { BusinessError } 13900010 - Try again 1467 * @throws { BusinessError } 13900011 - Out of memory 1468 * @throws { BusinessError } 13900012 - Permission denied 1469 * @throws { BusinessError } 13900013 - Bad address 1470 * @throws { BusinessError } 13900015 - File exists 1471 * @throws { BusinessError } 13900018 - Not a directory 1472 * @throws { BusinessError } 13900019 - Is a directory 1473 * @throws { BusinessError } 13900020 - Invalid argument 1474 * @throws { BusinessError } 13900030 - File name too long 1475 * @throws { BusinessError } 13900031 - Function not implemented 1476 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1477 * @throws { BusinessError } 13900034 - Operation would block 1478 * @throws { BusinessError } 13900038 - Value too large for defined data type 1479 * @throws { BusinessError } 13900042 - Unknown error 1480 * @throws { BusinessError } 13900044 - Network is unreachable 1481 * @syscap SystemCapability.FileManagement.File.FileIO 1482 * @crossplatform 1483 * @since 20 1484 */ 1485declare function copyDirSync(src: string, dest: string, mode?: number): void; 1486 1487/** 1488 * Copy file. 1489 * 1490 * @param { string | number } src - src. 1491 * @param { string | number } dest - dest. 1492 * @param { number } [mode = 0] - mode. 1493 * @returns { Promise<void> } The promise returned by the function. 1494 * @throws { BusinessError } 13900002 - No such file or directory 1495 * @throws { BusinessError } 13900004 - Interrupted system call 1496 * @throws { BusinessError } 13900005 - I/O error 1497 * @throws { BusinessError } 13900008 - Bad file descriptor 1498 * @throws { BusinessError } 13900010 - Try again 1499 * @throws { BusinessError } 13900011 - Out of memory 1500 * @throws { BusinessError } 13900012 - Permission denied 1501 * @throws { BusinessError } 13900013 - Bad address 1502 * @throws { BusinessError } 13900018 - Not a directory 1503 * @throws { BusinessError } 13900019 - Is a directory 1504 * @throws { BusinessError } 13900020 - Invalid argument 1505 * @throws { BusinessError } 13900030 - File name too long 1506 * @throws { BusinessError } 13900031 - Function not implemented 1507 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1508 * @throws { BusinessError } 13900034 - Operation would block 1509 * @throws { BusinessError } 13900038 - Value too large for defined data type 1510 * @throws { BusinessError } 13900042 - Unknown error 1511 * @syscap SystemCapability.FileManagement.File.FileIO 1512 * @since 9 1513 */ 1514/** 1515 * Copy file. 1516 * 1517 * @param { string | number } src - src. 1518 * @param { string | number } dest - dest. 1519 * @param { number } [mode = 0] - mode. 1520 * @returns { Promise<void> } The promise returned by the function. 1521 * @throws { BusinessError } 13900002 - No such file or directory 1522 * @throws { BusinessError } 13900004 - Interrupted system call 1523 * @throws { BusinessError } 13900005 - I/O error 1524 * @throws { BusinessError } 13900008 - Bad file descriptor 1525 * @throws { BusinessError } 13900010 - Try again 1526 * @throws { BusinessError } 13900011 - Out of memory 1527 * @throws { BusinessError } 13900012 - Permission denied 1528 * @throws { BusinessError } 13900013 - Bad address 1529 * @throws { BusinessError } 13900018 - Not a directory 1530 * @throws { BusinessError } 13900019 - Is a directory 1531 * @throws { BusinessError } 13900020 - Invalid argument 1532 * @throws { BusinessError } 13900030 - File name too long 1533 * @throws { BusinessError } 13900031 - Function not implemented 1534 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1535 * @throws { BusinessError } 13900034 - Operation would block 1536 * @throws { BusinessError } 13900038 - Value too large for defined data type 1537 * @throws { BusinessError } 13900042 - Unknown error 1538 * @syscap SystemCapability.FileManagement.File.FileIO 1539 * @crossplatform 1540 * @since 10 1541 */ 1542/** 1543 * Copy file. 1544 * 1545 * @param { string | number } src - src. 1546 * @param { string | number } dest - dest. 1547 * @param { number } [mode = 0] - mode. 1548 * @returns { Promise<void> } The promise returned by the function. 1549 * @throws { BusinessError } 13900002 - No such file or directory 1550 * @throws { BusinessError } 13900004 - Interrupted system call 1551 * @throws { BusinessError } 13900005 - I/O error 1552 * @throws { BusinessError } 13900008 - Bad file descriptor 1553 * @throws { BusinessError } 13900010 - Try again 1554 * @throws { BusinessError } 13900011 - Out of memory 1555 * @throws { BusinessError } 13900012 - Permission denied 1556 * @throws { BusinessError } 13900013 - Bad address 1557 * @throws { BusinessError } 13900018 - Not a directory 1558 * @throws { BusinessError } 13900019 - Is a directory 1559 * @throws { BusinessError } 13900020 - Invalid argument 1560 * @throws { BusinessError } 13900030 - File name too long 1561 * @throws { BusinessError } 13900031 - Function not implemented 1562 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1563 * @throws { BusinessError } 13900034 - Operation would block 1564 * @throws { BusinessError } 13900038 - Value too large for defined data type 1565 * @throws { BusinessError } 13900042 - Unknown error 1566 * @syscap SystemCapability.FileManagement.File.FileIO 1567 * @crossplatform 1568 * @atomicservice 1569 * @since 11 1570 */ 1571/** 1572 * Copies a file. This API uses a promise to return the result. 1573 * 1574 * @param { string | number } src - Path or FD of the file to copy. 1575 * @param { string | number } dest - Destination path of the file or FD of the file created. 1576 * @param { number } [mode = 0] - Whether to overwrite the file with the same name in the destination directory. 1577 * <br>The default value is 0, which is the only value supported. 1578 * <br>0: overwrite the file with the same name and truncate the part that is not overwritten. 1579 * @returns { Promise<void> } Promise that returns no value. 1580 * @throws { BusinessError } 13900002 - No such file or directory 1581 * @throws { BusinessError } 13900004 - Interrupted system call 1582 * @throws { BusinessError } 13900005 - I/O error 1583 * @throws { BusinessError } 13900008 - Bad file descriptor 1584 * @throws { BusinessError } 13900010 - Try again 1585 * @throws { BusinessError } 13900011 - Out of memory 1586 * @throws { BusinessError } 13900012 - Permission denied 1587 * @throws { BusinessError } 13900013 - Bad address 1588 * @throws { BusinessError } 13900018 - Not a directory 1589 * @throws { BusinessError } 13900019 - Is a directory 1590 * @throws { BusinessError } 13900020 - Invalid argument 1591 * @throws { BusinessError } 13900030 - File name too long 1592 * @throws { BusinessError } 13900031 - Function not implemented 1593 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1594 * @throws { BusinessError } 13900034 - Operation would block 1595 * @throws { BusinessError } 13900038 - Value too large for defined data type 1596 * @throws { BusinessError } 13900042 - Unknown error 1597 * @throws { BusinessError } 13900044 - Network is unreachable 1598 * @syscap SystemCapability.FileManagement.File.FileIO 1599 * @crossplatform 1600 * @atomicservice 1601 * @since 12 1602 */ 1603declare function copyFile(src: string | number, dest: string | number, mode?: number): Promise<void>; 1604 1605/** 1606 * Copy file. 1607 * 1608 * @param { string | number } src - src. 1609 * @param { string | number } dest - dest. 1610 * @param { AsyncCallback<void> } callback - Return the callback function. 1611 * @throws { BusinessError } 13900002 - No such file or directory 1612 * @throws { BusinessError } 13900004 - Interrupted system call 1613 * @throws { BusinessError } 13900005 - I/O error 1614 * @throws { BusinessError } 13900008 - Bad file descriptor 1615 * @throws { BusinessError } 13900010 - Try again 1616 * @throws { BusinessError } 13900011 - Out of memory 1617 * @throws { BusinessError } 13900012 - Permission denied 1618 * @throws { BusinessError } 13900013 - Bad address 1619 * @throws { BusinessError } 13900018 - Not a directory 1620 * @throws { BusinessError } 13900019 - Is a directory 1621 * @throws { BusinessError } 13900020 - Invalid argument 1622 * @throws { BusinessError } 13900030 - File name too long 1623 * @throws { BusinessError } 13900031 - Function not implemented 1624 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1625 * @throws { BusinessError } 13900034 - Operation would block 1626 * @throws { BusinessError } 13900038 - Value too large for defined data type 1627 * @throws { BusinessError } 13900042 - Unknown error 1628 * @syscap SystemCapability.FileManagement.File.FileIO 1629 * @since 9 1630 */ 1631/** 1632 * Copy file. 1633 * 1634 * @param { string | number } src - src. 1635 * @param { string | number } dest - dest. 1636 * @param { AsyncCallback<void> } callback - Return the callback function. 1637 * @throws { BusinessError } 13900002 - No such file or directory 1638 * @throws { BusinessError } 13900004 - Interrupted system call 1639 * @throws { BusinessError } 13900005 - I/O error 1640 * @throws { BusinessError } 13900008 - Bad file descriptor 1641 * @throws { BusinessError } 13900010 - Try again 1642 * @throws { BusinessError } 13900011 - Out of memory 1643 * @throws { BusinessError } 13900012 - Permission denied 1644 * @throws { BusinessError } 13900013 - Bad address 1645 * @throws { BusinessError } 13900018 - Not a directory 1646 * @throws { BusinessError } 13900019 - Is a directory 1647 * @throws { BusinessError } 13900020 - Invalid argument 1648 * @throws { BusinessError } 13900030 - File name too long 1649 * @throws { BusinessError } 13900031 - Function not implemented 1650 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1651 * @throws { BusinessError } 13900034 - Operation would block 1652 * @throws { BusinessError } 13900038 - Value too large for defined data type 1653 * @throws { BusinessError } 13900042 - Unknown error 1654 * @syscap SystemCapability.FileManagement.File.FileIO 1655 * @crossplatform 1656 * @since 10 1657 */ 1658/** 1659 * Copies a file. This API overwrites the file with the same name in the destination directory and truncates the part that is not overwritten. 1660 * This API uses an asynchronous callback to return the result. 1661 * 1662 * @param { string | number } src - Path or FD of the file to copy. 1663 * @param { string | number } dest - Destination path of the file or FD of the file created. 1664 * @param { AsyncCallback<void> } callback - Callback invoked immediately after the file is copied. 1665 * @throws { BusinessError } 13900002 - No such file or directory 1666 * @throws { BusinessError } 13900004 - Interrupted system call 1667 * @throws { BusinessError } 13900005 - I/O error 1668 * @throws { BusinessError } 13900008 - Bad file descriptor 1669 * @throws { BusinessError } 13900010 - Try again 1670 * @throws { BusinessError } 13900011 - Out of memory 1671 * @throws { BusinessError } 13900012 - Permission denied 1672 * @throws { BusinessError } 13900013 - Bad address 1673 * @throws { BusinessError } 13900018 - Not a directory 1674 * @throws { BusinessError } 13900019 - Is a directory 1675 * @throws { BusinessError } 13900020 - Invalid argument 1676 * @throws { BusinessError } 13900030 - File name too long 1677 * @throws { BusinessError } 13900031 - Function not implemented 1678 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1679 * @throws { BusinessError } 13900034 - Operation would block 1680 * @throws { BusinessError } 13900038 - Value too large for defined data type 1681 * @throws { BusinessError } 13900042 - Unknown error 1682 * @syscap SystemCapability.FileManagement.File.FileIO 1683 * @crossplatform 1684 * @atomicservice 1685 * @since 11 1686 */ 1687declare function copyFile(src: string | number, dest: string | number, callback: AsyncCallback<void>): void; 1688 1689/** 1690 * Copy file. 1691 * 1692 * @param { string | number } src - src. 1693 * @param { string | number } dest - dest. 1694 * @param { number } [mode = 0] - mode. 1695 * @param { AsyncCallback<void> } callback - Return the callback function. 1696 * @throws { BusinessError } 13900002 - No such file or directory 1697 * @throws { BusinessError } 13900004 - Interrupted system call 1698 * @throws { BusinessError } 13900005 - I/O error 1699 * @throws { BusinessError } 13900008 - Bad file descriptor 1700 * @throws { BusinessError } 13900010 - Try again 1701 * @throws { BusinessError } 13900011 - Out of memory 1702 * @throws { BusinessError } 13900012 - Permission denied 1703 * @throws { BusinessError } 13900013 - Bad address 1704 * @throws { BusinessError } 13900018 - Not a directory 1705 * @throws { BusinessError } 13900019 - Is a directory 1706 * @throws { BusinessError } 13900020 - Invalid argument 1707 * @throws { BusinessError } 13900030 - File name too long 1708 * @throws { BusinessError } 13900031 - Function not implemented 1709 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1710 * @throws { BusinessError } 13900034 - Operation would block 1711 * @throws { BusinessError } 13900038 - Value too large for defined data type 1712 * @throws { BusinessError } 13900042 - Unknown error 1713 * @syscap SystemCapability.FileManagement.File.FileIO 1714 * @since 9 1715 */ 1716/** 1717 * Copy file. 1718 * 1719 * @param { string | number } src - src. 1720 * @param { string | number } dest - dest. 1721 * @param { number } [mode = 0] - mode. 1722 * @param { AsyncCallback<void> } callback - Return the callback function. 1723 * @throws { BusinessError } 13900002 - No such file or directory 1724 * @throws { BusinessError } 13900004 - Interrupted system call 1725 * @throws { BusinessError } 13900005 - I/O error 1726 * @throws { BusinessError } 13900008 - Bad file descriptor 1727 * @throws { BusinessError } 13900010 - Try again 1728 * @throws { BusinessError } 13900011 - Out of memory 1729 * @throws { BusinessError } 13900012 - Permission denied 1730 * @throws { BusinessError } 13900013 - Bad address 1731 * @throws { BusinessError } 13900018 - Not a directory 1732 * @throws { BusinessError } 13900019 - Is a directory 1733 * @throws { BusinessError } 13900020 - Invalid argument 1734 * @throws { BusinessError } 13900030 - File name too long 1735 * @throws { BusinessError } 13900031 - Function not implemented 1736 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1737 * @throws { BusinessError } 13900034 - Operation would block 1738 * @throws { BusinessError } 13900038 - Value too large for defined data type 1739 * @throws { BusinessError } 13900042 - Unknown error 1740 * @syscap SystemCapability.FileManagement.File.FileIO 1741 * @crossplatform 1742 * @since 10 1743 */ 1744/** 1745 * Copies a file. This API overwrites the file with the same name in the destination directory 1746 * and truncates the part that is not overwritten. This API uses an asynchronous callback to return the result. 1747 * 1748 * @param { string | number } src - Path or FD of the file to copy. 1749 * @param { string | number } dest - Destination path of the file or FD of the file created. 1750 * @param { number } [mode = 0] - Whether to overwrite the file with the same name in the destination directory. 1751 * <br>The default value is 0, which is the only value supported. 1752 * <br>0: overwrite the file with the same name and truncate the part that is not overwritten. 1753 * @param { AsyncCallback<void> } callback - Callback invoked immediately after the file is copied. 1754 * @throws { BusinessError } 13900002 - No such file or directory 1755 * @throws { BusinessError } 13900004 - Interrupted system call 1756 * @throws { BusinessError } 13900005 - I/O error 1757 * @throws { BusinessError } 13900008 - Bad file descriptor 1758 * @throws { BusinessError } 13900010 - Try again 1759 * @throws { BusinessError } 13900011 - Out of memory 1760 * @throws { BusinessError } 13900012 - Permission denied 1761 * @throws { BusinessError } 13900013 - Bad address 1762 * @throws { BusinessError } 13900018 - Not a directory 1763 * @throws { BusinessError } 13900019 - Is a directory 1764 * @throws { BusinessError } 13900020 - Invalid argument 1765 * @throws { BusinessError } 13900030 - File name too long 1766 * @throws { BusinessError } 13900031 - Function not implemented 1767 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1768 * @throws { BusinessError } 13900034 - Operation would block 1769 * @throws { BusinessError } 13900038 - Value too large for defined data type 1770 * @throws { BusinessError } 13900042 - Unknown error 1771 * @syscap SystemCapability.FileManagement.File.FileIO 1772 * @crossplatform 1773 * @atomicservice 1774 * @since 11 1775 */ 1776declare function copyFile( 1777 src: string | number, 1778 dest: string | number, 1779 mode: number, 1780 callback: AsyncCallback<void> 1781): void; 1782 1783/** 1784 * Copy file with sync interface. 1785 * 1786 * @param { string | number } src - src. 1787 * @param { string | number } dest - dest. 1788 * @param { number } [mode = 0] - mode. 1789 * @throws { BusinessError } 13900002 - No such file or directory 1790 * @throws { BusinessError } 13900004 - Interrupted system call 1791 * @throws { BusinessError } 13900005 - I/O error 1792 * @throws { BusinessError } 13900008 - Bad file descriptor 1793 * @throws { BusinessError } 13900010 - Try again 1794 * @throws { BusinessError } 13900011 - Out of memory 1795 * @throws { BusinessError } 13900012 - Permission denied 1796 * @throws { BusinessError } 13900013 - Bad address 1797 * @throws { BusinessError } 13900018 - Not a directory 1798 * @throws { BusinessError } 13900019 - Is a directory 1799 * @throws { BusinessError } 13900020 - Invalid argument 1800 * @throws { BusinessError } 13900030 - File name too long 1801 * @throws { BusinessError } 13900031 - Function not implemented 1802 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1803 * @throws { BusinessError } 13900034 - Operation would block 1804 * @throws { BusinessError } 13900038 - Value too large for defined data type 1805 * @throws { BusinessError } 13900042 - Unknown error 1806 * @syscap SystemCapability.FileManagement.File.FileIO 1807 * @since 9 1808 */ 1809/** 1810 * Copy file with sync interface. 1811 * 1812 * @param { string | number } src - src. 1813 * @param { string | number } dest - dest. 1814 * @param { number } [mode = 0] - mode. 1815 * @throws { BusinessError } 13900002 - No such file or directory 1816 * @throws { BusinessError } 13900004 - Interrupted system call 1817 * @throws { BusinessError } 13900005 - I/O error 1818 * @throws { BusinessError } 13900008 - Bad file descriptor 1819 * @throws { BusinessError } 13900010 - Try again 1820 * @throws { BusinessError } 13900011 - Out of memory 1821 * @throws { BusinessError } 13900012 - Permission denied 1822 * @throws { BusinessError } 13900013 - Bad address 1823 * @throws { BusinessError } 13900018 - Not a directory 1824 * @throws { BusinessError } 13900019 - Is a directory 1825 * @throws { BusinessError } 13900020 - Invalid argument 1826 * @throws { BusinessError } 13900030 - File name too long 1827 * @throws { BusinessError } 13900031 - Function not implemented 1828 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1829 * @throws { BusinessError } 13900034 - Operation would block 1830 * @throws { BusinessError } 13900038 - Value too large for defined data type 1831 * @throws { BusinessError } 13900042 - Unknown error 1832 * @syscap SystemCapability.FileManagement.File.FileIO 1833 * @crossplatform 1834 * @since 10 1835 */ 1836/** 1837 * Copy file with sync interface. 1838 * 1839 * @param { string | number } src - src. 1840 * @param { string | number } dest - dest. 1841 * @param { number } [mode = 0] - mode. 1842 * @throws { BusinessError } 13900002 - No such file or directory 1843 * @throws { BusinessError } 13900004 - Interrupted system call 1844 * @throws { BusinessError } 13900005 - I/O error 1845 * @throws { BusinessError } 13900008 - Bad file descriptor 1846 * @throws { BusinessError } 13900010 - Try again 1847 * @throws { BusinessError } 13900011 - Out of memory 1848 * @throws { BusinessError } 13900012 - Permission denied 1849 * @throws { BusinessError } 13900013 - Bad address 1850 * @throws { BusinessError } 13900018 - Not a directory 1851 * @throws { BusinessError } 13900019 - Is a directory 1852 * @throws { BusinessError } 13900020 - Invalid argument 1853 * @throws { BusinessError } 13900030 - File name too long 1854 * @throws { BusinessError } 13900031 - Function not implemented 1855 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1856 * @throws { BusinessError } 13900034 - Operation would block 1857 * @throws { BusinessError } 13900038 - Value too large for defined data type 1858 * @throws { BusinessError } 13900042 - Unknown error 1859 * @syscap SystemCapability.FileManagement.File.FileIO 1860 * @crossplatform 1861 * @atomicservice 1862 * @since 11 1863 */ 1864/** 1865 * Copies a file. This API returns the result synchronously. 1866 * 1867 * @param { string | number } src - Path or FD of the file to copy. 1868 * @param { string | number } dest - Destination path of the file or FD of the file created. 1869 * @param { number } [mode = 0] - Whether to overwrite the file with the same name in the destination directory. 1870 * <br>The default value is 0, which is the only value supported. 1871 * <br>0: overwrite the file with the same name and truncate the part that is not overwritten. 1872 * @throws { BusinessError } 13900002 - No such file or directory 1873 * @throws { BusinessError } 13900004 - Interrupted system call 1874 * @throws { BusinessError } 13900005 - I/O error 1875 * @throws { BusinessError } 13900008 - Bad file descriptor 1876 * @throws { BusinessError } 13900010 - Try again 1877 * @throws { BusinessError } 13900011 - Out of memory 1878 * @throws { BusinessError } 13900012 - Permission denied 1879 * @throws { BusinessError } 13900013 - Bad address 1880 * @throws { BusinessError } 13900018 - Not a directory 1881 * @throws { BusinessError } 13900019 - Is a directory 1882 * @throws { BusinessError } 13900020 - Invalid argument 1883 * @throws { BusinessError } 13900030 - File name too long 1884 * @throws { BusinessError } 13900031 - Function not implemented 1885 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1886 * @throws { BusinessError } 13900034 - Operation would block 1887 * @throws { BusinessError } 13900038 - Value too large for defined data type 1888 * @throws { BusinessError } 13900042 - Unknown error 1889 * @throws { BusinessError } 13900044 - Network is unreachable 1890 * @syscap SystemCapability.FileManagement.File.FileIO 1891 * @crossplatform 1892 * @atomicservice 1893 * @since 12 1894 */ 1895declare function copyFileSync(src: string | number, dest: string | number, mode?: number): void; 1896 1897/** 1898 * Create class Stream. 1899 * 1900 * @param { string } path - path. 1901 * @param { string } mode - mode. 1902 * @returns { Promise<Stream> } return Promise 1903 * @throws { BusinessError } 13900001 - Operation not permitted 1904 * @throws { BusinessError } 13900002 - No such file or directory 1905 * @throws { BusinessError } 13900004 - Interrupted system call 1906 * @throws { BusinessError } 13900006 - No such device or address 1907 * @throws { BusinessError } 13900008 - Bad file descriptor 1908 * @throws { BusinessError } 13900011 - Out of memory 1909 * @throws { BusinessError } 13900012 - Permission denied 1910 * @throws { BusinessError } 13900013 - Bad address 1911 * @throws { BusinessError } 13900014 - Device or resource busy 1912 * @throws { BusinessError } 13900015 - File exists 1913 * @throws { BusinessError } 13900017 - No such device 1914 * @throws { BusinessError } 13900018 - Not a directory 1915 * @throws { BusinessError } 13900019 - Is a directory 1916 * @throws { BusinessError } 13900020 - Invalid argument 1917 * @throws { BusinessError } 13900022 - Too many open files 1918 * @throws { BusinessError } 13900023 - Text file busy 1919 * @throws { BusinessError } 13900024 - File too large 1920 * @throws { BusinessError } 13900025 - No space left on device 1921 * @throws { BusinessError } 13900027 - Read-only file system 1922 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1923 * @throws { BusinessError } 13900030 - File name too long 1924 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1925 * @throws { BusinessError } 13900034 - Operation would block 1926 * @throws { BusinessError } 13900038 - Value too large for defined data type 1927 * @throws { BusinessError } 13900041 - Quota exceeded 1928 * @throws { BusinessError } 13900042 - Unknown error 1929 * @syscap SystemCapability.FileManagement.File.FileIO 1930 * @since 9 1931 */ 1932/** 1933 * Creates a stream based on a file path. This API uses a promise to return the result. 1934 * To close the stream, use close() of Stream. 1935 * 1936 * @param { string } path - Application sandbox path of the file. 1937 * @param { string } mode - r: Open a file for reading. The file must exist. 1938 * <br>r+: Open a file for both reading and writing. The file must exist. 1939 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 1940 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 1941 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 1942 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 1943 * <br>a+: Open a file in append mode for reading or updating at the end of the file. 1944 * <br>If the file does not exist, create a file. 1945 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 1946 * @returns { Promise<Stream> } Promise used to return the stream opened. 1947 * @throws { BusinessError } 13900001 - Operation not permitted 1948 * @throws { BusinessError } 13900002 - No such file or directory 1949 * @throws { BusinessError } 13900004 - Interrupted system call 1950 * @throws { BusinessError } 13900006 - No such device or address 1951 * @throws { BusinessError } 13900008 - Bad file descriptor 1952 * @throws { BusinessError } 13900011 - Out of memory 1953 * @throws { BusinessError } 13900012 - Permission denied 1954 * @throws { BusinessError } 13900013 - Bad address 1955 * @throws { BusinessError } 13900014 - Device or resource busy 1956 * @throws { BusinessError } 13900015 - File exists 1957 * @throws { BusinessError } 13900017 - No such device 1958 * @throws { BusinessError } 13900018 - Not a directory 1959 * @throws { BusinessError } 13900019 - Is a directory 1960 * @throws { BusinessError } 13900020 - Invalid argument 1961 * @throws { BusinessError } 13900022 - Too many open files 1962 * @throws { BusinessError } 13900023 - Text file busy 1963 * @throws { BusinessError } 13900024 - File too large 1964 * @throws { BusinessError } 13900025 - No space left on device 1965 * @throws { BusinessError } 13900027 - Read-only file system 1966 * @throws { BusinessError } 13900029 - Resource deadlock would occur 1967 * @throws { BusinessError } 13900030 - File name too long 1968 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 1969 * @throws { BusinessError } 13900034 - Operation would block 1970 * @throws { BusinessError } 13900038 - Value too large for defined data type 1971 * @throws { BusinessError } 13900041 - Quota exceeded 1972 * @throws { BusinessError } 13900042 - Unknown error 1973 * @throws { BusinessError } 13900044 - Network is unreachable 1974 * @syscap SystemCapability.FileManagement.File.FileIO 1975 * @since 12 1976 */ 1977/** 1978 * Creates a stream based on a file path. This API uses a promise to return the result. 1979 * To close the stream, use close() of Stream. 1980 * 1981 * @param { string } path - Application sandbox path of the file. 1982 * @param { string } mode - r: Open a file for reading. The file must exist. 1983 * <br>r+: Open a file for both reading and writing. The file must exist. 1984 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 1985 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 1986 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 1987 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 1988 * <br>a+: Open a file in append mode for reading or updating at the end of the file. 1989 * <br>If the file does not exist, create a file. 1990 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 1991 * @returns { Promise<Stream> } Promise used to return the stream opened. 1992 * @throws { BusinessError } 13900001 - Operation not permitted 1993 * @throws { BusinessError } 13900002 - No such file or directory 1994 * @throws { BusinessError } 13900004 - Interrupted system call 1995 * @throws { BusinessError } 13900006 - No such device or address 1996 * @throws { BusinessError } 13900008 - Bad file descriptor 1997 * @throws { BusinessError } 13900011 - Out of memory 1998 * @throws { BusinessError } 13900012 - Permission denied 1999 * @throws { BusinessError } 13900013 - Bad address 2000 * @throws { BusinessError } 13900014 - Device or resource busy 2001 * @throws { BusinessError } 13900015 - File exists 2002 * @throws { BusinessError } 13900017 - No such device 2003 * @throws { BusinessError } 13900018 - Not a directory 2004 * @throws { BusinessError } 13900019 - Is a directory 2005 * @throws { BusinessError } 13900020 - Invalid argument 2006 * @throws { BusinessError } 13900022 - Too many open files 2007 * @throws { BusinessError } 13900023 - Text file busy 2008 * @throws { BusinessError } 13900024 - File too large 2009 * @throws { BusinessError } 13900025 - No space left on device 2010 * @throws { BusinessError } 13900027 - Read-only file system 2011 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2012 * @throws { BusinessError } 13900030 - File name too long 2013 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2014 * @throws { BusinessError } 13900034 - Operation would block 2015 * @throws { BusinessError } 13900038 - Value too large for defined data type 2016 * @throws { BusinessError } 13900041 - Quota exceeded 2017 * @throws { BusinessError } 13900042 - Unknown error 2018 * @throws { BusinessError } 13900044 - Network is unreachable 2019 * @syscap SystemCapability.FileManagement.File.FileIO 2020 * @crossplatform 2021 * @atomicservice 2022 * @since 20 2023 */ 2024declare function createStream(path: string, mode: string): Promise<Stream>; 2025 2026/** 2027 * Creates a stream based on a file path. This API uses an asynchronous callback to return the result. 2028 * To close the stream, use close() of Stream. 2029 * 2030 * @param { string } path - Application sandbox path of the file. 2031 * @param { string } mode - r: Open a file for reading. The file must exist. 2032 * <br>r+: Open a file for both reading and writing. The file must exist. 2033 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 2034 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 2035 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 2036 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 2037 * <br>a+: Open a file in append mode for reading or updating at the end of the file. 2038 * <br>If the file does not exist, create a file. 2039 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 2040 * @param { AsyncCallback<Stream> } callback - Callback used to return the result. 2041 * @throws { BusinessError } 13900001 - Operation not permitted 2042 * @throws { BusinessError } 13900002 - No such file or directory 2043 * @throws { BusinessError } 13900004 - Interrupted system call 2044 * @throws { BusinessError } 13900006 - No such device or address 2045 * @throws { BusinessError } 13900008 - Bad file descriptor 2046 * @throws { BusinessError } 13900011 - Out of memory 2047 * @throws { BusinessError } 13900012 - Permission denied 2048 * @throws { BusinessError } 13900013 - Bad address 2049 * @throws { BusinessError } 13900014 - Device or resource busy 2050 * @throws { BusinessError } 13900015 - File exists 2051 * @throws { BusinessError } 13900017 - No such device 2052 * @throws { BusinessError } 13900018 - Not a directory 2053 * @throws { BusinessError } 13900019 - Is a directory 2054 * @throws { BusinessError } 13900020 - Invalid argument 2055 * @throws { BusinessError } 13900022 - Too many open files 2056 * @throws { BusinessError } 13900023 - Text file busy 2057 * @throws { BusinessError } 13900024 - File too large 2058 * @throws { BusinessError } 13900025 - No space left on device 2059 * @throws { BusinessError } 13900027 - Read-only file system 2060 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2061 * @throws { BusinessError } 13900030 - File name too long 2062 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2063 * @throws { BusinessError } 13900034 - Operation would block 2064 * @throws { BusinessError } 13900038 - Value too large for defined data type 2065 * @throws { BusinessError } 13900041 - Quota exceeded 2066 * @throws { BusinessError } 13900042 - Unknown error 2067 * @syscap SystemCapability.FileManagement.File.FileIO 2068 * @since 9 2069 */ 2070/** 2071 * Creates a stream based on a file path. This API uses an asynchronous callback to return the result. 2072 * To close the stream, use close() of Stream. 2073 * 2074 * @param { string } path - Application sandbox path of the file. 2075 * @param { string } mode - r: Open a file for reading. The file must exist. 2076 * <br>r+: Open a file for both reading and writing. The file must exist. 2077 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 2078 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 2079 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 2080 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 2081 * <br>a+: Open a file in append mode for reading or updating at the end of the file. 2082 * <br>If the file does not exist, create a file. 2083 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 2084 * @param { AsyncCallback<Stream> } callback - Callback used to return the result. 2085 * @throws { BusinessError } 13900001 - Operation not permitted 2086 * @throws { BusinessError } 13900002 - No such file or directory 2087 * @throws { BusinessError } 13900004 - Interrupted system call 2088 * @throws { BusinessError } 13900006 - No such device or address 2089 * @throws { BusinessError } 13900008 - Bad file descriptor 2090 * @throws { BusinessError } 13900011 - Out of memory 2091 * @throws { BusinessError } 13900012 - Permission denied 2092 * @throws { BusinessError } 13900013 - Bad address 2093 * @throws { BusinessError } 13900014 - Device or resource busy 2094 * @throws { BusinessError } 13900015 - File exists 2095 * @throws { BusinessError } 13900017 - No such device 2096 * @throws { BusinessError } 13900018 - Not a directory 2097 * @throws { BusinessError } 13900019 - Is a directory 2098 * @throws { BusinessError } 13900020 - Invalid argument 2099 * @throws { BusinessError } 13900022 - Too many open files 2100 * @throws { BusinessError } 13900023 - Text file busy 2101 * @throws { BusinessError } 13900024 - File too large 2102 * @throws { BusinessError } 13900025 - No space left on device 2103 * @throws { BusinessError } 13900027 - Read-only file system 2104 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2105 * @throws { BusinessError } 13900030 - File name too long 2106 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2107 * @throws { BusinessError } 13900034 - Operation would block 2108 * @throws { BusinessError } 13900038 - Value too large for defined data type 2109 * @throws { BusinessError } 13900041 - Quota exceeded 2110 * @throws { BusinessError } 13900042 - Unknown error 2111 * @syscap SystemCapability.FileManagement.File.FileIO 2112 * @crossplatform 2113 * @atomicservice 2114 * @since 20 2115 */ 2116declare function createStream(path: string, mode: string, callback: AsyncCallback<Stream>): void; 2117 2118/** 2119 * Create class Stream with sync interface. 2120 * 2121 * @param { string } path - path. 2122 * @param { string } mode - mode. 2123 * @returns { Stream } createStream 2124 * @throws { BusinessError } 13900001 - Operation not permitted 2125 * @throws { BusinessError } 13900002 - No such file or directory 2126 * @throws { BusinessError } 13900004 - Interrupted system call 2127 * @throws { BusinessError } 13900006 - No such device or address 2128 * @throws { BusinessError } 13900008 - Bad file descriptor 2129 * @throws { BusinessError } 13900011 - Out of memory 2130 * @throws { BusinessError } 13900012 - Permission denied 2131 * @throws { BusinessError } 13900013 - Bad address 2132 * @throws { BusinessError } 13900014 - Device or resource busy 2133 * @throws { BusinessError } 13900015 - File exists 2134 * @throws { BusinessError } 13900017 - No such device 2135 * @throws { BusinessError } 13900018 - Not a directory 2136 * @throws { BusinessError } 13900019 - Is a directory 2137 * @throws { BusinessError } 13900020 - Invalid argument 2138 * @throws { BusinessError } 13900022 - Too many open files 2139 * @throws { BusinessError } 13900023 - Text file busy 2140 * @throws { BusinessError } 13900024 - File too large 2141 * @throws { BusinessError } 13900025 - No space left on device 2142 * @throws { BusinessError } 13900027 - Read-only file system 2143 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2144 * @throws { BusinessError } 13900030 - File name too long 2145 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2146 * @throws { BusinessError } 13900034 - Operation would block 2147 * @throws { BusinessError } 13900038 - Value too large for defined data type 2148 * @throws { BusinessError } 13900041 - Quota exceeded 2149 * @throws { BusinessError } 13900042 - Unknown error 2150 * @syscap SystemCapability.FileManagement.File.FileIO 2151 * @since 9 2152 */ 2153/** 2154 * Creates a stream based on a file path. This API returns the result synchronously. 2155 * To close the stream, use close() of Stream. 2156 * 2157 * @param { string } path - Application sandbox path of the file. 2158 * @param { string } mode - r: Open a file for reading. The file must exist. 2159 * <br>r+: Open a file for both reading and writing. The file must exist. 2160 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 2161 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 2162 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 2163 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 2164 * <br>a+: Open a file in append mode for reading or updating at the end of the file. 2165 * <br>If the file does not exist, create a file. 2166 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 2167 * @returns { Stream } Stream opened. 2168 * @throws { BusinessError } 13900001 - Operation not permitted 2169 * @throws { BusinessError } 13900002 - No such file or directory 2170 * @throws { BusinessError } 13900004 - Interrupted system call 2171 * @throws { BusinessError } 13900006 - No such device or address 2172 * @throws { BusinessError } 13900008 - Bad file descriptor 2173 * @throws { BusinessError } 13900011 - Out of memory 2174 * @throws { BusinessError } 13900012 - Permission denied 2175 * @throws { BusinessError } 13900013 - Bad address 2176 * @throws { BusinessError } 13900014 - Device or resource busy 2177 * @throws { BusinessError } 13900015 - File exists 2178 * @throws { BusinessError } 13900017 - No such device 2179 * @throws { BusinessError } 13900018 - Not a directory 2180 * @throws { BusinessError } 13900019 - Is a directory 2181 * @throws { BusinessError } 13900020 - Invalid argument 2182 * @throws { BusinessError } 13900022 - Too many open files 2183 * @throws { BusinessError } 13900023 - Text file busy 2184 * @throws { BusinessError } 13900024 - File too large 2185 * @throws { BusinessError } 13900025 - No space left on device 2186 * @throws { BusinessError } 13900027 - Read-only file system 2187 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2188 * @throws { BusinessError } 13900030 - File name too long 2189 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2190 * @throws { BusinessError } 13900034 - Operation would block 2191 * @throws { BusinessError } 13900038 - Value too large for defined data type 2192 * @throws { BusinessError } 13900041 - Quota exceeded 2193 * @throws { BusinessError } 13900042 - Unknown error 2194 * @throws { BusinessError } 13900044 - Network is unreachable 2195 * @syscap SystemCapability.FileManagement.File.FileIO 2196 * @since 12 2197 */ 2198/** 2199 * Creates a stream based on a file path. This API returns the result synchronously. 2200 * To close the stream, use close() of Stream. 2201 * 2202 * @param { string } path - Application sandbox path of the file. 2203 * @param { string } mode - r: Open a file for reading. The file must exist. 2204 * <br>r+: Open a file for both reading and writing. The file must exist. 2205 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 2206 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 2207 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 2208 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 2209 * <br>a+: Open a file in append mode for reading or updating at the end of the file. 2210 * <br>If the file does not exist, create a file. 2211 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 2212 * @returns { Stream } Stream opened. 2213 * @throws { BusinessError } 13900001 - Operation not permitted 2214 * @throws { BusinessError } 13900002 - No such file or directory 2215 * @throws { BusinessError } 13900004 - Interrupted system call 2216 * @throws { BusinessError } 13900006 - No such device or address 2217 * @throws { BusinessError } 13900008 - Bad file descriptor 2218 * @throws { BusinessError } 13900011 - Out of memory 2219 * @throws { BusinessError } 13900012 - Permission denied 2220 * @throws { BusinessError } 13900013 - Bad address 2221 * @throws { BusinessError } 13900014 - Device or resource busy 2222 * @throws { BusinessError } 13900015 - File exists 2223 * @throws { BusinessError } 13900017 - No such device 2224 * @throws { BusinessError } 13900018 - Not a directory 2225 * @throws { BusinessError } 13900019 - Is a directory 2226 * @throws { BusinessError } 13900020 - Invalid argument 2227 * @throws { BusinessError } 13900022 - Too many open files 2228 * @throws { BusinessError } 13900023 - Text file busy 2229 * @throws { BusinessError } 13900024 - File too large 2230 * @throws { BusinessError } 13900025 - No space left on device 2231 * @throws { BusinessError } 13900027 - Read-only file system 2232 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2233 * @throws { BusinessError } 13900030 - File name too long 2234 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2235 * @throws { BusinessError } 13900034 - Operation would block 2236 * @throws { BusinessError } 13900038 - Value too large for defined data type 2237 * @throws { BusinessError } 13900041 - Quota exceeded 2238 * @throws { BusinessError } 13900042 - Unknown error 2239 * @throws { BusinessError } 13900044 - Network is unreachable 2240 * @syscap SystemCapability.FileManagement.File.FileIO 2241 * @crossplatform 2242 * @atomicservice 2243 * @since 20 2244 */ 2245declare function createStreamSync(path: string, mode: string): Stream; 2246 2247 2248/** 2249 * Create class RandomAccessFile. 2250 * 2251 * @param { string | File } file - file path, object. 2252 * @param { number } [mode = OpenMode.READ_ONLY] - mode. 2253 * @returns { Promise<RandomAccessFile> } Returns the RandomAccessFile object which has been created in promise mode. 2254 * @throws { BusinessError } 13900001 - Operation not permitted 2255 * @throws { BusinessError } 13900002 - No such file or directory 2256 * @throws { BusinessError } 13900004 - Interrupted system call 2257 * @throws { BusinessError } 13900006 - No such device or address 2258 * @throws { BusinessError } 13900008 - Bad file descriptor 2259 * @throws { BusinessError } 13900011 - Out of memory 2260 * @throws { BusinessError } 13900012 - Permission denied 2261 * @throws { BusinessError } 13900013 - Bad address 2262 * @throws { BusinessError } 13900014 - Device or resource busy 2263 * @throws { BusinessError } 13900015 - File exists 2264 * @throws { BusinessError } 13900017 - No such device 2265 * @throws { BusinessError } 13900018 - Not a directory 2266 * @throws { BusinessError } 13900019 - Is a directory 2267 * @throws { BusinessError } 13900020 - Invalid argument 2268 * @throws { BusinessError } 13900022 - Too many open files 2269 * @throws { BusinessError } 13900023 - Text file busy 2270 * @throws { BusinessError } 13900024 - File too large 2271 * @throws { BusinessError } 13900025 - No space left on device 2272 * @throws { BusinessError } 13900027 - Read-only file system 2273 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2274 * @throws { BusinessError } 13900030 - File name too long 2275 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2276 * @throws { BusinessError } 13900034 - Operation would block 2277 * @throws { BusinessError } 13900038 - Value too large for defined data type 2278 * @throws { BusinessError } 13900041 - Quota exceeded 2279 * @throws { BusinessError } 13900042 - Unknown error 2280 * @syscap SystemCapability.FileManagement.File.FileIO 2281 * @since 10 2282 */ 2283/** 2284 * Creates a RandomAccessFile instance based on a file path or file object. 2285 * This API uses a promise to return the result. 2286 * 2287 * @param { string | File } file - Application sandbox path of the file or an opened file object. 2288 * @param { number } [mode = OpenMode.READ_ONLY] - Mode for creating the RandomAccessFile instance. 2289 * <br>This parameter is valid only when the application sandbox path of the file is passed in. 2290 * <br>One of the following options must be specified: 2291 * <br>OpenMode.READ_ONLY(0o0): Create the file in read-only mode. This is the default value. 2292 * <br>OpenMode.WRITE_ONLY(0o1): Create the file in write-only mode. 2293 * <br>OpenMode.READ_WRITE(0o2): Create the file in read/write mode. 2294 * <br>You can also specify the following options, separated by a bitwise OR operator (|). By default, 2295 * <br>no additional options are given. 2296 * <br>OpenMode.CREATE(0o100): If the file does not exist, create it. 2297 * <br>OpenMode.TRUNC(0o1000): If the RandomAccessFile object already exists and is created in write mode, 2298 * <br>truncate the file length to 0. 2299 * <br>OpenMode.APPEND(0o2000): Create the file in append mode. New data will be added to the end 2300 * <br>of the RandomAccessFile object. 2301 * <br>OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 2302 * <br>or character special file, perform non-blocking operations on the created file and in subsequent I/Os. 2303 * <br>OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 2304 * <br>OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 2305 * <br>OpenMode.SYNC(0o4010000): Create a RandomAccessFile instance in synchronous I/O mode. 2306 * @param { RandomAccessFileOptions } [options] - Defines the options used in createRandomAccessFile(). 2307 * @returns { Promise<RandomAccessFile> } Promise used to return the RandomAccessFile instance created. 2308 * @throws { BusinessError } 13900001 - Operation not permitted 2309 * @throws { BusinessError } 13900002 - No such file or directory 2310 * @throws { BusinessError } 13900004 - Interrupted system call 2311 * @throws { BusinessError } 13900006 - No such device or address 2312 * @throws { BusinessError } 13900008 - Bad file descriptor 2313 * @throws { BusinessError } 13900011 - Out of memory 2314 * @throws { BusinessError } 13900012 - Permission denied 2315 * @throws { BusinessError } 13900013 - Bad address 2316 * @throws { BusinessError } 13900014 - Device or resource busy 2317 * @throws { BusinessError } 13900015 - File exists 2318 * @throws { BusinessError } 13900017 - No such device 2319 * @throws { BusinessError } 13900018 - Not a directory 2320 * @throws { BusinessError } 13900019 - Is a directory 2321 * @throws { BusinessError } 13900020 - Invalid argument 2322 * @throws { BusinessError } 13900022 - Too many open files 2323 * @throws { BusinessError } 13900023 - Text file busy 2324 * @throws { BusinessError } 13900024 - File too large 2325 * @throws { BusinessError } 13900025 - No space left on device 2326 * @throws { BusinessError } 13900027 - Read-only file system 2327 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2328 * @throws { BusinessError } 13900030 - File name too long 2329 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2330 * @throws { BusinessError } 13900034 - Operation would block 2331 * @throws { BusinessError } 13900038 - Value too large for defined data type 2332 * @throws { BusinessError } 13900041 - Quota exceeded 2333 * @throws { BusinessError } 13900042 - Unknown error 2334 * @throws { BusinessError } 13900044 - Network is unreachable 2335 * @syscap SystemCapability.FileManagement.File.FileIO 2336 * @since 12 2337 */ 2338/** 2339 * Creates a RandomAccessFile instance based on a file path or file object. 2340 * This API uses a promise to return the result. 2341 * 2342 * @param { string | File } file - Application sandbox path of the file or an opened file object. 2343 * @param { number } [mode = OpenMode.READ_ONLY] - Mode for creating the RandomAccessFile instance. 2344 * <br>This parameter is valid only when the application sandbox path of the file is passed in. 2345 * <br>One of the following options must be specified: 2346 * <br>OpenMode.READ_ONLY(0o0): Create the file in read-only mode. This is the default value. 2347 * <br>OpenMode.WRITE_ONLY(0o1): Create the file in write-only mode. 2348 * <br>OpenMode.READ_WRITE(0o2): Create the file in read/write mode. 2349 * <br>You can also specify the following options, separated by a bitwise OR operator (|). By default, 2350 * <br>no additional options are given. 2351 * <br>OpenMode.CREATE(0o100): If the file does not exist, create it. 2352 * <br>OpenMode.TRUNC(0o1000): If the RandomAccessFile object already exists and is created in write mode, 2353 * <br>truncate the file length to 0. 2354 * <br>OpenMode.APPEND(0o2000): Create the file in append mode. New data will be added to the end 2355 * <br>of the RandomAccessFile object. 2356 * <br>OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 2357 * <br>or character special file, perform non-blocking operations on the created file and in subsequent I/Os. 2358 * <br>OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 2359 * <br>OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 2360 * <br>OpenMode.SYNC(0o4010000): Create a RandomAccessFile instance in synchronous I/O mode. 2361 * @param { RandomAccessFileOptions } [options] - Defines the options used in createRandomAccessFile(). 2362 * @returns { Promise<RandomAccessFile> } Promise used to return the RandomAccessFile instance created. 2363 * @throws { BusinessError } 13900001 - Operation not permitted 2364 * @throws { BusinessError } 13900002 - No such file or directory 2365 * @throws { BusinessError } 13900004 - Interrupted system call 2366 * @throws { BusinessError } 13900006 - No such device or address 2367 * @throws { BusinessError } 13900008 - Bad file descriptor 2368 * @throws { BusinessError } 13900011 - Out of memory 2369 * @throws { BusinessError } 13900012 - Permission denied 2370 * @throws { BusinessError } 13900013 - Bad address 2371 * @throws { BusinessError } 13900014 - Device or resource busy 2372 * @throws { BusinessError } 13900015 - File exists 2373 * @throws { BusinessError } 13900017 - No such device 2374 * @throws { BusinessError } 13900018 - Not a directory 2375 * @throws { BusinessError } 13900019 - Is a directory 2376 * @throws { BusinessError } 13900020 - Invalid argument 2377 * @throws { BusinessError } 13900022 - Too many open files 2378 * @throws { BusinessError } 13900023 - Text file busy 2379 * @throws { BusinessError } 13900024 - File too large 2380 * @throws { BusinessError } 13900025 - No space left on device 2381 * @throws { BusinessError } 13900027 - Read-only file system 2382 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2383 * @throws { BusinessError } 13900030 - File name too long 2384 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2385 * @throws { BusinessError } 13900034 - Operation would block 2386 * @throws { BusinessError } 13900038 - Value too large for defined data type 2387 * @throws { BusinessError } 13900041 - Quota exceeded 2388 * @throws { BusinessError } 13900042 - Unknown error 2389 * @throws { BusinessError } 13900044 - Network is unreachable 2390 * @syscap SystemCapability.FileManagement.File.FileIO 2391 * @crossplatform 2392 * @since 20 2393 */ 2394declare function createRandomAccessFile(file: string | File, mode?: number, 2395 options?: RandomAccessFileOptions): Promise<RandomAccessFile>; 2396 2397/** 2398 * Creates a RandomAccessFile object in read-only mode based on a file path or file object. 2399 * This API uses an asynchronous callback to return the result. 2400 * 2401 * @param { string | File } file - Application sandbox path of the file or an opened file object. 2402 * @param { AsyncCallback<RandomAccessFile> } callback - Callback used to return the RandomAccessFile instance created. 2403 * @throws { BusinessError } 13900001 - Operation not permitted 2404 * @throws { BusinessError } 13900002 - No such file or directory 2405 * @throws { BusinessError } 13900004 - Interrupted system call 2406 * @throws { BusinessError } 13900006 - No such device or address 2407 * @throws { BusinessError } 13900008 - Bad file descriptor 2408 * @throws { BusinessError } 13900011 - Out of memory 2409 * @throws { BusinessError } 13900012 - Permission denied 2410 * @throws { BusinessError } 13900013 - Bad address 2411 * @throws { BusinessError } 13900014 - Device or resource busy 2412 * @throws { BusinessError } 13900015 - File exists 2413 * @throws { BusinessError } 13900017 - No such device 2414 * @throws { BusinessError } 13900018 - Not a directory 2415 * @throws { BusinessError } 13900019 - Is a directory 2416 * @throws { BusinessError } 13900020 - Invalid argument 2417 * @throws { BusinessError } 13900022 - Too many open files 2418 * @throws { BusinessError } 13900023 - Text file busy 2419 * @throws { BusinessError } 13900024 - File too large 2420 * @throws { BusinessError } 13900025 - No space left on device 2421 * @throws { BusinessError } 13900027 - Read-only file system 2422 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2423 * @throws { BusinessError } 13900030 - File name too long 2424 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2425 * @throws { BusinessError } 13900034 - Operation would block 2426 * @throws { BusinessError } 13900038 - Value too large for defined data type 2427 * @throws { BusinessError } 13900041 - Quota exceeded 2428 * @throws { BusinessError } 13900042 - Unknown error 2429 * @syscap SystemCapability.FileManagement.File.FileIO 2430 * @since 10 2431 */ 2432/** 2433 * Creates a RandomAccessFile object in read-only mode based on a file path or file object. 2434 * This API uses an asynchronous callback to return the result. 2435 * 2436 * @param { string | File } file - Application sandbox path of the file or an opened file object. 2437 * @param { AsyncCallback<RandomAccessFile> } callback - Callback used to return the RandomAccessFile instance created. 2438 * @throws { BusinessError } 13900001 - Operation not permitted 2439 * @throws { BusinessError } 13900002 - No such file or directory 2440 * @throws { BusinessError } 13900004 - Interrupted system call 2441 * @throws { BusinessError } 13900006 - No such device or address 2442 * @throws { BusinessError } 13900008 - Bad file descriptor 2443 * @throws { BusinessError } 13900011 - Out of memory 2444 * @throws { BusinessError } 13900012 - Permission denied 2445 * @throws { BusinessError } 13900013 - Bad address 2446 * @throws { BusinessError } 13900014 - Device or resource busy 2447 * @throws { BusinessError } 13900015 - File exists 2448 * @throws { BusinessError } 13900017 - No such device 2449 * @throws { BusinessError } 13900018 - Not a directory 2450 * @throws { BusinessError } 13900019 - Is a directory 2451 * @throws { BusinessError } 13900020 - Invalid argument 2452 * @throws { BusinessError } 13900022 - Too many open files 2453 * @throws { BusinessError } 13900023 - Text file busy 2454 * @throws { BusinessError } 13900024 - File too large 2455 * @throws { BusinessError } 13900025 - No space left on device 2456 * @throws { BusinessError } 13900027 - Read-only file system 2457 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2458 * @throws { BusinessError } 13900030 - File name too long 2459 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2460 * @throws { BusinessError } 13900034 - Operation would block 2461 * @throws { BusinessError } 13900038 - Value too large for defined data type 2462 * @throws { BusinessError } 13900041 - Quota exceeded 2463 * @throws { BusinessError } 13900042 - Unknown error 2464 * @syscap SystemCapability.FileManagement.File.FileIO 2465 * @crossplatform 2466 * @since 20 2467 */ 2468declare function createRandomAccessFile(file: string | File, callback: AsyncCallback<RandomAccessFile>): void; 2469 2470/** 2471 * Creates a RandomAccessFile instance based on a file path or file object. 2472 * This API uses an asynchronous callback to return the result. 2473 * 2474 * @param { string | File } file - Application sandbox path of the file or an opened file object. 2475 * @param { number } [mode = OpenMode.READ_ONLY] - Mode for creating the RandomAccessFile instance. 2476 * <br>This parameter is valid only when the application sandbox path of the file is passed in. 2477 * <br>One of the following options must be specified: 2478 * <br>OpenMode.READ_ONLY(0o0): Create the file in read-only mode. This is the default value. 2479 * <br>OpenMode.WRITE_ONLY(0o1): Create the file in write-only mode. 2480 * <br>OpenMode.READ_WRITE(0o2): Create the file in read/write mode. 2481 * <br>You can also specify the following options, separated by a bitwise OR operator (|). By default, 2482 * <br>no additional options are given. 2483 * <br>OpenMode.CREATE(0o100): If the file does not exist, create it. 2484 * <br>OpenMode.TRUNC(0o1000): If the RandomAccessFile object already exists and is created in write mode, 2485 * <br>truncate the file length to 0. 2486 * <br>OpenMode.APPEND(0o2000): Create the file in append mode. New data will be added to the end 2487 * <br>of the RandomAccessFile object. 2488 * <br>OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 2489 * <br>or character special file, perform non-blocking operations on the created file and in subsequent I/Os. 2490 * <br>OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 2491 * <br>OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 2492 * <br>OpenMode.SYNC(0o4010000): Create a RandomAccessFile instance in synchronous I/O mode. 2493 * @param { AsyncCallback<RandomAccessFile> } callback - Callback used to return the RandomAccessFile instance created. 2494 * @throws { BusinessError } 13900001 - Operation not permitted 2495 * @throws { BusinessError } 13900002 - No such file or directory 2496 * @throws { BusinessError } 13900004 - Interrupted system call 2497 * @throws { BusinessError } 13900006 - No such device or address 2498 * @throws { BusinessError } 13900008 - Bad file descriptor 2499 * @throws { BusinessError } 13900011 - Out of memory 2500 * @throws { BusinessError } 13900012 - Permission denied 2501 * @throws { BusinessError } 13900013 - Bad address 2502 * @throws { BusinessError } 13900014 - Device or resource busy 2503 * @throws { BusinessError } 13900015 - File exists 2504 * @throws { BusinessError } 13900017 - No such device 2505 * @throws { BusinessError } 13900018 - Not a directory 2506 * @throws { BusinessError } 13900019 - Is a directory 2507 * @throws { BusinessError } 13900020 - Invalid argument 2508 * @throws { BusinessError } 13900022 - Too many open files 2509 * @throws { BusinessError } 13900023 - Text file busy 2510 * @throws { BusinessError } 13900024 - File too large 2511 * @throws { BusinessError } 13900025 - No space left on device 2512 * @throws { BusinessError } 13900027 - Read-only file system 2513 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2514 * @throws { BusinessError } 13900030 - File name too long 2515 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2516 * @throws { BusinessError } 13900034 - Operation would block 2517 * @throws { BusinessError } 13900038 - Value too large for defined data type 2518 * @throws { BusinessError } 13900041 - Quota exceeded 2519 * @throws { BusinessError } 13900042 - Unknown error 2520 * @syscap SystemCapability.FileManagement.File.FileIO 2521 * @since 10 2522 */ 2523/** 2524 * Creates a RandomAccessFile instance based on a file path or file object. 2525 * This API uses an asynchronous callback to return the result. 2526 * 2527 * @param { string | File } file - Application sandbox path of the file or an opened file object. 2528 * @param { number } [mode = OpenMode.READ_ONLY] - Mode for creating the RandomAccessFile instance. 2529 * <br>This parameter is valid only when the application sandbox path of the file is passed in. 2530 * <br>One of the following options must be specified: 2531 * <br>OpenMode.READ_ONLY(0o0): Create the file in read-only mode. This is the default value. 2532 * <br>OpenMode.WRITE_ONLY(0o1): Create the file in write-only mode. 2533 * <br>OpenMode.READ_WRITE(0o2): Create the file in read/write mode. 2534 * <br>You can also specify the following options, separated by a bitwise OR operator (|). By default, 2535 * <br>no additional options are given. 2536 * <br>OpenMode.CREATE(0o100): If the file does not exist, create it. 2537 * <br>OpenMode.TRUNC(0o1000): If the RandomAccessFile object already exists and is created in write mode, 2538 * <br>truncate the file length to 0. 2539 * <br>OpenMode.APPEND(0o2000): Create the file in append mode. New data will be added to the end 2540 * <br>of the RandomAccessFile object. 2541 * <br>OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 2542 * <br>or character special file, perform non-blocking operations on the created file and in subsequent I/Os. 2543 * <br>OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 2544 * <br>OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 2545 * <br>OpenMode.SYNC(0o4010000): Create a RandomAccessFile instance in synchronous I/O mode. 2546 * @param { AsyncCallback<RandomAccessFile> } callback - Callback used to return the RandomAccessFile instance created. 2547 * @throws { BusinessError } 13900001 - Operation not permitted 2548 * @throws { BusinessError } 13900002 - No such file or directory 2549 * @throws { BusinessError } 13900004 - Interrupted system call 2550 * @throws { BusinessError } 13900006 - No such device or address 2551 * @throws { BusinessError } 13900008 - Bad file descriptor 2552 * @throws { BusinessError } 13900011 - Out of memory 2553 * @throws { BusinessError } 13900012 - Permission denied 2554 * @throws { BusinessError } 13900013 - Bad address 2555 * @throws { BusinessError } 13900014 - Device or resource busy 2556 * @throws { BusinessError } 13900015 - File exists 2557 * @throws { BusinessError } 13900017 - No such device 2558 * @throws { BusinessError } 13900018 - Not a directory 2559 * @throws { BusinessError } 13900019 - Is a directory 2560 * @throws { BusinessError } 13900020 - Invalid argument 2561 * @throws { BusinessError } 13900022 - Too many open files 2562 * @throws { BusinessError } 13900023 - Text file busy 2563 * @throws { BusinessError } 13900024 - File too large 2564 * @throws { BusinessError } 13900025 - No space left on device 2565 * @throws { BusinessError } 13900027 - Read-only file system 2566 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2567 * @throws { BusinessError } 13900030 - File name too long 2568 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2569 * @throws { BusinessError } 13900034 - Operation would block 2570 * @throws { BusinessError } 13900038 - Value too large for defined data type 2571 * @throws { BusinessError } 13900041 - Quota exceeded 2572 * @throws { BusinessError } 13900042 - Unknown error 2573 * @syscap SystemCapability.FileManagement.File.FileIO 2574 * @crossplatform 2575 * @since 20 2576 */ 2577declare function createRandomAccessFile(file: string | File, mode: number, callback: AsyncCallback<RandomAccessFile>): void; 2578 2579/** 2580 * Create class RandomAccessFile with sync interface. 2581 * 2582 * @param { string | File } file - file path, object. 2583 * @param { number } [mode = OpenMode.READ_ONLY] - mode. 2584 * @returns { RandomAccessFile } Returns the RandomAccessFile object which has been created. 2585 * @throws { BusinessError } 13900001 - Operation not permitted 2586 * @throws { BusinessError } 13900002 - No such file or directory 2587 * @throws { BusinessError } 13900004 - Interrupted system call 2588 * @throws { BusinessError } 13900006 - No such device or address 2589 * @throws { BusinessError } 13900008 - Bad file descriptor 2590 * @throws { BusinessError } 13900011 - Out of memory 2591 * @throws { BusinessError } 13900012 - Permission denied 2592 * @throws { BusinessError } 13900013 - Bad address 2593 * @throws { BusinessError } 13900014 - Device or resource busy 2594 * @throws { BusinessError } 13900015 - File exists 2595 * @throws { BusinessError } 13900017 - No such device 2596 * @throws { BusinessError } 13900018 - Not a directory 2597 * @throws { BusinessError } 13900019 - Is a directory 2598 * @throws { BusinessError } 13900020 - Invalid argument 2599 * @throws { BusinessError } 13900022 - Too many open files 2600 * @throws { BusinessError } 13900023 - Text file busy 2601 * @throws { BusinessError } 13900024 - File too large 2602 * @throws { BusinessError } 13900025 - No space left on device 2603 * @throws { BusinessError } 13900027 - Read-only file system 2604 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2605 * @throws { BusinessError } 13900030 - File name too long 2606 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2607 * @throws { BusinessError } 13900034 - Operation would block 2608 * @throws { BusinessError } 13900038 - Value too large for defined data type 2609 * @throws { BusinessError } 13900041 - Quota exceeded 2610 * @throws { BusinessError } 13900042 - Unknown error 2611 * @syscap SystemCapability.FileManagement.File.FileIO 2612 * @since 10 2613 */ 2614/** 2615 * Creates a RandomAccessFile instance based on a file path or file object. 2616 * 2617 * @param { string | File } file - Application sandbox path of the file or an opened file object. 2618 * @param { number } [mode = OpenMode.READ_ONLY] - Mode for creating the RandomAccessFile instance. 2619 * <br>This parameter is valid only when the application sandbox path of the file is passed in. 2620 * <br>One of the following options must be specified: 2621 * <br>OpenMode.READ_ONLY(0o0): Create the file in read-only mode. This is the default value. 2622 * <br>OpenMode.WRITE_ONLY(0o1): Create the file in write-only mode. 2623 * <br>OpenMode.READ_WRITE(0o2): Create the file in read/write mode. 2624 * <br>You can also specify the following options, separated by a bitwise OR operator (|). By default, 2625 * <br>no additional options are given. 2626 * <br>OpenMode.CREATE(0o100): If the file does not exist, create it. 2627 * <br>OpenMode.TRUNC(0o1000): If the RandomAccessFile object already exists and is created in write mode, 2628 * <br>truncate the file length to 0. 2629 * <br>OpenMode.APPEND(0o2000): Create the file in append mode. New data will be added to the end 2630 * <br>of the RandomAccessFile object. 2631 * <br>OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 2632 * <br>or character special file, perform non-blocking operations on the created file and in subsequent I/Os. 2633 * <br>OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 2634 * <br>OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 2635 * <br>OpenMode.SYNC(0o4010000): Create a RandomAccessFile instance in synchronous I/O mode. 2636 * @param { RandomAccessFileOptions } [options] - Defines the options used in createRandomAccessFile(). 2637 * @returns { RandomAccessFile } RandomAccessFile instance created. 2638 * @throws { BusinessError } 13900001 - Operation not permitted 2639 * @throws { BusinessError } 13900002 - No such file or directory 2640 * @throws { BusinessError } 13900004 - Interrupted system call 2641 * @throws { BusinessError } 13900006 - No such device or address 2642 * @throws { BusinessError } 13900008 - Bad file descriptor 2643 * @throws { BusinessError } 13900011 - Out of memory 2644 * @throws { BusinessError } 13900012 - Permission denied 2645 * @throws { BusinessError } 13900013 - Bad address 2646 * @throws { BusinessError } 13900014 - Device or resource busy 2647 * @throws { BusinessError } 13900015 - File exists 2648 * @throws { BusinessError } 13900017 - No such device 2649 * @throws { BusinessError } 13900018 - Not a directory 2650 * @throws { BusinessError } 13900019 - Is a directory 2651 * @throws { BusinessError } 13900020 - Invalid argument 2652 * @throws { BusinessError } 13900022 - Too many open files 2653 * @throws { BusinessError } 13900023 - Text file busy 2654 * @throws { BusinessError } 13900024 - File too large 2655 * @throws { BusinessError } 13900025 - No space left on device 2656 * @throws { BusinessError } 13900027 - Read-only file system 2657 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2658 * @throws { BusinessError } 13900030 - File name too long 2659 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2660 * @throws { BusinessError } 13900034 - Operation would block 2661 * @throws { BusinessError } 13900038 - Value too large for defined data type 2662 * @throws { BusinessError } 13900041 - Quota exceeded 2663 * @throws { BusinessError } 13900042 - Unknown error 2664 * @throws { BusinessError } 13900044 - Network is unreachable 2665 * @syscap SystemCapability.FileManagement.File.FileIO 2666 * @since 12 2667 */ 2668/** 2669 * Creates a RandomAccessFile instance based on a file path or file object. 2670 * 2671 * @param { string | File } file - Application sandbox path of the file or an opened file object. 2672 * @param { number } [mode = OpenMode.READ_ONLY] - Mode for creating the RandomAccessFile instance. 2673 * <br>This parameter is valid only when the application sandbox path of the file is passed in. 2674 * <br>One of the following options must be specified: 2675 * <br>OpenMode.READ_ONLY(0o0): Create the file in read-only mode. This is the default value. 2676 * <br>OpenMode.WRITE_ONLY(0o1): Create the file in write-only mode. 2677 * <br>OpenMode.READ_WRITE(0o2): Create the file in read/write mode. 2678 * <br>You can also specify the following options, separated by a bitwise OR operator (|). By default, 2679 * <br>no additional options are given. 2680 * <br>OpenMode.CREATE(0o100): If the file does not exist, create it. 2681 * <br>OpenMode.TRUNC(0o1000): If the RandomAccessFile object already exists and is created in write mode, 2682 * <br>truncate the file length to 0. 2683 * <br>OpenMode.APPEND(0o2000): Create the file in append mode. New data will be added to the end 2684 * <br>of the RandomAccessFile object. 2685 * <br>OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 2686 * <br>or character special file, perform non-blocking operations on the created file and in subsequent I/Os. 2687 * <br>OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 2688 * <br>OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 2689 * <br>OpenMode.SYNC(0o4010000): Create a RandomAccessFile instance in synchronous I/O mode. 2690 * @param { RandomAccessFileOptions } [options] - Defines the options used in createRandomAccessFile(). 2691 * @returns { RandomAccessFile } RandomAccessFile instance created. 2692 * @throws { BusinessError } 13900001 - Operation not permitted 2693 * @throws { BusinessError } 13900002 - No such file or directory 2694 * @throws { BusinessError } 13900004 - Interrupted system call 2695 * @throws { BusinessError } 13900006 - No such device or address 2696 * @throws { BusinessError } 13900008 - Bad file descriptor 2697 * @throws { BusinessError } 13900011 - Out of memory 2698 * @throws { BusinessError } 13900012 - Permission denied 2699 * @throws { BusinessError } 13900013 - Bad address 2700 * @throws { BusinessError } 13900014 - Device or resource busy 2701 * @throws { BusinessError } 13900015 - File exists 2702 * @throws { BusinessError } 13900017 - No such device 2703 * @throws { BusinessError } 13900018 - Not a directory 2704 * @throws { BusinessError } 13900019 - Is a directory 2705 * @throws { BusinessError } 13900020 - Invalid argument 2706 * @throws { BusinessError } 13900022 - Too many open files 2707 * @throws { BusinessError } 13900023 - Text file busy 2708 * @throws { BusinessError } 13900024 - File too large 2709 * @throws { BusinessError } 13900025 - No space left on device 2710 * @throws { BusinessError } 13900027 - Read-only file system 2711 * @throws { BusinessError } 13900029 - Resource deadlock would occur 2712 * @throws { BusinessError } 13900030 - File name too long 2713 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 2714 * @throws { BusinessError } 13900034 - Operation would block 2715 * @throws { BusinessError } 13900038 - Value too large for defined data type 2716 * @throws { BusinessError } 13900041 - Quota exceeded 2717 * @throws { BusinessError } 13900042 - Unknown error 2718 * @throws { BusinessError } 13900044 - Network is unreachable 2719 * @syscap SystemCapability.FileManagement.File.FileIO 2720 * @crossplatform 2721 * @since 20 2722 */ 2723declare function createRandomAccessFileSync(file: string | File, mode?: number, 2724 options?: RandomAccessFileOptions): RandomAccessFile; 2725 2726/** 2727 * Creates a readable stream. This API returns the result synchronously. 2728 * 2729 * @param { string } path - Path of the file. 2730 * @param { ReadStreamOptions } [options] - Defines the options used in createReadStream(). 2731 * @returns { ReadStream } ReadStream instance obtained. 2732 * @throws { BusinessError } 401 - Parameter error 2733 * @throws { BusinessError } 13900001 - Operation not permitted 2734 * @throws { BusinessError } 13900002 - No such file or directory 2735 * @throws { BusinessError } 13900004 - Interrupted system call 2736 * @throws { BusinessError } 13900011 - Out of memory 2737 * @throws { BusinessError } 13900012 - Permission denied 2738 * @throws { BusinessError } 13900017 - No such device 2739 * @throws { BusinessError } 13900019 - Is a directory 2740 * @throws { BusinessError } 13900020 - Invalid argument 2741 * @throws { BusinessError } 13900022 - Too many open files 2742 * @throws { BusinessError } 13900024 - File too large 2743 * @throws { BusinessError } 13900030 - File name too long 2744 * @throws { BusinessError } 13900038 - Value too large for defined data type 2745 * @throws { BusinessError } 13900041 - Quota exceeded 2746 * @throws { BusinessError } 13900042 - Unknown error 2747 * @throws { BusinessError } 13900044 - Network is unreachable 2748 * @syscap SystemCapability.FileManagement.File.FileIO 2749 * @since 12 2750 */ 2751/** 2752 * Creates a readable stream. This API returns the result synchronously. 2753 * 2754 * @param { string } path - Path of the file. 2755 * @param { ReadStreamOptions } [options] - The options are as follows: 2756 * <br>start (number): start position of the data to read in the file. This parameter is optional. 2757 * <br>By default, data is read from the current position. 2758 * <br>end (number): end position of the data to read in the file. This parameter is optional. 2759 * <br>The default value is the end of the file. 2760 * @returns { ReadStream } ReadStream instance obtained. 2761 * @throws { BusinessError } 401 - Parameter error 2762 * @throws { BusinessError } 13900001 - Operation not permitted 2763 * @throws { BusinessError } 13900002 - No such file or directory 2764 * @throws { BusinessError } 13900004 - Interrupted system call 2765 * @throws { BusinessError } 13900011 - Out of memory 2766 * @throws { BusinessError } 13900012 - Permission denied 2767 * @throws { BusinessError } 13900017 - No such device 2768 * @throws { BusinessError } 13900019 - Is a directory 2769 * @throws { BusinessError } 13900020 - Invalid argument 2770 * @throws { BusinessError } 13900022 - Too many open files 2771 * @throws { BusinessError } 13900024 - File too large 2772 * @throws { BusinessError } 13900030 - File name too long 2773 * @throws { BusinessError } 13900038 - Value too large for defined data type 2774 * @throws { BusinessError } 13900041 - Quota exceeded 2775 * @throws { BusinessError } 13900042 - Unknown error 2776 * @throws { BusinessError } 13900044 - Network is unreachable 2777 * @syscap SystemCapability.FileManagement.File.FileIO 2778 * @crossplatform 2779 * @since 20 2780 */ 2781declare function createReadStream(path: string, options?: ReadStreamOptions): ReadStream; 2782 2783/** 2784 * Creates a writeable stream. This API returns the result synchronously. 2785 * 2786 * @param { string } path - Path of the file. 2787 * @param { WriteStreamOptions } [options] - Defines the options used in createWriteStream(). 2788 * @returns { WriteStream } ReadStream instance obtained. 2789 * @throws { BusinessError } 401 - Parameter error 2790 * @throws { BusinessError } 13900001 - Operation not permitted 2791 * @throws { BusinessError } 13900002 - No such file or directory 2792 * @throws { BusinessError } 13900004 - Interrupted system call 2793 * @throws { BusinessError } 13900011 - Out of memory 2794 * @throws { BusinessError } 13900012 - Permission denied 2795 * @throws { BusinessError } 13900015 - File exists 2796 * @throws { BusinessError } 13900017 - No such device 2797 * @throws { BusinessError } 13900019 - Is a directory 2798 * @throws { BusinessError } 13900020 - Invalid argument 2799 * @throws { BusinessError } 13900022 - Too many open files 2800 * @throws { BusinessError } 13900024 - File too large 2801 * @throws { BusinessError } 13900025 - No space left on device 2802 * @throws { BusinessError } 13900027 - Read-only file system 2803 * @throws { BusinessError } 13900030 - File name too long 2804 * @throws { BusinessError } 13900038 - Value too large for defined data type 2805 * @throws { BusinessError } 13900041 - Quota exceeded 2806 * @throws { BusinessError } 13900042 - Unknown error 2807 * @syscap SystemCapability.FileManagement.File.FileIO 2808 * @since 12 2809 */ 2810/** 2811 * Creates a writeable stream. This API returns the result synchronously. 2812 * 2813 * @param { string } path - Path of the file. 2814 * @param { WriteStreamOptions } [options] - The options are as follows: 2815 * <br>start (number): start position to write the data in the file. This parameter is optional. 2816 * <br>By default, data is written from the current position. 2817 * <br>mode (number): mode for creating the writeable stream. This parameter is optional. 2818 * <br>The default value is the write-only mode. 2819 * @returns { WriteStream } ReadStream instance obtained. 2820 * @throws { BusinessError } 401 - Parameter error 2821 * @throws { BusinessError } 13900001 - Operation not permitted 2822 * @throws { BusinessError } 13900002 - No such file or directory 2823 * @throws { BusinessError } 13900004 - Interrupted system call 2824 * @throws { BusinessError } 13900011 - Out of memory 2825 * @throws { BusinessError } 13900012 - Permission denied 2826 * @throws { BusinessError } 13900015 - File exists 2827 * @throws { BusinessError } 13900017 - No such device 2828 * @throws { BusinessError } 13900019 - Is a directory 2829 * @throws { BusinessError } 13900020 - Invalid argument 2830 * @throws { BusinessError } 13900022 - Too many open files 2831 * @throws { BusinessError } 13900024 - File too large 2832 * @throws { BusinessError } 13900025 - No space left on device 2833 * @throws { BusinessError } 13900027 - Read-only file system 2834 * @throws { BusinessError } 13900030 - File name too long 2835 * @throws { BusinessError } 13900038 - Value too large for defined data type 2836 * @throws { BusinessError } 13900041 - Quota exceeded 2837 * @throws { BusinessError } 13900042 - Unknown error 2838 * @syscap SystemCapability.FileManagement.File.FileIO 2839 * @crossplatform 2840 * @since 20 2841 */ 2842declare function createWriteStream(path: string, options?: WriteStreamOptions): WriteStream; 2843 2844/** 2845 * Creates a Watcher object to listen for file or directory changes. 2846 * 2847 * @param { string } path - Application sandbox path of the file or directory to observe. 2848 * @param { number } events - Events to observe. Multiple events can be separated by a bitwise OR operator (|). 2849 * @param { WatchEventListener } listener - Callback invoked when an observed event occurs. 2850 * <br>The callback will be invoked each time an observed event occurs. 2851 * @returns { Watcher } Watcher object created. 2852 * @throws { BusinessError } 13900002 - No such file or directory 2853 * @throws { BusinessError } 13900008 - Bad file descriptor 2854 * @throws { BusinessError } 13900011 - Out of memory 2855 * @throws { BusinessError } 13900012 - Permission denied 2856 * @throws { BusinessError } 13900013 - Bad address 2857 * @throws { BusinessError } 13900015 - File exists 2858 * @throws { BusinessError } 13900018 - Not a directory 2859 * @throws { BusinessError } 13900020 - Invalid argument 2860 * @throws { BusinessError } 13900021 - File table overflow 2861 * @throws { BusinessError } 13900022 - Too many open files 2862 * @throws { BusinessError } 13900025 - No space left on device 2863 * @throws { BusinessError } 13900030 - File name too long 2864 * @throws { BusinessError } 13900042 - Unknown error 2865 * @syscap SystemCapability.FileManagement.File.FileIO 2866 * @since 10 2867 */ 2868/** 2869 * Creates a Watcher object to listen for file or directory changes. 2870 * 2871 * @param { string } path - Application sandbox path of the file or directory to observe. 2872 * @param { number } events - Events to observe. Multiple events can be separated by a bitwise OR operator (|). 2873 * @param { WatchEventListener } listener - Callback invoked when an observed event occurs. 2874 * <br>The callback will be invoked each time an observed event occurs. 2875 * @returns { Watcher } Watcher object created. 2876 * @throws { BusinessError } 13900002 - No such file or directory 2877 * @throws { BusinessError } 13900008 - Bad file descriptor 2878 * @throws { BusinessError } 13900011 - Out of memory 2879 * @throws { BusinessError } 13900012 - Permission denied 2880 * @throws { BusinessError } 13900013 - Bad address 2881 * @throws { BusinessError } 13900015 - File exists 2882 * @throws { BusinessError } 13900018 - Not a directory 2883 * @throws { BusinessError } 13900020 - Invalid argument 2884 * @throws { BusinessError } 13900021 - File table overflow 2885 * @throws { BusinessError } 13900022 - Too many open files 2886 * @throws { BusinessError } 13900025 - No space left on device 2887 * @throws { BusinessError } 13900030 - File name too long 2888 * @throws { BusinessError } 13900042 - Unknown error 2889 * @syscap SystemCapability.FileManagement.File.FileIO 2890 * @crossplatform 2891 * @since 20 2892 */ 2893declare function createWatcher(path: string, events: number, listener: WatchEventListener): Watcher; 2894 2895/** 2896 * Opens a File object based on an FD. 2897 * 2898 * @param { number } fd - FD of the file. 2899 * @returns { File } File object opened. 2900 * @throws { BusinessError } 13900004 - Interrupted system call 2901 * @throws { BusinessError } 13900005 - I/O error 2902 * @throws { BusinessError } 13900008 - Bad file descriptor 2903 * @throws { BusinessError } 13900014 - Device or resource busy 2904 * @throws { BusinessError } 13900020 - Invalid argument 2905 * @throws { BusinessError } 13900022 - Too many open files 2906 * @throws { BusinessError } 13900042 - Unknown error 2907 * @syscap SystemCapability.FileManagement.File.FileIO 2908 * @since 10 2909 */ 2910declare function dup(fd: number): File; 2911 2912/** 2913 * Synchronize file metadata. 2914 * 2915 * @param { number } fd - fd. 2916 * @returns { Promise<void> } The promise returned by the function. 2917 * @throws { BusinessError } 13900005 - I/O error 2918 * @throws { BusinessError } 13900008 - Bad file descriptor 2919 * @throws { BusinessError } 13900020 - Invalid argument 2920 * @throws { BusinessError } 13900025 - No space left on device 2921 * @throws { BusinessError } 13900027 - Read-only file system 2922 * @throws { BusinessError } 13900041 - Quota exceeded 2923 * @throws { BusinessError } 13900042 - Unknown error 2924 * @syscap SystemCapability.FileManagement.File.FileIO 2925 * @since 9 2926 */ 2927/** 2928 * Synchronizes the data of a file. This API uses a promise to return the result. 2929 * 2930 * @param { number } fd - FD of the file. 2931 * @returns { Promise<void> } Promise that returns no value. 2932 * @throws { BusinessError } 13900005 - I/O error 2933 * @throws { BusinessError } 13900008 - Bad file descriptor 2934 * @throws { BusinessError } 13900020 - Invalid argument 2935 * @throws { BusinessError } 13900025 - No space left on device 2936 * @throws { BusinessError } 13900027 - Read-only file system 2937 * @throws { BusinessError } 13900041 - Quota exceeded 2938 * @throws { BusinessError } 13900042 - Unknown error 2939 * @syscap SystemCapability.FileManagement.File.FileIO 2940 * @crossplatform 2941 * @since 10 2942 */ 2943declare function fdatasync(fd: number): Promise<void>; 2944 2945/** 2946 * Synchronize file metadata. 2947 * 2948 * @param { number } fd - fd. 2949 * @param { AsyncCallback<void> } callback - Return the callback function. 2950 * @throws { BusinessError } 13900005 - I/O error 2951 * @throws { BusinessError } 13900008 - Bad file descriptor 2952 * @throws { BusinessError } 13900020 - Invalid argument 2953 * @throws { BusinessError } 13900025 - No space left on device 2954 * @throws { BusinessError } 13900027 - Read-only file system 2955 * @throws { BusinessError } 13900041 - Quota exceeded 2956 * @throws { BusinessError } 13900042 - Unknown error 2957 * @syscap SystemCapability.FileManagement.File.FileIO 2958 * @since 9 2959 */ 2960/** 2961 * Synchronizes the data (excluding the metadata) of a file. 2962 * This API uses an asynchronous callback to return the result. 2963 * 2964 * @param { number } fd - FD of the file. 2965 * @param { AsyncCallback<void> } callback - Callback used to return the result. 2966 * @throws { BusinessError } 13900005 - I/O error 2967 * @throws { BusinessError } 13900008 - Bad file descriptor 2968 * @throws { BusinessError } 13900020 - Invalid argument 2969 * @throws { BusinessError } 13900025 - No space left on device 2970 * @throws { BusinessError } 13900027 - Read-only file system 2971 * @throws { BusinessError } 13900041 - Quota exceeded 2972 * @throws { BusinessError } 13900042 - Unknown error 2973 * @syscap SystemCapability.FileManagement.File.FileIO 2974 * @crossplatform 2975 * @since 10 2976 */ 2977declare function fdatasync(fd: number, callback: AsyncCallback<void>): void; 2978 2979/** 2980 * Synchronize file metadata with sync interface. 2981 * 2982 * @param { number } fd - fd. 2983 * @throws { BusinessError } 13900005 - I/O error 2984 * @throws { BusinessError } 13900008 - Bad file descriptor 2985 * @throws { BusinessError } 13900020 - Invalid argument 2986 * @throws { BusinessError } 13900025 - No space left on device 2987 * @throws { BusinessError } 13900027 - Read-only file system 2988 * @throws { BusinessError } 13900041 - Quota exceeded 2989 * @throws { BusinessError } 13900042 - Unknown error 2990 * @syscap SystemCapability.FileManagement.File.FileIO 2991 * @since 9 2992 */ 2993/** 2994 * Synchronizes the data of a file. This API returns the result synchronously. 2995 * 2996 * @param { number } fd - FD of the file. 2997 * @throws { BusinessError } 13900005 - I/O error 2998 * @throws { BusinessError } 13900008 - Bad file descriptor 2999 * @throws { BusinessError } 13900020 - Invalid argument 3000 * @throws { BusinessError } 13900025 - No space left on device 3001 * @throws { BusinessError } 13900027 - Read-only file system 3002 * @throws { BusinessError } 13900041 - Quota exceeded 3003 * @throws { BusinessError } 13900042 - Unknown error 3004 * @syscap SystemCapability.FileManagement.File.FileIO 3005 * @crossplatform 3006 * @since 10 3007 */ 3008declare function fdatasyncSync(fd: number): void; 3009 3010/** 3011 * Opens a stream based on an FD. This API uses a promise to return the result. To close the stream, 3012 * use close() of Stream. 3013 * 3014 * @param { number } fd - FD of the file. 3015 * @param { string } mode - r: Open a file for reading. The file must exist. 3016 * <br>r+: Open a file for both reading and writing. The file must exist. 3017 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 3018 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 3019 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 3020 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 3021 * <br>a+: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, 3022 * <br>create a file. If the file exists, write data to the end of the file (the original content of the file is reserved). 3023 * @returns { Promise<Stream> } Returns the Stream object in promise mode. 3024 * @throws { BusinessError } 13900001 - Operation not permitted 3025 * @throws { BusinessError } 13900002 - No such file or directory 3026 * @throws { BusinessError } 13900004 - Interrupted system call 3027 * @throws { BusinessError } 13900006 - No such device or address 3028 * @throws { BusinessError } 13900008 - Bad file descriptor 3029 * @throws { BusinessError } 13900010 - Try again 3030 * @throws { BusinessError } 13900011 - Out of memory 3031 * @throws { BusinessError } 13900012 - Permission denied 3032 * @throws { BusinessError } 13900013 - Bad address 3033 * @throws { BusinessError } 13900014 - Device or resource busy 3034 * @throws { BusinessError } 13900015 - File exists 3035 * @throws { BusinessError } 13900017 - No such device 3036 * @throws { BusinessError } 13900018 - Not a directory 3037 * @throws { BusinessError } 13900019 - Is a directory 3038 * @throws { BusinessError } 13900020 - Invalid argument 3039 * @throws { BusinessError } 13900022 - Too many open files 3040 * @throws { BusinessError } 13900023 - Text file busy 3041 * @throws { BusinessError } 13900024 - File too large 3042 * @throws { BusinessError } 13900025 - No space left on device 3043 * @throws { BusinessError } 13900027 - Read-only file system 3044 * @throws { BusinessError } 13900029 - Resource deadlock would occur 3045 * @throws { BusinessError } 13900030 - File name too long 3046 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3047 * @throws { BusinessError } 13900034 - Operation would block 3048 * @throws { BusinessError } 13900038 - Value too large for defined data type 3049 * @throws { BusinessError } 13900041 - Quota exceeded 3050 * @throws { BusinessError } 13900042 - Unknown error 3051 * @syscap SystemCapability.FileManagement.File.FileIO 3052 * @since 9 3053 */ 3054/** 3055 * Opens a stream based on an FD. This API uses a promise to return the result. To close the stream, 3056 * use close() of Stream. 3057 * 3058 * @param { number } fd - FD of the file. 3059 * @param { string } mode - r: Open a file for reading. The file must exist. 3060 * <br>r+: Open a file for both reading and writing. The file must exist. 3061 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 3062 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 3063 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 3064 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 3065 * <br>a+: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, 3066 * <br>create a file. If the file exists, write data to the end of the file (the original content of the file is reserved). 3067 * @returns { Promise<Stream> } Returns the Stream object in promise mode. 3068 * @throws { BusinessError } 13900001 - Operation not permitted 3069 * @throws { BusinessError } 13900002 - No such file or directory 3070 * @throws { BusinessError } 13900004 - Interrupted system call 3071 * @throws { BusinessError } 13900006 - No such device or address 3072 * @throws { BusinessError } 13900008 - Bad file descriptor 3073 * @throws { BusinessError } 13900010 - Try again 3074 * @throws { BusinessError } 13900011 - Out of memory 3075 * @throws { BusinessError } 13900012 - Permission denied 3076 * @throws { BusinessError } 13900013 - Bad address 3077 * @throws { BusinessError } 13900014 - Device or resource busy 3078 * @throws { BusinessError } 13900015 - File exists 3079 * @throws { BusinessError } 13900017 - No such device 3080 * @throws { BusinessError } 13900018 - Not a directory 3081 * @throws { BusinessError } 13900019 - Is a directory 3082 * @throws { BusinessError } 13900020 - Invalid argument 3083 * @throws { BusinessError } 13900022 - Too many open files 3084 * @throws { BusinessError } 13900023 - Text file busy 3085 * @throws { BusinessError } 13900024 - File too large 3086 * @throws { BusinessError } 13900025 - No space left on device 3087 * @throws { BusinessError } 13900027 - Read-only file system 3088 * @throws { BusinessError } 13900029 - Resource deadlock would occur 3089 * @throws { BusinessError } 13900030 - File name too long 3090 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3091 * @throws { BusinessError } 13900034 - Operation would block 3092 * @throws { BusinessError } 13900038 - Value too large for defined data type 3093 * @throws { BusinessError } 13900041 - Quota exceeded 3094 * @throws { BusinessError } 13900042 - Unknown error 3095 * @syscap SystemCapability.FileManagement.File.FileIO 3096 * @crossplatform 3097 * @atomicservice 3098 * @since 20 3099 */ 3100declare function fdopenStream(fd: number, mode: string): Promise<Stream>; 3101 3102/** 3103 * Opens a stream based on an FD. This API uses an asynchronous callback to return the result. 3104 * To close the stream, use close() of Stream. 3105 * 3106 * @param { number } fd - FD of the file. 3107 * @param { string } mode - r: Open a file for reading. The file must exist. 3108 * <br>r+: Open a file for both reading and writing. The file must exist. 3109 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 3110 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 3111 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 3112 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 3113 * <br>a+: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, 3114 * <br>create a file. If the file exists, write data to the end of the file (the original content of the file is reserved). 3115 * @param { AsyncCallback<Stream> } callback - Callback used to return the result. 3116 * @throws { BusinessError } 13900001 - Operation not permitted 3117 * @throws { BusinessError } 13900002 - No such file or directory 3118 * @throws { BusinessError } 13900004 - Interrupted system call 3119 * @throws { BusinessError } 13900006 - No such device or address 3120 * @throws { BusinessError } 13900008 - Bad file descriptor 3121 * @throws { BusinessError } 13900010 - Try again 3122 * @throws { BusinessError } 13900011 - Out of memory 3123 * @throws { BusinessError } 13900012 - Permission denied 3124 * @throws { BusinessError } 13900013 - Bad address 3125 * @throws { BusinessError } 13900014 - Device or resource busy 3126 * @throws { BusinessError } 13900015 - File exists 3127 * @throws { BusinessError } 13900017 - No such device 3128 * @throws { BusinessError } 13900018 - Not a directory 3129 * @throws { BusinessError } 13900019 - Is a directory 3130 * @throws { BusinessError } 13900020 - Invalid argument 3131 * @throws { BusinessError } 13900022 - Too many open files 3132 * @throws { BusinessError } 13900023 - Text file busy 3133 * @throws { BusinessError } 13900024 - File too large 3134 * @throws { BusinessError } 13900025 - No space left on device 3135 * @throws { BusinessError } 13900027 - Read-only file system 3136 * @throws { BusinessError } 13900029 - Resource deadlock would occur 3137 * @throws { BusinessError } 13900030 - File name too long 3138 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3139 * @throws { BusinessError } 13900034 - Operation would block 3140 * @throws { BusinessError } 13900038 - Value too large for defined data type 3141 * @throws { BusinessError } 13900041 - Quota exceeded 3142 * @throws { BusinessError } 13900042 - Unknown error 3143 * @syscap SystemCapability.FileManagement.File.FileIO 3144 * @since 9 3145 */ 3146/** 3147 * Opens a stream based on an FD. This API uses an asynchronous callback to return the result. 3148 * To close the stream, use close() of Stream. 3149 * 3150 * @param { number } fd - FD of the file. 3151 * @param { string } mode - r: Open a file for reading. The file must exist. 3152 * <br>r+: Open a file for both reading and writing. The file must exist. 3153 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 3154 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 3155 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 3156 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 3157 * <br>a+: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, 3158 * <br>create a file. If the file exists, write data to the end of the file (the original content of the file is reserved). 3159 * @param { AsyncCallback<Stream> } callback - Callback used to return the result. 3160 * @throws { BusinessError } 13900001 - Operation not permitted 3161 * @throws { BusinessError } 13900002 - No such file or directory 3162 * @throws { BusinessError } 13900004 - Interrupted system call 3163 * @throws { BusinessError } 13900006 - No such device or address 3164 * @throws { BusinessError } 13900008 - Bad file descriptor 3165 * @throws { BusinessError } 13900010 - Try again 3166 * @throws { BusinessError } 13900011 - Out of memory 3167 * @throws { BusinessError } 13900012 - Permission denied 3168 * @throws { BusinessError } 13900013 - Bad address 3169 * @throws { BusinessError } 13900014 - Device or resource busy 3170 * @throws { BusinessError } 13900015 - File exists 3171 * @throws { BusinessError } 13900017 - No such device 3172 * @throws { BusinessError } 13900018 - Not a directory 3173 * @throws { BusinessError } 13900019 - Is a directory 3174 * @throws { BusinessError } 13900020 - Invalid argument 3175 * @throws { BusinessError } 13900022 - Too many open files 3176 * @throws { BusinessError } 13900023 - Text file busy 3177 * @throws { BusinessError } 13900024 - File too large 3178 * @throws { BusinessError } 13900025 - No space left on device 3179 * @throws { BusinessError } 13900027 - Read-only file system 3180 * @throws { BusinessError } 13900029 - Resource deadlock would occur 3181 * @throws { BusinessError } 13900030 - File name too long 3182 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3183 * @throws { BusinessError } 13900034 - Operation would block 3184 * @throws { BusinessError } 13900038 - Value too large for defined data type 3185 * @throws { BusinessError } 13900041 - Quota exceeded 3186 * @throws { BusinessError } 13900042 - Unknown error 3187 * @syscap SystemCapability.FileManagement.File.FileIO 3188 * @crossplatform 3189 * @atomicservice 3190 * @since 20 3191 */ 3192declare function fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): void; 3193 3194/** 3195 * Opens a stream based on an FD. This API returns the result synchronously. To close the stream, use close() of Stream. 3196 * 3197 * @param { number } fd - FD of the file. 3198 * @param { string } mode - r: Open a file for reading. The file must exist. 3199 * <br>r+: Open a file for both reading and writing. The file must exist. 3200 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 3201 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 3202 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 3203 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 3204 * <br>a+: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, 3205 * <br>create a file. If the file exists, write data to the end of the file (the original content of the file is reserved). 3206 * @returns { Stream } Returns the Stream object. 3207 * @throws { BusinessError } 13900001 - Operation not permitted 3208 * @throws { BusinessError } 13900002 - No such file or directory 3209 * @throws { BusinessError } 13900004 - Interrupted system call 3210 * @throws { BusinessError } 13900006 - No such device or address 3211 * @throws { BusinessError } 13900008 - Bad file descriptor 3212 * @throws { BusinessError } 13900010 - Try again 3213 * @throws { BusinessError } 13900011 - Out of memory 3214 * @throws { BusinessError } 13900012 - Permission denied 3215 * @throws { BusinessError } 13900013 - Bad address 3216 * @throws { BusinessError } 13900014 - Device or resource busy 3217 * @throws { BusinessError } 13900015 - File exists 3218 * @throws { BusinessError } 13900017 - No such device 3219 * @throws { BusinessError } 13900018 - Not a directory 3220 * @throws { BusinessError } 13900019 - Is a directory 3221 * @throws { BusinessError } 13900020 - Invalid argument 3222 * @throws { BusinessError } 13900022 - Too many open files 3223 * @throws { BusinessError } 13900023 - Text file busy 3224 * @throws { BusinessError } 13900024 - File too large 3225 * @throws { BusinessError } 13900025 - No space left on device 3226 * @throws { BusinessError } 13900027 - Read-only file system 3227 * @throws { BusinessError } 13900029 - Resource deadlock would occur 3228 * @throws { BusinessError } 13900030 - File name too long 3229 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3230 * @throws { BusinessError } 13900034 - Operation would block 3231 * @throws { BusinessError } 13900038 - Value too large for defined data type 3232 * @throws { BusinessError } 13900041 - Quota exceeded 3233 * @throws { BusinessError } 13900042 - Unknown error 3234 * @syscap SystemCapability.FileManagement.File.FileIO 3235 * @since 9 3236 */ 3237/** 3238 * Opens a stream based on an FD. This API returns the result synchronously. To close the stream, use close() of Stream. 3239 * 3240 * @param { number } fd - FD of the file. 3241 * @param { string } mode - r: Open a file for reading. The file must exist. 3242 * <br>r+: Open a file for both reading and writing. The file must exist. 3243 * <br>w: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file. 3244 * <br>w+: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file. 3245 * <br>a: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. 3246 * <br>If the file exists, write data to the end of the file (the original content of the file is reserved). 3247 * <br>a+: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, 3248 * <br>create a file. If the file exists, write data to the end of the file (the original content of the file is reserved). 3249 * @returns { Stream } Returns the Stream object. 3250 * @throws { BusinessError } 13900001 - Operation not permitted 3251 * @throws { BusinessError } 13900002 - No such file or directory 3252 * @throws { BusinessError } 13900004 - Interrupted system call 3253 * @throws { BusinessError } 13900006 - No such device or address 3254 * @throws { BusinessError } 13900008 - Bad file descriptor 3255 * @throws { BusinessError } 13900010 - Try again 3256 * @throws { BusinessError } 13900011 - Out of memory 3257 * @throws { BusinessError } 13900012 - Permission denied 3258 * @throws { BusinessError } 13900013 - Bad address 3259 * @throws { BusinessError } 13900014 - Device or resource busy 3260 * @throws { BusinessError } 13900015 - File exists 3261 * @throws { BusinessError } 13900017 - No such device 3262 * @throws { BusinessError } 13900018 - Not a directory 3263 * @throws { BusinessError } 13900019 - Is a directory 3264 * @throws { BusinessError } 13900020 - Invalid argument 3265 * @throws { BusinessError } 13900022 - Too many open files 3266 * @throws { BusinessError } 13900023 - Text file busy 3267 * @throws { BusinessError } 13900024 - File too large 3268 * @throws { BusinessError } 13900025 - No space left on device 3269 * @throws { BusinessError } 13900027 - Read-only file system 3270 * @throws { BusinessError } 13900029 - Resource deadlock would occur 3271 * @throws { BusinessError } 13900030 - File name too long 3272 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3273 * @throws { BusinessError } 13900034 - Operation would block 3274 * @throws { BusinessError } 13900038 - Value too large for defined data type 3275 * @throws { BusinessError } 13900041 - Quota exceeded 3276 * @throws { BusinessError } 13900042 - Unknown error 3277 * @syscap SystemCapability.FileManagement.File.FileIO 3278 * @crossplatform 3279 * @atomicservice 3280 * @since 20 3281 */ 3282declare function fdopenStreamSync(fd: number, mode: string): Stream; 3283 3284/** 3285 * Synchronize file. 3286 * 3287 * @param { number } fd - fd. 3288 * @returns { Promise<void> } The promise returned by the function. 3289 * @throws { BusinessError } 13900005 - I/O error 3290 * @throws { BusinessError } 13900008 - Bad file descriptor 3291 * @throws { BusinessError } 13900020 - Invalid argument 3292 * @throws { BusinessError } 13900025 - No space left on device 3293 * @throws { BusinessError } 13900027 - Read-only file system 3294 * @throws { BusinessError } 13900041 - Quota exceeded 3295 * @throws { BusinessError } 13900042 - Unknown error 3296 * @syscap SystemCapability.FileManagement.File.FileIO 3297 * @since 9 3298 */ 3299/** 3300 * Synchronizes the cached data of a file to storage. This API uses a promise to return the result. 3301 * 3302 * @param { number } fd - FD of the file. 3303 * @returns { Promise<void> } The promise returned by the function. 3304 * @throws { BusinessError } 13900005 - I/O error 3305 * @throws { BusinessError } 13900008 - Bad file descriptor 3306 * @throws { BusinessError } 13900020 - Invalid argument 3307 * @throws { BusinessError } 13900025 - No space left on device 3308 * @throws { BusinessError } 13900027 - Read-only file system 3309 * @throws { BusinessError } 13900041 - Quota exceeded 3310 * @throws { BusinessError } 13900042 - Unknown error 3311 * @syscap SystemCapability.FileManagement.File.FileIO 3312 * @crossplatform 3313 * @since 10 3314 */ 3315declare function fsync(fd: number): Promise<void>; 3316 3317/** 3318 * Synchronize file. 3319 * 3320 * @param { number } fd - fd. 3321 * @param { AsyncCallback<void> } callback - Return the callback function. 3322 * @throws { BusinessError } 13900005 - I/O error 3323 * @throws { BusinessError } 13900008 - Bad file descriptor 3324 * @throws { BusinessError } 13900020 - Invalid argument 3325 * @throws { BusinessError } 13900025 - No space left on device 3326 * @throws { BusinessError } 13900027 - Read-only file system 3327 * @throws { BusinessError } 13900041 - Quota exceeded 3328 * @throws { BusinessError } 13900042 - Unknown error 3329 * @syscap SystemCapability.FileManagement.File.FileIO 3330 * @since 9 3331 */ 3332/** 3333 * Synchronizes the cached data of a file to storage. This API uses an asynchronous callback to return the result. 3334 * 3335 * @param { number } fd - FD of the file. 3336 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3337 * @throws { BusinessError } 13900005 - I/O error 3338 * @throws { BusinessError } 13900008 - Bad file descriptor 3339 * @throws { BusinessError } 13900020 - Invalid argument 3340 * @throws { BusinessError } 13900025 - No space left on device 3341 * @throws { BusinessError } 13900027 - Read-only file system 3342 * @throws { BusinessError } 13900041 - Quota exceeded 3343 * @throws { BusinessError } 13900042 - Unknown error 3344 * @syscap SystemCapability.FileManagement.File.FileIO 3345 * @crossplatform 3346 * @since 10 3347 */ 3348declare function fsync(fd: number, callback: AsyncCallback<void>): void; 3349 3350/** 3351 * Synchronize file with sync interface. 3352 * 3353 * @param { number } fd - fd. 3354 * @throws { BusinessError } 13900005 - I/O error 3355 * @throws { BusinessError } 13900008 - Bad file descriptor 3356 * @throws { BusinessError } 13900020 - Invalid argument 3357 * @throws { BusinessError } 13900025 - No space left on device 3358 * @throws { BusinessError } 13900027 - Read-only file system 3359 * @throws { BusinessError } 13900041 - Quota exceeded 3360 * @throws { BusinessError } 13900042 - Unknown error 3361 * @syscap SystemCapability.FileManagement.File.FileIO 3362 * @since 9 3363 */ 3364/** 3365 * Synchronizes the cached data of a file to storage. This API returns the result synchronously. 3366 * 3367 * @param { number } fd - FD of the file. 3368 * @throws { BusinessError } 13900005 - I/O error 3369 * @throws { BusinessError } 13900008 - Bad file descriptor 3370 * @throws { BusinessError } 13900020 - Invalid argument 3371 * @throws { BusinessError } 13900025 - No space left on device 3372 * @throws { BusinessError } 13900027 - Read-only file system 3373 * @throws { BusinessError } 13900041 - Quota exceeded 3374 * @throws { BusinessError } 13900042 - Unknown error 3375 * @syscap SystemCapability.FileManagement.File.FileIO 3376 * @crossplatform 3377 * @since 10 3378 */ 3379declare function fsyncSync(fd: number): void; 3380 3381/** 3382 * List file. 3383 * 3384 * @param { string } path - path. 3385 * @param { object } [options] - options. 3386 * @returns { Promise<string[]> } Returns an Array containing the name of files or directories that meet the filter criteria in promise mode. 3387 * If present, Include the subdirectory structure. 3388 * @throws { BusinessError } 13900002 - No such file or directory 3389 * @throws { BusinessError } 13900008 - Bad file descriptor 3390 * @throws { BusinessError } 13900011 - Out of memory 3391 * @throws { BusinessError } 13900018 - Not a directory 3392 * @throws { BusinessError } 13900042 - Unknown error 3393 * @syscap SystemCapability.FileManagement.File.FileIO 3394 * @since 9 3395 */ 3396/** 3397 * List file. 3398 * 3399 * @param { string } path - path. 3400 * @param { object } [options] - options. 3401 * @returns { Promise<string[]> } Returns an Array containing the name of files or directories that meet the filter criteria. 3402 * If present, Include the subdirectory structure. 3403 * @throws { BusinessError } 13900002 - No such file or directory 3404 * @throws { BusinessError } 13900008 - Bad file descriptor 3405 * @throws { BusinessError } 13900011 - Out of memory 3406 * @throws { BusinessError } 13900018 - Not a directory 3407 * @throws { BusinessError } 13900042 - Unknown error 3408 * @syscap SystemCapability.FileManagement.File.FileIO 3409 * @crossplatform 3410 * @since 10 3411 */ 3412/** 3413 * Lists all file names in a directory. This API supports recursive listing of all file names and file filtering. 3414 * The returned result starts with a slash (/) and contains the subdirectory. This API uses a promise to return the result. 3415 * 3416 * @param { string } path - Application sandbox path of the directory. 3417 * @param { ListFileOptions } [options] - Options for filtering files. The files are not filtered by default. 3418 * @returns { Promise<string[]> } Promise used to return the file names listed. 3419 * @throws { BusinessError } 13900002 - No such file or directory 3420 * @throws { BusinessError } 13900008 - Bad file descriptor 3421 * @throws { BusinessError } 13900011 - Out of memory 3422 * @throws { BusinessError } 13900018 - Not a directory 3423 * @throws { BusinessError } 13900042 - Unknown error 3424 * @syscap SystemCapability.FileManagement.File.FileIO 3425 * @crossplatform 3426 * @atomicservice 3427 * @since 11 3428 */ 3429declare function listFile( 3430 path: string, 3431 options?: ListFileOptions 3432): Promise<string[]>; 3433 3434/** 3435 * List file. 3436 * 3437 * @param { string } path - path. 3438 * @param { AsyncCallback<string[]> } callback - The callback is used to return an Array containing the name of files or directories 3439 * that meet the filter criteria in promise mode. If present, Include the subdirectory structure. 3440 * @throws { BusinessError } 13900002 - No such file or directory 3441 * @throws { BusinessError } 13900008 - Bad file descriptor 3442 * @throws { BusinessError } 13900011 - Out of memory 3443 * @throws { BusinessError } 13900018 - Not a directory 3444 * @throws { BusinessError } 13900042 - Unknown error 3445 * @syscap SystemCapability.FileManagement.File.FileIO 3446 * @since 9 3447 */ 3448/** 3449 * List file. 3450 * 3451 * @param { string } path - path. 3452 * @param { AsyncCallback<string[]> } callback - The callback is used to return an Array containing the name of files or directories 3453 * that meet the filter criteria in promise mode. If present, Include the subdirectory structure. 3454 * @throws { BusinessError } 13900002 - No such file or directory 3455 * @throws { BusinessError } 13900008 - Bad file descriptor 3456 * @throws { BusinessError } 13900011 - Out of memory 3457 * @throws { BusinessError } 13900018 - Not a directory 3458 * @throws { BusinessError } 13900042 - Unknown error 3459 * @syscap SystemCapability.FileManagement.File.FileIO 3460 * @crossplatform 3461 * @since 10 3462 */ 3463/** 3464 * Lists all file names in a directory. This API uses a promise to return the result. 3465 * 3466 * @param { string } path - Application sandbox path of the directory. 3467 * @param { AsyncCallback<string[]> } callback - Options for filtering files. The files are not filtered by default 3468 * @throws { BusinessError } 13900002 - No such file or directory 3469 * @throws { BusinessError } 13900008 - Bad file descriptor 3470 * @throws { BusinessError } 13900011 - Out of memory 3471 * @throws { BusinessError } 13900018 - Not a directory 3472 * @throws { BusinessError } 13900042 - Unknown error 3473 * @syscap SystemCapability.FileManagement.File.FileIO 3474 * @crossplatform 3475 * @atomicservice 3476 * @since 11 3477 */ 3478declare function listFile(path: string, callback: AsyncCallback<string[]>): void; 3479 3480/** 3481 * List file. 3482 * 3483 * @param { string } path - path. 3484 * @param { object } [options] - options. 3485 * @param { AsyncCallback<string[]> } callback - The callback is used to return an Array containing the name of files or directories 3486 * that meet the filter criteria in promise mode. If present, Include the subdirectory structure. 3487 * @throws { BusinessError } 13900002 - No such file or directory 3488 * @throws { BusinessError } 13900008 - Bad file descriptor 3489 * @throws { BusinessError } 13900011 - Out of memory 3490 * @throws { BusinessError } 13900018 - Not a directory 3491 * @throws { BusinessError } 13900042 - Unknown error 3492 * @syscap SystemCapability.FileManagement.File.FileIO 3493 * @since 9 3494 */ 3495/** 3496 * List file. 3497 * 3498 * @param { string } path - path. 3499 * @param { object } [options] - options. 3500 * @param { AsyncCallback<string[]> } callback - The callback is used to return an Array containing the name of files or directories 3501 * that meet the filter criteria in promise mode. If present, Include the subdirectory structure. 3502 * @throws { BusinessError } 13900002 - No such file or directory 3503 * @throws { BusinessError } 13900008 - Bad file descriptor 3504 * @throws { BusinessError } 13900011 - Out of memory 3505 * @throws { BusinessError } 13900018 - Not a directory 3506 * @throws { BusinessError } 13900042 - Unknown error 3507 * @syscap SystemCapability.FileManagement.File.FileIO 3508 * @crossplatform 3509 * @since 10 3510 */ 3511/** 3512 * Lists all file names in a directory. This API supports recursive listing of all file names and file filtering. 3513 * This API uses an asynchronous callback to return the result. 3514 * 3515 * @param { string } path - Application sandbox path of the directory. 3516 * @param { ListFileOptions } [options] - Options for filtering files. The files are not filtered by default. 3517 * @param { AsyncCallback<string[]> } callback - Callback used to return the file names listed. 3518 * @throws { BusinessError } 13900002 - No such file or directory 3519 * @throws { BusinessError } 13900008 - Bad file descriptor 3520 * @throws { BusinessError } 13900011 - Out of memory 3521 * @throws { BusinessError } 13900018 - Not a directory 3522 * @throws { BusinessError } 13900042 - Unknown error 3523 * @syscap SystemCapability.FileManagement.File.FileIO 3524 * @crossplatform 3525 * @atomicservice 3526 * @since 11 3527 */ 3528declare function listFile( 3529 path: string, 3530 options: ListFileOptions, 3531 callback: AsyncCallback<string[]> 3532): void; 3533 3534/** 3535 * List file with sync interface. 3536 * 3537 * @param { string } path - path. 3538 * @param { object } [options] - options. 3539 * @returns { string[] } Returns an Array containing the name of files or directories that meet the filter criteria. 3540 * @throws { BusinessError } 13900002 - No such file or directory 3541 * @throws { BusinessError } 13900008 - Bad file descriptor 3542 * @throws { BusinessError } 13900011 - Out of memory 3543 * @throws { BusinessError } 13900018 - Not a directory 3544 * @throws { BusinessError } 13900042 - Unknown error 3545 * @syscap SystemCapability.FileManagement.File.FileIO 3546 * @since 9 3547 */ 3548/** 3549 * List file with sync interface. 3550 * 3551 * @param { string } path - path. 3552 * @param { object } [options] - options. 3553 * @returns { string[] } Returns an Array containing the name of files or directories that meet the filter criteria. 3554 * @throws { BusinessError } 13900002 - No such file or directory 3555 * @throws { BusinessError } 13900008 - Bad file descriptor 3556 * @throws { BusinessError } 13900011 - Out of memory 3557 * @throws { BusinessError } 13900018 - Not a directory 3558 * @throws { BusinessError } 13900042 - Unknown error 3559 * @syscap SystemCapability.FileManagement.File.FileIO 3560 * @crossplatform 3561 * @since 10 3562 */ 3563/** 3564 * Lists all file names in a directory. This API returns the result synchronously. 3565 * This API supports recursive listing of all file names and file filtering. 3566 * 3567 * @param { string } path - Application sandbox path of the directory. 3568 * @param { ListFileOptions } [options] - Options for filtering files. The files are not filtered by default. 3569 * @returns { string[] } List of the file names obtained. 3570 * @throws { BusinessError } 13900002 - No such file or directory 3571 * @throws { BusinessError } 13900008 - Bad file descriptor 3572 * @throws { BusinessError } 13900011 - Out of memory 3573 * @throws { BusinessError } 13900018 - Not a directory 3574 * @throws { BusinessError } 13900042 - Unknown error 3575 * @syscap SystemCapability.FileManagement.File.FileIO 3576 * @crossplatform 3577 * @atomicservice 3578 * @since 11 3579 */ 3580declare function listFileSync( 3581 path: string, 3582 options?: ListFileOptions 3583): string[]; 3584 3585/** 3586 * Reposition file offset. 3587 * 3588 * @param { number } fd - file descriptor. 3589 * @param { number } offset - file offset. 3590 * @param { WhenceType } [whence = WhenceType.SEEK_SET] - directive whence. 3591 * @returns { number } Returns the file offset relative to starting position of file. 3592 * @throws { BusinessError } 13900008 - Bad file descriptor 3593 * @throws { BusinessError } 13900020 - Invalid argument 3594 * @throws { BusinessError } 13900026 - Illegal seek 3595 * @throws { BusinessError } 13900038 - Value too large for defined data type 3596 * @throws { BusinessError } 13900042 - Unknown error 3597 * @syscap SystemCapability.FileManagement.File.FileIO 3598 * @since 11 3599 */ 3600/** 3601 * Adjusts the position of the file offset pointer. 3602 * 3603 * @param { number } fd - FD of the file. 3604 * @param { number } offset - Number of bytes to move the offset. 3605 * @param { WhenceType } [whence = WhenceType.SEEK_SET] - Where to start the offset. 3606 * <br>If this parameter is not specified, the file start position is used by default. 3607 * @returns { number } Returns the file offset relative to starting position of file. 3608 * @throws { BusinessError } 13900008 - Bad file descriptor 3609 * @throws { BusinessError } 13900020 - Invalid argument 3610 * @throws { BusinessError } 13900026 - Illegal seek 3611 * @throws { BusinessError } 13900038 - Value too large for defined data type 3612 * @throws { BusinessError } 13900042 - Unknown error 3613 * @syscap SystemCapability.FileManagement.File.FileIO 3614 * @crossplatform 3615 * @since 12 3616 */ 3617declare function lseek(fd: number, offset: number, whence?: WhenceType): number; 3618 3619/** 3620 * Obtains information about a symbolic link that is used to refer to a file or directory. 3621 * This API uses a promise to return the result. 3622 * 3623 * @param { string } path - Application sandbox path of the file. 3624 * @returns { Promise<Stat> } Promise used to return the symbolic link information obtained. 3625 * @throws { BusinessError } 13900002 - No such file or directory 3626 * @throws { BusinessError } 13900008 - Bad file descriptor 3627 * @throws { BusinessError } 13900011 - Out of memory 3628 * @throws { BusinessError } 13900012 - Permission denied 3629 * @throws { BusinessError } 13900013 - Bad address 3630 * @throws { BusinessError } 13900018 - Not a directory 3631 * @throws { BusinessError } 13900030 - File name too long 3632 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3633 * @throws { BusinessError } 13900038 - Value too large for defined data type 3634 * @throws { BusinessError } 13900042 - Unknown error 3635 * @syscap SystemCapability.FileManagement.File.FileIO 3636 * @since 9 3637 */ 3638/** 3639 * Obtains information about a symbolic link that is used to refer to a file or directory. 3640 * This API uses a promise to return the result. 3641 * 3642 * @param { string } path - Application sandbox path of the file. 3643 * @returns { Promise<Stat> } Promise used to return the symbolic link information obtained. 3644 * @throws { BusinessError } 13900002 - No such file or directory 3645 * @throws { BusinessError } 13900008 - Bad file descriptor 3646 * @throws { BusinessError } 13900011 - Out of memory 3647 * @throws { BusinessError } 13900012 - Permission denied 3648 * @throws { BusinessError } 13900013 - Bad address 3649 * @throws { BusinessError } 13900018 - Not a directory 3650 * @throws { BusinessError } 13900030 - File name too long 3651 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3652 * @throws { BusinessError } 13900038 - Value too large for defined data type 3653 * @throws { BusinessError } 13900042 - Unknown error 3654 * @syscap SystemCapability.FileManagement.File.FileIO 3655 * @crossplatform 3656 * @since 20 3657 */ 3658declare function lstat(path: string): Promise<Stat>; 3659 3660/** 3661 * Obtains information about a symbolic link that is used to refer to a file or directory. 3662 * This API uses an asynchronous callback to return the result. 3663 * 3664 * @param { string } path - Application sandbox path of the file. 3665 * @param { AsyncCallback<Stat> } callback - Callback used to return the symbolic link information obtained. 3666 * @throws { BusinessError } 13900002 - No such file or directory 3667 * @throws { BusinessError } 13900008 - Bad file descriptor 3668 * @throws { BusinessError } 13900011 - Out of memory 3669 * @throws { BusinessError } 13900012 - Permission denied 3670 * @throws { BusinessError } 13900013 - Bad address 3671 * @throws { BusinessError } 13900018 - Not a directory 3672 * @throws { BusinessError } 13900030 - File name too long 3673 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3674 * @throws { BusinessError } 13900038 - Value too large for defined data type 3675 * @throws { BusinessError } 13900042 - Unknown error 3676 * @syscap SystemCapability.FileManagement.File.FileIO 3677 * @since 9 3678 */ 3679/** 3680 * Obtains information about a symbolic link that is used to refer to a file or directory. 3681 * This API uses an asynchronous callback to return the result. 3682 * 3683 * @param { string } path - Application sandbox path of the file. 3684 * @param { AsyncCallback<Stat> } callback - Callback used to return the symbolic link information obtained. 3685 * @throws { BusinessError } 13900002 - No such file or directory 3686 * @throws { BusinessError } 13900008 - Bad file descriptor 3687 * @throws { BusinessError } 13900011 - Out of memory 3688 * @throws { BusinessError } 13900012 - Permission denied 3689 * @throws { BusinessError } 13900013 - Bad address 3690 * @throws { BusinessError } 13900018 - Not a directory 3691 * @throws { BusinessError } 13900030 - File name too long 3692 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3693 * @throws { BusinessError } 13900038 - Value too large for defined data type 3694 * @throws { BusinessError } 13900042 - Unknown error 3695 * @syscap SystemCapability.FileManagement.File.FileIO 3696 * @crossplatform 3697 * @since 20 3698 */ 3699declare function lstat(path: string, callback: AsyncCallback<Stat>): void; 3700 3701/** 3702 * Obtains information about a symbolic link that is used to refer to a file or directory. 3703 * This API returns the result synchronously. 3704 * 3705 * @param { string } path - Application sandbox path of the file. 3706 * @returns { Stat } File information obtained. 3707 * @throws { BusinessError } 13900002 - No such file or directory 3708 * @throws { BusinessError } 13900008 - Bad file descriptor 3709 * @throws { BusinessError } 13900011 - Out of memory 3710 * @throws { BusinessError } 13900012 - Permission denied 3711 * @throws { BusinessError } 13900013 - Bad address 3712 * @throws { BusinessError } 13900018 - Not a directory 3713 * @throws { BusinessError } 13900030 - File name too long 3714 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3715 * @throws { BusinessError } 13900038 - Value too large for defined data type 3716 * @throws { BusinessError } 13900042 - Unknown error 3717 * @syscap SystemCapability.FileManagement.File.FileIO 3718 * @since 9 3719 */ 3720/** 3721 * Obtains information about a symbolic link that is used to refer to a file or directory. 3722 * This API returns the result synchronously. 3723 * 3724 * @param { string } path - Application sandbox path of the file. 3725 * @returns { Stat } File information obtained. 3726 * @throws { BusinessError } 13900002 - No such file or directory 3727 * @throws { BusinessError } 13900008 - Bad file descriptor 3728 * @throws { BusinessError } 13900011 - Out of memory 3729 * @throws { BusinessError } 13900012 - Permission denied 3730 * @throws { BusinessError } 13900013 - Bad address 3731 * @throws { BusinessError } 13900018 - Not a directory 3732 * @throws { BusinessError } 13900030 - File name too long 3733 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3734 * @throws { BusinessError } 13900038 - Value too large for defined data type 3735 * @throws { BusinessError } 13900042 - Unknown error 3736 * @syscap SystemCapability.FileManagement.File.FileIO 3737 * @crossplatform 3738 * @since 20 3739 */ 3740declare function lstatSync(path: string): Stat; 3741 3742/** 3743 * Make dir. 3744 * 3745 * @param { string } path - path. 3746 * @returns { Promise<void> } The promise returned by the function. 3747 * @throws { BusinessError } 13900001 - Operation not permitted 3748 * @throws { BusinessError } 13900002 - No such file or directory 3749 * @throws { BusinessError } 13900008 - Bad file descriptor 3750 * @throws { BusinessError } 13900011 - Out of memory 3751 * @throws { BusinessError } 13900012 - Permission denied 3752 * @throws { BusinessError } 13900013 - Bad address 3753 * @throws { BusinessError } 13900015 - File exists 3754 * @throws { BusinessError } 13900018 - Not a directory 3755 * @throws { BusinessError } 13900020 - Invalid argument 3756 * @throws { BusinessError } 13900025 - No space left on device 3757 * @throws { BusinessError } 13900028 - Too many links 3758 * @throws { BusinessError } 13900030 - File name too long 3759 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3760 * @throws { BusinessError } 13900041 - Quota exceeded 3761 * @throws { BusinessError } 13900042 - Unknown error 3762 * @syscap SystemCapability.FileManagement.File.FileIO 3763 * @since 9 3764 */ 3765/** 3766 * Make dir. 3767 * 3768 * @param { string } path - path. 3769 * @returns { Promise<void> } The promise returned by the function. 3770 * @throws { BusinessError } 13900001 - Operation not permitted 3771 * @throws { BusinessError } 13900002 - No such file or directory 3772 * @throws { BusinessError } 13900008 - Bad file descriptor 3773 * @throws { BusinessError } 13900011 - Out of memory 3774 * @throws { BusinessError } 13900012 - Permission denied 3775 * @throws { BusinessError } 13900013 - Bad address 3776 * @throws { BusinessError } 13900015 - File exists 3777 * @throws { BusinessError } 13900018 - Not a directory 3778 * @throws { BusinessError } 13900020 - Invalid argument 3779 * @throws { BusinessError } 13900025 - No space left on device 3780 * @throws { BusinessError } 13900028 - Too many links 3781 * @throws { BusinessError } 13900030 - File name too long 3782 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3783 * @throws { BusinessError } 13900041 - Quota exceeded 3784 * @throws { BusinessError } 13900042 - Unknown error 3785 * @syscap SystemCapability.FileManagement.File.FileIO 3786 * @crossplatform 3787 * @since 10 3788 */ 3789/** 3790 * Creates a directory. This API uses a promise to return the result. 3791 * 3792 * @param { string } path - Application sandbox path of the directory. 3793 * @returns { Promise<void> } Promise that returns no value. 3794 * @throws { BusinessError } 13900001 - Operation not permitted 3795 * @throws { BusinessError } 13900002 - No such file or directory 3796 * @throws { BusinessError } 13900008 - Bad file descriptor 3797 * @throws { BusinessError } 13900011 - Out of memory 3798 * @throws { BusinessError } 13900012 - Permission denied 3799 * @throws { BusinessError } 13900013 - Bad address 3800 * @throws { BusinessError } 13900015 - File exists 3801 * @throws { BusinessError } 13900018 - Not a directory 3802 * @throws { BusinessError } 13900020 - Invalid argument 3803 * @throws { BusinessError } 13900025 - No space left on device 3804 * @throws { BusinessError } 13900028 - Too many links 3805 * @throws { BusinessError } 13900030 - File name too long 3806 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3807 * @throws { BusinessError } 13900041 - Quota exceeded 3808 * @throws { BusinessError } 13900042 - Unknown error 3809 * @syscap SystemCapability.FileManagement.File.FileIO 3810 * @crossplatform 3811 * @atomicservice 3812 * @since 11 3813 */ 3814declare function mkdir(path: string): Promise<void>; 3815 3816/** 3817 * Creates a directory. This API uses a promise to return the result. The value true means to create a directory recursively. 3818 * 3819 * @param { string } path - Application sandbox path of the directory. 3820 * @param { boolean } recursion - Whether to create a directory recursively. 3821 * <br>The value true means to create a directory recursively. The value false means to create a single-level directory. 3822 * @returns { Promise<void> } Promise that returns no value. 3823 * @throws { BusinessError } 13900001 - Operation not permitted 3824 * @throws { BusinessError } 13900002 - No such file or directory 3825 * @throws { BusinessError } 13900008 - Bad file descriptor 3826 * @throws { BusinessError } 13900011 - Out of memory 3827 * @throws { BusinessError } 13900012 - Permission denied 3828 * @throws { BusinessError } 13900013 - Bad address 3829 * @throws { BusinessError } 13900015 - File exists 3830 * @throws { BusinessError } 13900018 - Not a directory 3831 * @throws { BusinessError } 13900020 - Invalid argument 3832 * @throws { BusinessError } 13900025 - No space left on device 3833 * @throws { BusinessError } 13900028 - Too many links 3834 * @throws { BusinessError } 13900030 - File name too long 3835 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3836 * @throws { BusinessError } 13900041 - Quota exceeded 3837 * @throws { BusinessError } 13900042 - Unknown error 3838 * @syscap SystemCapability.FileManagement.File.FileIO 3839 * @atomicservice 3840 * @since 11 3841 */ 3842/** 3843 * Creates a directory. This API uses a promise to return the result. The value true means to create a directory recursively. 3844 * 3845 * @param { string } path - Application sandbox path of the directory. 3846 * @param { boolean } recursion - Whether to create a directory recursively. 3847 * <br>The value true means to create a directory recursively. The value false means to create a single-level directory. 3848 * @returns { Promise<void> } Promise that returns no value. 3849 * @throws { BusinessError } 13900001 - Operation not permitted 3850 * @throws { BusinessError } 13900002 - No such file or directory 3851 * @throws { BusinessError } 13900008 - Bad file descriptor 3852 * @throws { BusinessError } 13900011 - Out of memory 3853 * @throws { BusinessError } 13900012 - Permission denied 3854 * @throws { BusinessError } 13900013 - Bad address 3855 * @throws { BusinessError } 13900015 - File exists 3856 * @throws { BusinessError } 13900018 - Not a directory 3857 * @throws { BusinessError } 13900020 - Invalid argument 3858 * @throws { BusinessError } 13900025 - No space left on device 3859 * @throws { BusinessError } 13900028 - Too many links 3860 * @throws { BusinessError } 13900030 - File name too long 3861 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3862 * @throws { BusinessError } 13900041 - Quota exceeded 3863 * @throws { BusinessError } 13900042 - Unknown error 3864 * @syscap SystemCapability.FileManagement.File.FileIO 3865 * @crossplatform 3866 * @atomicservice 3867 * @since 20 3868 */ 3869declare function mkdir(path: string, recursion: boolean): Promise<void>; 3870 3871/** 3872 * Make dir. 3873 * 3874 * @param { string } path - path. 3875 * @param { AsyncCallback<void> } callback - Return the callback function. 3876 * @throws { BusinessError } 13900001 - Operation not permitted 3877 * @throws { BusinessError } 13900002 - No such file or directory 3878 * @throws { BusinessError } 13900008 - Bad file descriptor 3879 * @throws { BusinessError } 13900011 - Out of memory 3880 * @throws { BusinessError } 13900012 - Permission denied 3881 * @throws { BusinessError } 13900013 - Bad address 3882 * @throws { BusinessError } 13900015 - File exists 3883 * @throws { BusinessError } 13900018 - Not a directory 3884 * @throws { BusinessError } 13900020 - Invalid argument 3885 * @throws { BusinessError } 13900025 - No space left on device 3886 * @throws { BusinessError } 13900028 - Too many links 3887 * @throws { BusinessError } 13900030 - File name too long 3888 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3889 * @throws { BusinessError } 13900041 - Quota exceeded 3890 * @throws { BusinessError } 13900042 - Unknown error 3891 * @syscap SystemCapability.FileManagement.File.FileIO 3892 * @since 9 3893 */ 3894/** 3895 * Make dir. 3896 * 3897 * @param { string } path - path. 3898 * @param { AsyncCallback<void> } callback - Return the callback function. 3899 * @throws { BusinessError } 13900001 - Operation not permitted 3900 * @throws { BusinessError } 13900002 - No such file or directory 3901 * @throws { BusinessError } 13900008 - Bad file descriptor 3902 * @throws { BusinessError } 13900011 - Out of memory 3903 * @throws { BusinessError } 13900012 - Permission denied 3904 * @throws { BusinessError } 13900013 - Bad address 3905 * @throws { BusinessError } 13900015 - File exists 3906 * @throws { BusinessError } 13900018 - Not a directory 3907 * @throws { BusinessError } 13900020 - Invalid argument 3908 * @throws { BusinessError } 13900025 - No space left on device 3909 * @throws { BusinessError } 13900028 - Too many links 3910 * @throws { BusinessError } 13900030 - File name too long 3911 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3912 * @throws { BusinessError } 13900041 - Quota exceeded 3913 * @throws { BusinessError } 13900042 - Unknown error 3914 * @syscap SystemCapability.FileManagement.File.FileIO 3915 * @crossplatform 3916 * @since 10 3917 */ 3918/** 3919 * Creates a directory. This API uses an asynchronous callback to return the result. 3920 * 3921 * @param { string } path - Application sandbox path of the directory. 3922 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3923 * @throws { BusinessError } 13900001 - Operation not permitted 3924 * @throws { BusinessError } 13900002 - No such file or directory 3925 * @throws { BusinessError } 13900008 - Bad file descriptor 3926 * @throws { BusinessError } 13900011 - Out of memory 3927 * @throws { BusinessError } 13900012 - Permission denied 3928 * @throws { BusinessError } 13900013 - Bad address 3929 * @throws { BusinessError } 13900015 - File exists 3930 * @throws { BusinessError } 13900018 - Not a directory 3931 * @throws { BusinessError } 13900020 - Invalid argument 3932 * @throws { BusinessError } 13900025 - No space left on device 3933 * @throws { BusinessError } 13900028 - Too many links 3934 * @throws { BusinessError } 13900030 - File name too long 3935 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3936 * @throws { BusinessError } 13900041 - Quota exceeded 3937 * @throws { BusinessError } 13900042 - Unknown error 3938 * @syscap SystemCapability.FileManagement.File.FileIO 3939 * @crossplatform 3940 * @atomicservice 3941 * @since 11 3942 */ 3943declare function mkdir(path: string, callback: AsyncCallback<void>): void; 3944 3945/** 3946 * Creates a directory. This API uses an asynchronous callback to return the result. 3947 * The value true means to create a directory recursively. 3948 * 3949 * @param { string } path - Application sandbox path of the directory. 3950 * @param { boolean } recursion - Whether to create a directory recursively. 3951 * <br>The value true means to create a directory recursively. The value false means to create a single-level directory. 3952 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3953 * @throws { BusinessError } 13900001 - Operation not permitted 3954 * @throws { BusinessError } 13900002 - No such file or directory 3955 * @throws { BusinessError } 13900008 - Bad file descriptor 3956 * @throws { BusinessError } 13900011 - Out of memory 3957 * @throws { BusinessError } 13900012 - Permission denied 3958 * @throws { BusinessError } 13900013 - Bad address 3959 * @throws { BusinessError } 13900015 - File exists 3960 * @throws { BusinessError } 13900018 - Not a directory 3961 * @throws { BusinessError } 13900020 - Invalid argument 3962 * @throws { BusinessError } 13900025 - No space left on device 3963 * @throws { BusinessError } 13900028 - Too many links 3964 * @throws { BusinessError } 13900030 - File name too long 3965 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3966 * @throws { BusinessError } 13900041 - Quota exceeded 3967 * @throws { BusinessError } 13900042 - Unknown error 3968 * @syscap SystemCapability.FileManagement.File.FileIO 3969 * @atomicservice 3970 * @since 11 3971 */ 3972/** 3973 * Creates a directory. This API uses an asynchronous callback to return the result. 3974 * The value true means to create a directory recursively. 3975 * 3976 * @param { string } path - Application sandbox path of the directory. 3977 * @param { boolean } recursion - Whether to create a directory recursively. 3978 * <br>The value true means to create a directory recursively. The value false means to create a single-level directory. 3979 * @param { AsyncCallback<void> } callback - Callback used to return the result. 3980 * @throws { BusinessError } 13900001 - Operation not permitted 3981 * @throws { BusinessError } 13900002 - No such file or directory 3982 * @throws { BusinessError } 13900008 - Bad file descriptor 3983 * @throws { BusinessError } 13900011 - Out of memory 3984 * @throws { BusinessError } 13900012 - Permission denied 3985 * @throws { BusinessError } 13900013 - Bad address 3986 * @throws { BusinessError } 13900015 - File exists 3987 * @throws { BusinessError } 13900018 - Not a directory 3988 * @throws { BusinessError } 13900020 - Invalid argument 3989 * @throws { BusinessError } 13900025 - No space left on device 3990 * @throws { BusinessError } 13900028 - Too many links 3991 * @throws { BusinessError } 13900030 - File name too long 3992 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 3993 * @throws { BusinessError } 13900041 - Quota exceeded 3994 * @throws { BusinessError } 13900042 - Unknown error 3995 * @syscap SystemCapability.FileManagement.File.FileIO 3996 * @crossplatform 3997 * @atomicservice 3998 * @since 20 3999 */ 4000declare function mkdir(path: string, recursion: boolean, callback: AsyncCallback<void>): void; 4001 4002/** 4003 * Make dir with sync interface. 4004 * 4005 * @param { string } path - path. 4006 * @throws { BusinessError } 13900001 - Operation not permitted 4007 * @throws { BusinessError } 13900002 - No such file or directory 4008 * @throws { BusinessError } 13900008 - Bad file descriptor 4009 * @throws { BusinessError } 13900011 - Out of memory 4010 * @throws { BusinessError } 13900012 - Permission denied 4011 * @throws { BusinessError } 13900013 - Bad address 4012 * @throws { BusinessError } 13900015 - File exists 4013 * @throws { BusinessError } 13900018 - Not a directory 4014 * @throws { BusinessError } 13900020 - Invalid argument 4015 * @throws { BusinessError } 13900025 - No space left on device 4016 * @throws { BusinessError } 13900028 - Too many links 4017 * @throws { BusinessError } 13900030 - File name too long 4018 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4019 * @throws { BusinessError } 13900041 - Quota exceeded 4020 * @throws { BusinessError } 13900042 - Unknown error 4021 * @syscap SystemCapability.FileManagement.File.FileIO 4022 * @since 9 4023 */ 4024/** 4025 * Make dir with sync interface. 4026 * 4027 * @param { string } path - path. 4028 * @throws { BusinessError } 13900001 - Operation not permitted 4029 * @throws { BusinessError } 13900002 - No such file or directory 4030 * @throws { BusinessError } 13900008 - Bad file descriptor 4031 * @throws { BusinessError } 13900011 - Out of memory 4032 * @throws { BusinessError } 13900012 - Permission denied 4033 * @throws { BusinessError } 13900013 - Bad address 4034 * @throws { BusinessError } 13900015 - File exists 4035 * @throws { BusinessError } 13900018 - Not a directory 4036 * @throws { BusinessError } 13900020 - Invalid argument 4037 * @throws { BusinessError } 13900025 - No space left on device 4038 * @throws { BusinessError } 13900028 - Too many links 4039 * @throws { BusinessError } 13900030 - File name too long 4040 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4041 * @throws { BusinessError } 13900041 - Quota exceeded 4042 * @throws { BusinessError } 13900042 - Unknown error 4043 * @syscap SystemCapability.FileManagement.File.FileIO 4044 * @crossplatform 4045 * @since 10 4046 */ 4047/** 4048 * Creates a directory. This API returns the result synchronously. 4049 * 4050 * @param { string } path - Application sandbox path of the directory. 4051 * @throws { BusinessError } 13900001 - Operation not permitted 4052 * @throws { BusinessError } 13900002 - No such file or directory 4053 * @throws { BusinessError } 13900008 - Bad file descriptor 4054 * @throws { BusinessError } 13900011 - Out of memory 4055 * @throws { BusinessError } 13900012 - Permission denied 4056 * @throws { BusinessError } 13900013 - Bad address 4057 * @throws { BusinessError } 13900015 - File exists 4058 * @throws { BusinessError } 13900018 - Not a directory 4059 * @throws { BusinessError } 13900020 - Invalid argument 4060 * @throws { BusinessError } 13900025 - No space left on device 4061 * @throws { BusinessError } 13900028 - Too many links 4062 * @throws { BusinessError } 13900030 - File name too long 4063 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4064 * @throws { BusinessError } 13900041 - Quota exceeded 4065 * @throws { BusinessError } 13900042 - Unknown error 4066 * @syscap SystemCapability.FileManagement.File.FileIO 4067 * @crossplatform 4068 * @atomicservice 4069 * @since 11 4070 */ 4071declare function mkdirSync(path: string): void; 4072 4073/** 4074 * Creates a directory. This API returns the result synchronously. The value true means to create a directory recursively. 4075 * 4076 * @param { string } path - Application sandbox path of the directory. 4077 * @param { boolean } recursion - Whether to create a directory recursively. 4078 * <br>The value true means to create a directory recursively. The value false means to create a single-level directory. 4079 * @throws { BusinessError } 13900001 - Operation not permitted 4080 * @throws { BusinessError } 13900002 - No such file or directory 4081 * @throws { BusinessError } 13900008 - Bad file descriptor 4082 * @throws { BusinessError } 13900011 - Out of memory 4083 * @throws { BusinessError } 13900012 - Permission denied 4084 * @throws { BusinessError } 13900013 - Bad address 4085 * @throws { BusinessError } 13900015 - File exists 4086 * @throws { BusinessError } 13900018 - Not a directory 4087 * @throws { BusinessError } 13900020 - Invalid argument 4088 * @throws { BusinessError } 13900025 - No space left on device 4089 * @throws { BusinessError } 13900028 - Too many links 4090 * @throws { BusinessError } 13900030 - File name too long 4091 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4092 * @throws { BusinessError } 13900041 - Quota exceeded 4093 * @throws { BusinessError } 13900042 - Unknown error 4094 * @syscap SystemCapability.FileManagement.File.FileIO 4095 * @atomicservice 4096 * @since 11 4097 */ 4098/** 4099 * Creates a directory. This API returns the result synchronously. The value true means to create a directory recursively. 4100 * 4101 * @param { string } path - Application sandbox path of the directory. 4102 * @param { boolean } recursion - Whether to create a directory recursively. 4103 * <br>The value true means to create a directory recursively. The value false means to create a single-level directory. 4104 * @throws { BusinessError } 13900001 - Operation not permitted 4105 * @throws { BusinessError } 13900002 - No such file or directory 4106 * @throws { BusinessError } 13900008 - Bad file descriptor 4107 * @throws { BusinessError } 13900011 - Out of memory 4108 * @throws { BusinessError } 13900012 - Permission denied 4109 * @throws { BusinessError } 13900013 - Bad address 4110 * @throws { BusinessError } 13900015 - File exists 4111 * @throws { BusinessError } 13900018 - Not a directory 4112 * @throws { BusinessError } 13900020 - Invalid argument 4113 * @throws { BusinessError } 13900025 - No space left on device 4114 * @throws { BusinessError } 13900028 - Too many links 4115 * @throws { BusinessError } 13900030 - File name too long 4116 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4117 * @throws { BusinessError } 13900041 - Quota exceeded 4118 * @throws { BusinessError } 13900042 - Unknown error 4119 * @syscap SystemCapability.FileManagement.File.FileIO 4120 * @crossplatform 4121 * @atomicservice 4122 * @since 20 4123 */ 4124declare function mkdirSync(path: string, recursion: boolean): void; 4125 4126/** 4127 * Make temp dir. 4128 * 4129 * @param { string } prefix - dir prefix. 4130 * @returns { Promise<string> } Returns the path to the new directory in promise mode. 4131 * @throws { BusinessError } 13900001 - Operation not permitted 4132 * @throws { BusinessError } 13900002 - No such file or directory 4133 * @throws { BusinessError } 13900008 - Bad file descriptor 4134 * @throws { BusinessError } 13900011 - Out of memory 4135 * @throws { BusinessError } 13900012 - Permission denied 4136 * @throws { BusinessError } 13900013 - Bad address 4137 * @throws { BusinessError } 13900015 - File exists 4138 * @throws { BusinessError } 13900018 - Not a directory 4139 * @throws { BusinessError } 13900020 - Invalid argument 4140 * @throws { BusinessError } 13900025 - No space left on device 4141 * @throws { BusinessError } 13900028 - Too many links 4142 * @throws { BusinessError } 13900030 - File name too long 4143 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4144 * @throws { BusinessError } 13900041 - Quota exceeded 4145 * @throws { BusinessError } 13900042 - Unknown error 4146 * @syscap SystemCapability.FileManagement.File.FileIO 4147 * @since 9 4148 */ 4149/** 4150 * Creates a temporary directory. This API uses a promise to return the result. 4151 * 4152 * @param { string } prefix - String to be replaced with six randomly generated characters to create a unique temporary directory. 4153 * @returns { Promise<string> } Promise used to return the directory created. 4154 * @throws { BusinessError } 13900001 - Operation not permitted 4155 * @throws { BusinessError } 13900002 - No such file or directory 4156 * @throws { BusinessError } 13900008 - Bad file descriptor 4157 * @throws { BusinessError } 13900011 - Out of memory 4158 * @throws { BusinessError } 13900012 - Permission denied 4159 * @throws { BusinessError } 13900013 - Bad address 4160 * @throws { BusinessError } 13900015 - File exists 4161 * @throws { BusinessError } 13900018 - Not a directory 4162 * @throws { BusinessError } 13900020 - Invalid argument 4163 * @throws { BusinessError } 13900025 - No space left on device 4164 * @throws { BusinessError } 13900028 - Too many links 4165 * @throws { BusinessError } 13900030 - File name too long 4166 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4167 * @throws { BusinessError } 13900041 - Quota exceeded 4168 * @throws { BusinessError } 13900042 - Unknown error 4169 * @syscap SystemCapability.FileManagement.File.FileIO 4170 * @crossplatform 4171 * @since 10 4172 */ 4173declare function mkdtemp(prefix: string): Promise<string>; 4174 4175/** 4176 * Make temp dir. 4177 * 4178 * @param { string } prefix - dir prefix. 4179 * @param { AsyncCallback<string> } callback - The callback is used to return the path to the new directory. 4180 * @throws { BusinessError } 13900001 - Operation not permitted 4181 * @throws { BusinessError } 13900002 - No such file or directory 4182 * @throws { BusinessError } 13900008 - Bad file descriptor 4183 * @throws { BusinessError } 13900011 - Out of memory 4184 * @throws { BusinessError } 13900012 - Permission denied 4185 * @throws { BusinessError } 13900013 - Bad address 4186 * @throws { BusinessError } 13900015 - File exists 4187 * @throws { BusinessError } 13900018 - Not a directory 4188 * @throws { BusinessError } 13900020 - Invalid argument 4189 * @throws { BusinessError } 13900025 - No space left on device 4190 * @throws { BusinessError } 13900028 - Too many links 4191 * @throws { BusinessError } 13900030 - File name too long 4192 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4193 * @throws { BusinessError } 13900041 - Quota exceeded 4194 * @throws { BusinessError } 13900042 - Unknown error 4195 * @syscap SystemCapability.FileManagement.File.FileIO 4196 * @since 9 4197 */ 4198/** 4199 * Creates a temporary directory. This API uses an asynchronous callback to return the result. 4200 * The directory name is created by replacing a string (specified by prefix) with six randomly generated characters. 4201 * 4202 * @param { string } prefix - String to be replaced with six randomly generated characters to create a unique temporary directory. 4203 * @param { AsyncCallback<string> } callback - Callback used to return the result. 4204 * @throws { BusinessError } 13900001 - Operation not permitted 4205 * @throws { BusinessError } 13900002 - No such file or directory 4206 * @throws { BusinessError } 13900008 - Bad file descriptor 4207 * @throws { BusinessError } 13900011 - Out of memory 4208 * @throws { BusinessError } 13900012 - Permission denied 4209 * @throws { BusinessError } 13900013 - Bad address 4210 * @throws { BusinessError } 13900015 - File exists 4211 * @throws { BusinessError } 13900018 - Not a directory 4212 * @throws { BusinessError } 13900020 - Invalid argument 4213 * @throws { BusinessError } 13900025 - No space left on device 4214 * @throws { BusinessError } 13900028 - Too many links 4215 * @throws { BusinessError } 13900030 - File name too long 4216 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4217 * @throws { BusinessError } 13900041 - Quota exceeded 4218 * @throws { BusinessError } 13900042 - Unknown error 4219 * @syscap SystemCapability.FileManagement.File.FileIO 4220 * @crossplatform 4221 * @since 10 4222 */ 4223declare function mkdtemp(prefix: string, callback: AsyncCallback<string>): void; 4224 4225/** 4226 * Make temp dir with sync interface. 4227 * 4228 * @param { string } prefix - dir prefix. 4229 * @returns { string } Returns the path to the new directory. 4230 * @throws { BusinessError } 13900001 - Operation not permitted 4231 * @throws { BusinessError } 13900002 - No such file or directory 4232 * @throws { BusinessError } 13900008 - Bad file descriptor 4233 * @throws { BusinessError } 13900011 - Out of memory 4234 * @throws { BusinessError } 13900012 - Permission denied 4235 * @throws { BusinessError } 13900013 - Bad address 4236 * @throws { BusinessError } 13900015 - File exists 4237 * @throws { BusinessError } 13900018 - Not a directory 4238 * @throws { BusinessError } 13900020 - Invalid argument 4239 * @throws { BusinessError } 13900025 - No space left on device 4240 * @throws { BusinessError } 13900028 - Too many links 4241 * @throws { BusinessError } 13900030 - File name too long 4242 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4243 * @throws { BusinessError } 13900041 - Quota exceeded 4244 * @throws { BusinessError } 13900042 - Unknown error 4245 * @syscap SystemCapability.FileManagement.File.FileIO 4246 * @since 9 4247 */ 4248/** 4249 * Creates a temporary directory. This API returns the result synchronously. 4250 * The directory name is created by replacing a string (specified by prefix) with six randomly generated characters. 4251 * 4252 * @param { string } prefix - String to be replaced with six randomly generated characters to create a unique temporary directory. 4253 * @returns { string } Unique path generated. 4254 * @throws { BusinessError } 13900001 - Operation not permitted 4255 * @throws { BusinessError } 13900002 - No such file or directory 4256 * @throws { BusinessError } 13900008 - Bad file descriptor 4257 * @throws { BusinessError } 13900011 - Out of memory 4258 * @throws { BusinessError } 13900012 - Permission denied 4259 * @throws { BusinessError } 13900013 - Bad address 4260 * @throws { BusinessError } 13900015 - File exists 4261 * @throws { BusinessError } 13900018 - Not a directory 4262 * @throws { BusinessError } 13900020 - Invalid argument 4263 * @throws { BusinessError } 13900025 - No space left on device 4264 * @throws { BusinessError } 13900028 - Too many links 4265 * @throws { BusinessError } 13900030 - File name too long 4266 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4267 * @throws { BusinessError } 13900041 - Quota exceeded 4268 * @throws { BusinessError } 13900042 - Unknown error 4269 * @syscap SystemCapability.FileManagement.File.FileIO 4270 * @crossplatform 4271 * @since 10 4272 */ 4273declare function mkdtempSync(prefix: string): string; 4274 4275/** 4276 * Moves the source directory to the destination directory. This API uses a promise to return the result. 4277 * 4278 * @param { string } src - Application sandbox path of the source directory. 4279 * @param { string } dest - Application sandbox path of the destination directory. 4280 * @param { number } [mode = 0] - Move mode. The default value is 0. 4281 * <br>0: Throw an exception if a directory conflict occurs. 4282 * <br>An exception will be thrown if the destination directory contains a non-empty directory with the same name as the source directory. 4283 * <br>1: Throw an exception if a file conflict occurs. 4284 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 4285 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory 4286 * <br>will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. 4287 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 4288 * <br>2: Forcibly overwrite the conflicting files in the destination directory. 4289 * <br>When the destination directory contains a directory with the same name as the source directory, 4290 * <br>the files with the same names in the destination directory are overwritten forcibly; 4291 * <br>the files without conflicts in the destination directory are retained. 4292 * <br>3: Forcibly overwrite the conflicting directory. 4293 * <br>The source directory is moved to the destination directory, and the content of the moved directory is the 4294 * <br>same as that of the source directory. If the destination directory contains a directory with the same name 4295 * <br>as the source directory, all original files in the directory will be deleted. 4296 * @returns { Promise<void> } Promise that returns no value. 4297 * @throws { BusinessError } 13900001 - Operation not permitted 4298 * @throws { BusinessError } 13900002 - No such file or directory 4299 * @throws { BusinessError } 13900008 - Bad file descriptor 4300 * @throws { BusinessError } 13900011 - Out of memory 4301 * @throws { BusinessError } 13900012 - Permission denied 4302 * @throws { BusinessError } 13900013 - Bad address 4303 * @throws { BusinessError } 13900014 - Device or resource busy 4304 * @throws { BusinessError } 13900015 - File exists 4305 * @throws { BusinessError } 13900016 - Cross-device link 4306 * @throws { BusinessError } 13900018 - Not a directory 4307 * @throws { BusinessError } 13900019 - Is a directory 4308 * @throws { BusinessError } 13900020 - Invalid argument 4309 * @throws { BusinessError } 13900025 - No space left on device 4310 * @throws { BusinessError } 13900027 - Read-only file system 4311 * @throws { BusinessError } 13900028 - Too many links 4312 * @throws { BusinessError } 13900032 - Directory not empty 4313 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4314 * @throws { BusinessError } 13900041 - Quota exceeded 4315 * @throws { BusinessError } 13900042 - Unknown error 4316 * @syscap SystemCapability.FileManagement.File.FileIO 4317 * @since 10 4318 */ 4319/** 4320 * Moves the source directory to the destination directory. This API uses a promise to return the result. 4321 * 4322 * @param { string } src - Application sandbox path of the source directory. 4323 * @param { string } dest - Application sandbox path of the destination directory. 4324 * @param { number } [mode = 0] - Move mode. The default value is 0. 4325 * <br>0: Throw an exception if a directory conflict occurs. 4326 * <br>An exception will be thrown if the destination directory contains a non-empty directory with the same name as the source directory. 4327 * <br>1: Throw an exception if a file conflict occurs. 4328 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 4329 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory 4330 * <br>will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. 4331 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 4332 * <br>2: Forcibly overwrite the conflicting files in the destination directory. 4333 * <br>When the destination directory contains a directory with the same name as the source directory, 4334 * <br>the files with the same names in the destination directory are overwritten forcibly; 4335 * <br>the files without conflicts in the destination directory are retained. 4336 * <br>3: Forcibly overwrite the conflicting directory. 4337 * <br>The source directory is moved to the destination directory, and the content of the moved directory is the 4338 * <br>same as that of the source directory. If the destination directory contains a directory with the same name 4339 * <br>as the source directory, all original files in the directory will be deleted. 4340 * @returns { Promise<void> } Promise that returns no value. 4341 * @throws { BusinessError } 13900001 - Operation not permitted 4342 * @throws { BusinessError } 13900002 - No such file or directory 4343 * @throws { BusinessError } 13900008 - Bad file descriptor 4344 * @throws { BusinessError } 13900011 - Out of memory 4345 * @throws { BusinessError } 13900012 - Permission denied 4346 * @throws { BusinessError } 13900013 - Bad address 4347 * @throws { BusinessError } 13900014 - Device or resource busy 4348 * @throws { BusinessError } 13900015 - File exists 4349 * @throws { BusinessError } 13900016 - Cross-device link 4350 * @throws { BusinessError } 13900018 - Not a directory 4351 * @throws { BusinessError } 13900019 - Is a directory 4352 * @throws { BusinessError } 13900020 - Invalid argument 4353 * @throws { BusinessError } 13900025 - No space left on device 4354 * @throws { BusinessError } 13900027 - Read-only file system 4355 * @throws { BusinessError } 13900028 - Too many links 4356 * @throws { BusinessError } 13900032 - Directory not empty 4357 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4358 * @throws { BusinessError } 13900041 - Quota exceeded 4359 * @throws { BusinessError } 13900042 - Unknown error 4360 * @syscap SystemCapability.FileManagement.File.FileIO 4361 * @crossplatform 4362 * @since 20 4363 */ 4364declare function moveDir(src: string, dest: string, mode?: number): Promise<void>; 4365 4366/** 4367 * Moves the source directory to the destination directory. This API uses an asynchronous callback to return the result. 4368 * 4369 * @param { string } src - Application sandbox path of the source directory. 4370 * @param { string } dest - Application sandbox path of the destination directory. 4371 * @param { AsyncCallback<void> } callback - Callback used to return the result. 4372 * @throws { BusinessError } 13900001 - Operation not permitted 4373 * @throws { BusinessError } 13900002 - No such file or directory 4374 * @throws { BusinessError } 13900008 - Bad file descriptor 4375 * @throws { BusinessError } 13900011 - Out of memory 4376 * @throws { BusinessError } 13900012 - Permission denied 4377 * @throws { BusinessError } 13900013 - Bad address 4378 * @throws { BusinessError } 13900014 - Device or resource busy 4379 * @throws { BusinessError } 13900016 - Cross-device link 4380 * @throws { BusinessError } 13900018 - Not a directory 4381 * @throws { BusinessError } 13900019 - Is a directory 4382 * @throws { BusinessError } 13900020 - Invalid argument 4383 * @throws { BusinessError } 13900025 - No space left on device 4384 * @throws { BusinessError } 13900027 - Read-only file system 4385 * @throws { BusinessError } 13900028 - Too many links 4386 * @throws { BusinessError } 13900032 - Directory not empty 4387 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4388 * @throws { BusinessError } 13900041 - Quota exceeded 4389 * @throws { BusinessError } 13900042 - Unknown error 4390 * @syscap SystemCapability.FileManagement.File.FileIO 4391 * @since 10 4392 */ 4393/** 4394 * Moves the source directory to the destination directory. This API uses an asynchronous callback to return the result. 4395 * 4396 * @param { string } src - Application sandbox path of the source directory. 4397 * @param { string } dest - Application sandbox path of the destination directory. 4398 * @param { AsyncCallback<void> } callback - Callback used to return the result. 4399 * @throws { BusinessError } 13900001 - Operation not permitted 4400 * @throws { BusinessError } 13900002 - No such file or directory 4401 * @throws { BusinessError } 13900008 - Bad file descriptor 4402 * @throws { BusinessError } 13900011 - Out of memory 4403 * @throws { BusinessError } 13900012 - Permission denied 4404 * @throws { BusinessError } 13900013 - Bad address 4405 * @throws { BusinessError } 13900014 - Device or resource busy 4406 * @throws { BusinessError } 13900016 - Cross-device link 4407 * @throws { BusinessError } 13900018 - Not a directory 4408 * @throws { BusinessError } 13900019 - Is a directory 4409 * @throws { BusinessError } 13900020 - Invalid argument 4410 * @throws { BusinessError } 13900025 - No space left on device 4411 * @throws { BusinessError } 13900027 - Read-only file system 4412 * @throws { BusinessError } 13900028 - Too many links 4413 * @throws { BusinessError } 13900032 - Directory not empty 4414 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4415 * @throws { BusinessError } 13900041 - Quota exceeded 4416 * @throws { BusinessError } 13900042 - Unknown error 4417 * @syscap SystemCapability.FileManagement.File.FileIO 4418 * @crossplatform 4419 * @since 20 4420 */ 4421declare function moveDir(src: string, dest: string, callback: AsyncCallback<void>): void; 4422 4423/** 4424 * Moves the source directory to the destination directory. This API uses an asynchronous callback to return the result. 4425 * 4426 * @param { string } src - Application sandbox path of the source directory. 4427 * @param { string } dest - Application sandbox path of the destination directory. 4428 * @param { AsyncCallback<void, Array<ConflictFiles>> } callback - Callback used to return the result. 4429 * @throws { BusinessError } 13900015 - File exists 4430 * @syscap SystemCapability.FileManagement.File.FileIO 4431 * @since 10 4432 */ 4433/** 4434 * Moves the source directory to the destination directory. This API uses an asynchronous callback to return the result. 4435 * 4436 * @param { string } src - Application sandbox path of the source directory. 4437 * @param { string } dest - Application sandbox path of the destination directory. 4438 * @param { AsyncCallback<void, Array<ConflictFiles>> } callback - Callback used to return the result. 4439 * @throws { BusinessError } 13900015 - File exists 4440 * @syscap SystemCapability.FileManagement.File.FileIO 4441 * @crossplatform 4442 * @since 20 4443 */ 4444declare function moveDir(src: string, dest: string, callback: AsyncCallback<void, Array<ConflictFiles>>): void; 4445 4446/** 4447 * Moves the source directory to the destination directory. You can set the move mode. 4448 * This API uses an asynchronous callback to return the result. 4449 * 4450 * @param { string } src - Application sandbox path of the source directory. 4451 * @param { string } dest - Application sandbox path of the destination directory. 4452 * @param { number } mode - Move mode. The default value is 0. 4453 * <br>0: Throw an exception if a directory conflict occurs. 4454 * <br>An exception will be thrown if the destination directory contains a non-empty directory with the same name as the source directory. 4455 * <br>1: Throw an exception if a file conflict occurs. 4456 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 4457 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory 4458 * <br>will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. 4459 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 4460 * <br>2: Forcibly overwrite the conflicting files in the destination directory. 4461 * <br>When the destination directory contains a directory with the same name as the source directory, 4462 * <br>the files with the same names in the destination directory are overwritten forcibly; 4463 * <br>the files without conflicts in the destination directory are retained. 4464 * <br>3: Forcibly overwrite the conflicting directory. 4465 * <br>The source directory is moved to the destination directory, and the content of the moved directory is the 4466 * <br>same as that of the source directory. If the destination directory contains a directory with the same name 4467 * <br>as the source directory, all original files in the directory will be deleted. 4468 * @param { AsyncCallback<void> } callback - Return the callback function. 4469 * @throws { BusinessError } 13900001 - Operation not permitted 4470 * @throws { BusinessError } 13900002 - No such file or directory 4471 * @throws { BusinessError } 13900008 - Bad file descriptor 4472 * @throws { BusinessError } 13900011 - Out of memory 4473 * @throws { BusinessError } 13900012 - Permission denied 4474 * @throws { BusinessError } 13900013 - Bad address 4475 * @throws { BusinessError } 13900014 - Device or resource busy 4476 * @throws { BusinessError } 13900016 - Cross-device link 4477 * @throws { BusinessError } 13900018 - Not a directory 4478 * @throws { BusinessError } 13900019 - Is a directory 4479 * @throws { BusinessError } 13900020 - Invalid argument 4480 * @throws { BusinessError } 13900025 - No space left on device 4481 * @throws { BusinessError } 13900027 - Read-only file system 4482 * @throws { BusinessError } 13900028 - Too many links 4483 * @throws { BusinessError } 13900032 - Directory not empty 4484 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4485 * @throws { BusinessError } 13900041 - Quota exceeded 4486 * @throws { BusinessError } 13900042 - Unknown error 4487 * @syscap SystemCapability.FileManagement.File.FileIO 4488 * @since 10 4489 */ 4490/** 4491 * Moves the source directory to the destination directory. You can set the move mode. 4492 * This API uses an asynchronous callback to return the result. 4493 * 4494 * @param { string } src - Application sandbox path of the source directory. 4495 * @param { string } dest - Application sandbox path of the destination directory. 4496 * @param { number } mode - Move mode. The default value is 0. 4497 * <br>0: Throw an exception if a directory conflict occurs. 4498 * <br>An exception will be thrown if the destination directory contains a non-empty directory with the same name as the source directory. 4499 * <br>1: Throw an exception if a file conflict occurs. 4500 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 4501 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory 4502 * <br>will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. 4503 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 4504 * <br>2: Forcibly overwrite the conflicting files in the destination directory. 4505 * <br>When the destination directory contains a directory with the same name as the source directory, 4506 * <br>the files with the same names in the destination directory are overwritten forcibly; 4507 * <br>the files without conflicts in the destination directory are retained. 4508 * <br>3: Forcibly overwrite the conflicting directory. 4509 * <br>The source directory is moved to the destination directory, and the content of the moved directory is the 4510 * <br>same as that of the source directory. If the destination directory contains a directory with the same name 4511 * <br>as the source directory, all original files in the directory will be deleted. 4512 * @param { AsyncCallback<void> } callback - Return the callback function. 4513 * @throws { BusinessError } 13900001 - Operation not permitted 4514 * @throws { BusinessError } 13900002 - No such file or directory 4515 * @throws { BusinessError } 13900008 - Bad file descriptor 4516 * @throws { BusinessError } 13900011 - Out of memory 4517 * @throws { BusinessError } 13900012 - Permission denied 4518 * @throws { BusinessError } 13900013 - Bad address 4519 * @throws { BusinessError } 13900014 - Device or resource busy 4520 * @throws { BusinessError } 13900016 - Cross-device link 4521 * @throws { BusinessError } 13900018 - Not a directory 4522 * @throws { BusinessError } 13900019 - Is a directory 4523 * @throws { BusinessError } 13900020 - Invalid argument 4524 * @throws { BusinessError } 13900025 - No space left on device 4525 * @throws { BusinessError } 13900027 - Read-only file system 4526 * @throws { BusinessError } 13900028 - Too many links 4527 * @throws { BusinessError } 13900032 - Directory not empty 4528 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4529 * @throws { BusinessError } 13900041 - Quota exceeded 4530 * @throws { BusinessError } 13900042 - Unknown error 4531 * @syscap SystemCapability.FileManagement.File.FileIO 4532 * @crossplatform 4533 * @since 20 4534 */ 4535declare function moveDir(src: string, dest: string, mode: number, callback: AsyncCallback<void>): void; 4536 4537/** 4538 * Moves the source directory to the destination directory. You can set the move mode. 4539 * This API uses an asynchronous callback to return the result. 4540 * 4541 * @param { string } src - Application sandbox path of the source directory. 4542 * @param { string } dest - Application sandbox path of the destination directory. 4543 * @param { number } mode - Move mode. The default value is 0. 4544 * <br>0: Throw an exception if a directory conflict occurs. 4545 * <br>An exception will be thrown if the destination directory contains a non-empty directory with the same name as the source directory. 4546 * <br>1: Throw an exception if a file conflict occurs. 4547 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 4548 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory 4549 * <br>will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. 4550 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 4551 * <br>2: Forcibly overwrite the conflicting files in the destination directory. 4552 * <br>When the destination directory contains a directory with the same name as the source directory, 4553 * <br>the files with the same names in the destination directory are overwritten forcibly; 4554 * <br>the files without conflicts in the destination directory are retained. 4555 * <br>3: Forcibly overwrite the conflicting directory. 4556 * <br>The source directory is moved to the destination directory, and the content of the moved directory is the 4557 * <br>same as that of the source directory. If the destination directory contains a directory with the same name 4558 * <br>as the source directory, all original files in the directory will be deleted. 4559 * @param { AsyncCallback<void, Array<ConflictFiles>> } callback - Callback used to return the result. 4560 * @throws { BusinessError } 13900015 - File exists 4561 * @syscap SystemCapability.FileManagement.File.FileIO 4562 * @since 10 4563 */ 4564/** 4565 * Moves the source directory to the destination directory. You can set the move mode. 4566 * This API uses an asynchronous callback to return the result. 4567 * 4568 * @param { string } src - Application sandbox path of the source directory. 4569 * @param { string } dest - Application sandbox path of the destination directory. 4570 * @param { number } mode - Move mode. The default value is 0. 4571 * <br>0: Throw an exception if a directory conflict occurs. 4572 * <br>An exception will be thrown if the destination directory contains a non-empty directory with the same name as the source directory. 4573 * <br>1: Throw an exception if a file conflict occurs. 4574 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 4575 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory 4576 * <br>will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. 4577 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 4578 * <br>2: Forcibly overwrite the conflicting files in the destination directory. 4579 * <br>When the destination directory contains a directory with the same name as the source directory, 4580 * <br>the files with the same names in the destination directory are overwritten forcibly; 4581 * <br>the files without conflicts in the destination directory are retained. 4582 * <br>3: Forcibly overwrite the conflicting directory. 4583 * <br>The source directory is moved to the destination directory, and the content of the moved directory is the 4584 * <br>same as that of the source directory. If the destination directory contains a directory with the same name 4585 * <br>as the source directory, all original files in the directory will be deleted. 4586 * @param { AsyncCallback<void, Array<ConflictFiles>> } callback - Callback used to return the result. 4587 * @throws { BusinessError } 13900015 - File exists 4588 * @syscap SystemCapability.FileManagement.File.FileIO 4589 * @crossplatform 4590 * @since 20 4591 */ 4592declare function moveDir(src: string, dest: string, mode: number, callback: AsyncCallback<void, Array<ConflictFiles>>): void; 4593 4594/** 4595 * Moves the source directory to the destination directory. This API returns the result synchronously. 4596 * 4597 * @param { string } src - Application sandbox path of the source directory. 4598 * @param { string } dest - Application sandbox path of the destination directory. 4599 * @param { number } [mode = 0] - Move mode. The default value is 0. 4600 * <br>0: Throw an exception if a directory conflict occurs. 4601 * <br>An exception will be thrown if the destination directory contains a non-empty directory with the same name as the source directory. 4602 * <br>1: Throw an exception if a file conflict occurs. 4603 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 4604 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory 4605 * <br>will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. 4606 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 4607 * <br>2: Forcibly overwrite the conflicting files in the destination directory. 4608 * <br>When the destination directory contains a directory with the same name as the source directory, 4609 * <br>the files with the same names in the destination directory are overwritten forcibly; 4610 * <br>the files without conflicts in the destination directory are retained. 4611 * <br>3: Forcibly overwrite the conflicting directory. 4612 * <br>The source directory is moved to the destination directory, and the content of the moved directory is the 4613 * <br>same as that of the source directory. If the destination directory contains a directory with the same name 4614 * <br>as the source directory, all original files in the directory will be deleted. 4615 * @throws { BusinessError } 13900001 - Operation not permitted 4616 * @throws { BusinessError } 13900002 - No such file or directory 4617 * @throws { BusinessError } 13900008 - Bad file descriptor 4618 * @throws { BusinessError } 13900011 - Out of memory 4619 * @throws { BusinessError } 13900012 - Permission denied 4620 * @throws { BusinessError } 13900013 - Bad address 4621 * @throws { BusinessError } 13900014 - Device or resource busy 4622 * @throws { BusinessError } 13900015 - File exists 4623 * @throws { BusinessError } 13900016 - Cross-device link 4624 * @throws { BusinessError } 13900018 - Not a directory 4625 * @throws { BusinessError } 13900019 - Is a directory 4626 * @throws { BusinessError } 13900020 - Invalid argument 4627 * @throws { BusinessError } 13900025 - No space left on device 4628 * @throws { BusinessError } 13900027 - Read-only file system 4629 * @throws { BusinessError } 13900028 - Too many links 4630 * @throws { BusinessError } 13900032 - Directory not empty 4631 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4632 * @throws { BusinessError } 13900041 - Quota exceeded 4633 * @throws { BusinessError } 13900042 - Unknown error 4634 * @syscap SystemCapability.FileManagement.File.FileIO 4635 * @since 10 4636 */ 4637/** 4638 * Moves the source directory to the destination directory. This API returns the result synchronously. 4639 * 4640 * @param { string } src - Application sandbox path of the source directory. 4641 * @param { string } dest - Application sandbox path of the destination directory. 4642 * @param { number } [mode = 0] - Move mode. The default value is 0. 4643 * <br>0: Throw an exception if a directory conflict occurs. 4644 * <br>An exception will be thrown if the destination directory contains a non-empty directory with the same name as the source directory. 4645 * <br>1: Throw an exception if a file conflict occurs. 4646 * <br>An exception will be thrown if the destination directory contains a directory with the same name as the source directory, 4647 * <br>and a file with the same name exists in the conflict directory. All the non-conflicting files in the source directory 4648 * <br>will be moved to the destination directory, and the non-conflicting files in the destination directory will be retained. 4649 * <br>The data attribute in the error returned provides information about the conflicting files in the Array<ConflictFiles> format. 4650 * <br>2: Forcibly overwrite the conflicting files in the destination directory. 4651 * <br>When the destination directory contains a directory with the same name as the source directory, 4652 * <br>the files with the same names in the destination directory are overwritten forcibly; 4653 * <br>the files without conflicts in the destination directory are retained. 4654 * <br>3: Forcibly overwrite the conflicting directory. 4655 * <br>The source directory is moved to the destination directory, and the content of the moved directory is the 4656 * <br>same as that of the source directory. If the destination directory contains a directory with the same name 4657 * <br>as the source directory, all original files in the directory will be deleted. 4658 * @throws { BusinessError } 13900001 - Operation not permitted 4659 * @throws { BusinessError } 13900002 - No such file or directory 4660 * @throws { BusinessError } 13900008 - Bad file descriptor 4661 * @throws { BusinessError } 13900011 - Out of memory 4662 * @throws { BusinessError } 13900012 - Permission denied 4663 * @throws { BusinessError } 13900013 - Bad address 4664 * @throws { BusinessError } 13900014 - Device or resource busy 4665 * @throws { BusinessError } 13900015 - File exists 4666 * @throws { BusinessError } 13900016 - Cross-device link 4667 * @throws { BusinessError } 13900018 - Not a directory 4668 * @throws { BusinessError } 13900019 - Is a directory 4669 * @throws { BusinessError } 13900020 - Invalid argument 4670 * @throws { BusinessError } 13900025 - No space left on device 4671 * @throws { BusinessError } 13900027 - Read-only file system 4672 * @throws { BusinessError } 13900028 - Too many links 4673 * @throws { BusinessError } 13900032 - Directory not empty 4674 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4675 * @throws { BusinessError } 13900041 - Quota exceeded 4676 * @throws { BusinessError } 13900042 - Unknown error 4677 * @syscap SystemCapability.FileManagement.File.FileIO 4678 * @crossplatform 4679 * @since 20 4680 */ 4681declare function moveDirSync(src: string, dest: string, mode?: number): void; 4682 4683/** 4684 * Move file. 4685 * 4686 * @param { string } src - source file path. 4687 * @param { string } dest - destination file path. 4688 * @param { number } [mode = 0] - move mode when duplicate file name exists. 4689 * @returns { Promise<void> } The promise returned by the function. 4690 * @throws { BusinessError } 13900001 - Operation not permitted 4691 * @throws { BusinessError } 13900002 - No such file or directory 4692 * @throws { BusinessError } 13900008 - Bad file descriptor 4693 * @throws { BusinessError } 13900011 - Out of memory 4694 * @throws { BusinessError } 13900012 - Permission denied 4695 * @throws { BusinessError } 13900013 - Bad address 4696 * @throws { BusinessError } 13900014 - Device or resource busy 4697 * @throws { BusinessError } 13900015 - File exists 4698 * @throws { BusinessError } 13900016 - Cross-device link 4699 * @throws { BusinessError } 13900018 - Not a directory 4700 * @throws { BusinessError } 13900019 - Is a directory 4701 * @throws { BusinessError } 13900020 - Invalid argument 4702 * @throws { BusinessError } 13900025 - No space left on device 4703 * @throws { BusinessError } 13900027 - Read-only file system 4704 * @throws { BusinessError } 13900028 - Too many links 4705 * @throws { BusinessError } 13900032 - Directory not empty 4706 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4707 * @throws { BusinessError } 13900041 - Quota exceeded 4708 * @throws { BusinessError } 13900042 - Unknown error 4709 * @syscap SystemCapability.FileManagement.File.FileIO 4710 * @since 9 4711 */ 4712/** 4713 * Moves a file. This API uses a promise to return the result. 4714 * 4715 * @param { string } src - Application sandbox path of the file to move. 4716 * @param { string } dest - Application sandbox path of the destination file. 4717 * @param { number } [mode = 0] - Move mode. 4718 * <br>The value 0 means to overwrite the file with the same name in the destination directory; 4719 * <br>the value 1 means to throw an exception. The default value is 0. 4720 * @returns { Promise<void> } Promise that returns no value. 4721 * @throws { BusinessError } 13900001 - Operation not permitted 4722 * @throws { BusinessError } 13900002 - No such file or directory 4723 * @throws { BusinessError } 13900008 - Bad file descriptor 4724 * @throws { BusinessError } 13900011 - Out of memory 4725 * @throws { BusinessError } 13900012 - Permission denied 4726 * @throws { BusinessError } 13900013 - Bad address 4727 * @throws { BusinessError } 13900014 - Device or resource busy 4728 * @throws { BusinessError } 13900015 - File exists 4729 * @throws { BusinessError } 13900016 - Cross-device link 4730 * @throws { BusinessError } 13900018 - Not a directory 4731 * @throws { BusinessError } 13900019 - Is a directory 4732 * @throws { BusinessError } 13900020 - Invalid argument 4733 * @throws { BusinessError } 13900025 - No space left on device 4734 * @throws { BusinessError } 13900027 - Read-only file system 4735 * @throws { BusinessError } 13900028 - Too many links 4736 * @throws { BusinessError } 13900032 - Directory not empty 4737 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4738 * @throws { BusinessError } 13900041 - Quota exceeded 4739 * @throws { BusinessError } 13900042 - Unknown error 4740 * @syscap SystemCapability.FileManagement.File.FileIO 4741 * @crossplatform 4742 * @since 10 4743 */ 4744declare function moveFile(src: string, dest: string, mode?: number): Promise<void>; 4745 4746/** 4747 * Move file. 4748 * 4749 * @param { string } src - source file path. 4750 * @param { string } dest - destination file path. 4751 * @param { AsyncCallback<void> } callback - Return the callback function. 4752 * @throws { BusinessError } 13900001 - Operation not permitted 4753 * @throws { BusinessError } 13900002 - No such file or directory 4754 * @throws { BusinessError } 13900008 - Bad file descriptor 4755 * @throws { BusinessError } 13900011 - Out of memory 4756 * @throws { BusinessError } 13900012 - Permission denied 4757 * @throws { BusinessError } 13900013 - Bad address 4758 * @throws { BusinessError } 13900014 - Device or resource busy 4759 * @throws { BusinessError } 13900015 - File exists 4760 * @throws { BusinessError } 13900016 - Cross-device link 4761 * @throws { BusinessError } 13900018 - Not a directory 4762 * @throws { BusinessError } 13900019 - Is a directory 4763 * @throws { BusinessError } 13900020 - Invalid argument 4764 * @throws { BusinessError } 13900025 - No space left on device 4765 * @throws { BusinessError } 13900027 - Read-only file system 4766 * @throws { BusinessError } 13900028 - Too many links 4767 * @throws { BusinessError } 13900032 - Directory not empty 4768 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4769 * @throws { BusinessError } 13900041 - Quota exceeded 4770 * @throws { BusinessError } 13900042 - Unknown error 4771 * @syscap SystemCapability.FileManagement.File.FileIO 4772 * @since 9 4773 */ 4774/** 4775 * Moves a file and forcibly overwrites the file with the same name in the destination directory. 4776 * This API uses an asynchronous callback to return the result. 4777 * 4778 * @param { string } src - Application sandbox path of the file to move. 4779 * @param { string } dest - Application sandbox path of the destination file. 4780 * @param { AsyncCallback<void> } callback - Callback used to return the result. 4781 * @throws { BusinessError } 13900001 - Operation not permitted 4782 * @throws { BusinessError } 13900002 - No such file or directory 4783 * @throws { BusinessError } 13900008 - Bad file descriptor 4784 * @throws { BusinessError } 13900011 - Out of memory 4785 * @throws { BusinessError } 13900012 - Permission denied 4786 * @throws { BusinessError } 13900013 - Bad address 4787 * @throws { BusinessError } 13900014 - Device or resource busy 4788 * @throws { BusinessError } 13900015 - File exists 4789 * @throws { BusinessError } 13900016 - Cross-device link 4790 * @throws { BusinessError } 13900018 - Not a directory 4791 * @throws { BusinessError } 13900019 - Is a directory 4792 * @throws { BusinessError } 13900020 - Invalid argument 4793 * @throws { BusinessError } 13900025 - No space left on device 4794 * @throws { BusinessError } 13900027 - Read-only file system 4795 * @throws { BusinessError } 13900028 - Too many links 4796 * @throws { BusinessError } 13900032 - Directory not empty 4797 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4798 * @throws { BusinessError } 13900041 - Quota exceeded 4799 * @throws { BusinessError } 13900042 - Unknown error 4800 * @syscap SystemCapability.FileManagement.File.FileIO 4801 * @crossplatform 4802 * @since 10 4803 */ 4804declare function moveFile(src: string, dest: string, callback: AsyncCallback<void>): void; 4805 4806/** 4807 * Move file. 4808 * 4809 * @param { string } src - source file path. 4810 * @param { string } dest - destination file path. 4811 * @param { number } [mode = 0] - move mode when duplicate file name exists. 4812 * @param { AsyncCallback<void> } callback - Return the callback function. 4813 * @throws { BusinessError } 13900001 - Operation not permitted 4814 * @throws { BusinessError } 13900002 - No such file or directory 4815 * @throws { BusinessError } 13900008 - Bad file descriptor 4816 * @throws { BusinessError } 13900011 - Out of memory 4817 * @throws { BusinessError } 13900012 - Permission denied 4818 * @throws { BusinessError } 13900013 - Bad address 4819 * @throws { BusinessError } 13900014 - Device or resource busy 4820 * @throws { BusinessError } 13900015 - File exists 4821 * @throws { BusinessError } 13900016 - Cross-device link 4822 * @throws { BusinessError } 13900018 - Not a directory 4823 * @throws { BusinessError } 13900019 - Is a directory 4824 * @throws { BusinessError } 13900020 - Invalid argument 4825 * @throws { BusinessError } 13900025 - No space left on device 4826 * @throws { BusinessError } 13900027 - Read-only file system 4827 * @throws { BusinessError } 13900028 - Too many links 4828 * @throws { BusinessError } 13900032 - Directory not empty 4829 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4830 * @throws { BusinessError } 13900041 - Quota exceeded 4831 * @throws { BusinessError } 13900042 - Unknown error 4832 * @syscap SystemCapability.FileManagement.File.FileIO 4833 * @since 9 4834 */ 4835/** 4836 * Moves a file with the specified mode. This API uses an asynchronous callback to return the result. 4837 * 4838 * @param { string } src - Application sandbox path of the file to move. 4839 * @param { string } dest - Application sandbox path of the destination to move. 4840 * @param { number } [mode = 0] - Move mode. 4841 * <br>The value 0 means to overwrite the file with the same name in the destination directory; 4842 * <br>the value 1 means to throw an exception. The default value is 0. 4843 * @param { AsyncCallback<void> } callback - Callback used to return the result. 4844 * @throws { BusinessError } 13900001 - Operation not permitted 4845 * @throws { BusinessError } 13900002 - No such file or directory 4846 * @throws { BusinessError } 13900008 - Bad file descriptor 4847 * @throws { BusinessError } 13900011 - Out of memory 4848 * @throws { BusinessError } 13900012 - Permission denied 4849 * @throws { BusinessError } 13900013 - Bad address 4850 * @throws { BusinessError } 13900014 - Device or resource busy 4851 * @throws { BusinessError } 13900015 - File exists 4852 * @throws { BusinessError } 13900016 - Cross-device link 4853 * @throws { BusinessError } 13900018 - Not a directory 4854 * @throws { BusinessError } 13900019 - Is a directory 4855 * @throws { BusinessError } 13900020 - Invalid argument 4856 * @throws { BusinessError } 13900025 - No space left on device 4857 * @throws { BusinessError } 13900027 - Read-only file system 4858 * @throws { BusinessError } 13900028 - Too many links 4859 * @throws { BusinessError } 13900032 - Directory not empty 4860 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4861 * @throws { BusinessError } 13900041 - Quota exceeded 4862 * @throws { BusinessError } 13900042 - Unknown error 4863 * @syscap SystemCapability.FileManagement.File.FileIO 4864 * @crossplatform 4865 * @since 10 4866 */ 4867declare function moveFile(src: string, dest: string, mode: number, callback: AsyncCallback<void>): void; 4868 4869/** 4870 * Move file with sync interface. 4871 * 4872 * @param { string } src - source file path. 4873 * @param { string } dest - destination file path. 4874 * @param { number } [mode = 0] - move mode when duplicate file name exists. 4875 * @throws { BusinessError } 13900001 - Operation not permitted 4876 * @throws { BusinessError } 13900002 - No such file or directory 4877 * @throws { BusinessError } 13900008 - Bad file descriptor 4878 * @throws { BusinessError } 13900011 - Out of memory 4879 * @throws { BusinessError } 13900012 - Permission denied 4880 * @throws { BusinessError } 13900013 - Bad address 4881 * @throws { BusinessError } 13900014 - Device or resource busy 4882 * @throws { BusinessError } 13900015 - File exists 4883 * @throws { BusinessError } 13900016 - Cross-device link 4884 * @throws { BusinessError } 13900018 - Not a directory 4885 * @throws { BusinessError } 13900019 - Is a directory 4886 * @throws { BusinessError } 13900020 - Invalid argument 4887 * @throws { BusinessError } 13900025 - No space left on device 4888 * @throws { BusinessError } 13900027 - Read-only file system 4889 * @throws { BusinessError } 13900028 - Too many links 4890 * @throws { BusinessError } 13900032 - Directory not empty 4891 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4892 * @throws { BusinessError } 13900041 - Quota exceeded 4893 * @throws { BusinessError } 13900042 - Unknown error 4894 * @syscap SystemCapability.FileManagement.File.FileIO 4895 * @since 9 4896 */ 4897/** 4898 * Moves a file. This API returns the result synchronously. 4899 * 4900 * @param { string } src - Application sandbox path of the file to move. 4901 * @param { string } dest - Application sandbox path of the destination to move. 4902 * @param { number } [mode = 0] - Move mode. 4903 * <br>The value 0 means to overwrite the file with the same name in the destination directory; 4904 * <br>the value 1 means to throw an exception. The default value is 0. 4905 * @throws { BusinessError } 13900001 - Operation not permitted 4906 * @throws { BusinessError } 13900002 - No such file or directory 4907 * @throws { BusinessError } 13900008 - Bad file descriptor 4908 * @throws { BusinessError } 13900011 - Out of memory 4909 * @throws { BusinessError } 13900012 - Permission denied 4910 * @throws { BusinessError } 13900013 - Bad address 4911 * @throws { BusinessError } 13900014 - Device or resource busy 4912 * @throws { BusinessError } 13900015 - File exists 4913 * @throws { BusinessError } 13900016 - Cross-device link 4914 * @throws { BusinessError } 13900018 - Not a directory 4915 * @throws { BusinessError } 13900019 - Is a directory 4916 * @throws { BusinessError } 13900020 - Invalid argument 4917 * @throws { BusinessError } 13900025 - No space left on device 4918 * @throws { BusinessError } 13900027 - Read-only file system 4919 * @throws { BusinessError } 13900028 - Too many links 4920 * @throws { BusinessError } 13900032 - Directory not empty 4921 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4922 * @throws { BusinessError } 13900041 - Quota exceeded 4923 * @throws { BusinessError } 13900042 - Unknown error 4924 * @syscap SystemCapability.FileManagement.File.FileIO 4925 * @crossplatform 4926 * @since 10 4927 */ 4928declare function moveFileSync(src: string, dest: string, mode?: number): void; 4929 4930/** 4931 * Open file. 4932 * 4933 * @param { string } path - path. 4934 * @param { number } [mode = OpenMode.READ_ONLY] - mode. 4935 * @returns { Promise<File> } Returns the File object in Promise mode to record the file descriptor. 4936 * @throws { BusinessError } 13900001 - Operation not permitted 4937 * @throws { BusinessError } 13900002 - No such file or directory 4938 * @throws { BusinessError } 13900004 - Interrupted system call 4939 * @throws { BusinessError } 13900006 - No such device or address 4940 * @throws { BusinessError } 13900008 - Bad file descriptor 4941 * @throws { BusinessError } 13900011 - Out of memory 4942 * @throws { BusinessError } 13900012 - Permission denied 4943 * @throws { BusinessError } 13900013 - Bad address 4944 * @throws { BusinessError } 13900014 - Device or resource busy 4945 * @throws { BusinessError } 13900015 - File exists 4946 * @throws { BusinessError } 13900017 - No such device 4947 * @throws { BusinessError } 13900018 - Not a directory 4948 * @throws { BusinessError } 13900019 - Is a directory 4949 * @throws { BusinessError } 13900020 - Invalid argument 4950 * @throws { BusinessError } 13900022 - Too many open files 4951 * @throws { BusinessError } 13900023 - Text file busy 4952 * @throws { BusinessError } 13900024 - File too large 4953 * @throws { BusinessError } 13900025 - No space left on device 4954 * @throws { BusinessError } 13900027 - Read-only file system 4955 * @throws { BusinessError } 13900029 - Resource deadlock would occur 4956 * @throws { BusinessError } 13900030 - File name too long 4957 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4958 * @throws { BusinessError } 13900034 - Operation would block 4959 * @throws { BusinessError } 13900038 - Value too large for defined data type 4960 * @throws { BusinessError } 13900041 - Quota exceeded 4961 * @throws { BusinessError } 13900042 - Unknown error 4962 * @syscap SystemCapability.FileManagement.File.FileIO 4963 * @since 9 4964 */ 4965/** 4966 * Open file. 4967 * 4968 * @param { string } path - path. 4969 * @param { number } [mode = OpenMode.READ_ONLY] - mode. 4970 * @returns { Promise<File> } Returns the File object in Promise mode to record the file descriptor. 4971 * @throws { BusinessError } 13900001 - Operation not permitted 4972 * @throws { BusinessError } 13900002 - No such file or directory 4973 * @throws { BusinessError } 13900004 - Interrupted system call 4974 * @throws { BusinessError } 13900006 - No such device or address 4975 * @throws { BusinessError } 13900008 - Bad file descriptor 4976 * @throws { BusinessError } 13900011 - Out of memory 4977 * @throws { BusinessError } 13900012 - Permission denied 4978 * @throws { BusinessError } 13900013 - Bad address 4979 * @throws { BusinessError } 13900014 - Device or resource busy 4980 * @throws { BusinessError } 13900015 - File exists 4981 * @throws { BusinessError } 13900017 - No such device 4982 * @throws { BusinessError } 13900018 - Not a directory 4983 * @throws { BusinessError } 13900019 - Is a directory 4984 * @throws { BusinessError } 13900020 - Invalid argument 4985 * @throws { BusinessError } 13900022 - Too many open files 4986 * @throws { BusinessError } 13900023 - Text file busy 4987 * @throws { BusinessError } 13900024 - File too large 4988 * @throws { BusinessError } 13900025 - No space left on device 4989 * @throws { BusinessError } 13900027 - Read-only file system 4990 * @throws { BusinessError } 13900029 - Resource deadlock would occur 4991 * @throws { BusinessError } 13900030 - File name too long 4992 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 4993 * @throws { BusinessError } 13900034 - Operation would block 4994 * @throws { BusinessError } 13900038 - Value too large for defined data type 4995 * @throws { BusinessError } 13900041 - Quota exceeded 4996 * @throws { BusinessError } 13900042 - Unknown error 4997 * @syscap SystemCapability.FileManagement.File.FileIO 4998 * @crossplatform 4999 * @since 10 5000 */ 5001/** 5002 * Open file. 5003 * 5004 * @param { string } path - path. 5005 * @param { number } [mode = OpenMode.READ_ONLY] - mode. 5006 * @returns { Promise<File> } Returns the File object in Promise mode to record the file descriptor. 5007 * @throws { BusinessError } 13900001 - Operation not permitted 5008 * @throws { BusinessError } 13900002 - No such file or directory 5009 * @throws { BusinessError } 13900004 - Interrupted system call 5010 * @throws { BusinessError } 13900006 - No such device or address 5011 * @throws { BusinessError } 13900008 - Bad file descriptor 5012 * @throws { BusinessError } 13900011 - Out of memory 5013 * @throws { BusinessError } 13900012 - Permission denied 5014 * @throws { BusinessError } 13900013 - Bad address 5015 * @throws { BusinessError } 13900014 - Device or resource busy 5016 * @throws { BusinessError } 13900015 - File exists 5017 * @throws { BusinessError } 13900017 - No such device 5018 * @throws { BusinessError } 13900018 - Not a directory 5019 * @throws { BusinessError } 13900019 - Is a directory 5020 * @throws { BusinessError } 13900020 - Invalid argument 5021 * @throws { BusinessError } 13900022 - Too many open files 5022 * @throws { BusinessError } 13900023 - Text file busy 5023 * @throws { BusinessError } 13900024 - File too large 5024 * @throws { BusinessError } 13900025 - No space left on device 5025 * @throws { BusinessError } 13900027 - Read-only file system 5026 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5027 * @throws { BusinessError } 13900030 - File name too long 5028 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5029 * @throws { BusinessError } 13900034 - Operation would block 5030 * @throws { BusinessError } 13900038 - Value too large for defined data type 5031 * @throws { BusinessError } 13900041 - Quota exceeded 5032 * @throws { BusinessError } 13900042 - Unknown error 5033 * @syscap SystemCapability.FileManagement.File.FileIO 5034 * @crossplatform 5035 * @atomicservice 5036 * @since 11 5037 */ 5038/** 5039 * Opens a file or directory. This API uses a promise to return the result. This API supports the use of a URI. 5040 * 5041 * @param { string } path - Application sandbox path or URI of the file. 5042 * @param { number } [mode = OpenMode.READ_ONLY] - Mode for opening the file. 5043 * <br>You must specify one of the following options. By default, the file is opened in read-only mode. 5044 * <br>OpenMode.READ_ONLY(0o0): Open the file in read-only mode. 5045 * <br>OpenMode.WRITE_ONLY(0o1): Open the file in write-only mode. 5046 * <br>OpenMode.READ_WRITE(0o2): Open the file in read/write mode. 5047 * <br>You can add the following function options in bitwise OR mode. By default, no additional option is added. 5048 * <br>OpenMode.CREATE(0o100): Create a file if the file does not exist. 5049 * <br>OpenMode.TRUNC(0o1000): If the file exists and is opened in write mode, truncate the file length to 0. 5050 * <br>OpenMode.APPEND(0o2000): Open the file in append mode. New data will be added to the end of the file. 5051 * <br>OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 5052 * <br>or character special file, perform non-blocking operations on the opened file and in subsequent I/Os. 5053 * <br>OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 5054 * <br>OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 5055 * <br>OpenMode.SYNC(0o4010000): Open the file in synchronous I/O mode. 5056 * @returns { Promise<File> } Promise used to return the File object. 5057 * @throws { BusinessError } 13900001 - Operation not permitted 5058 * @throws { BusinessError } 13900002 - No such file or directory 5059 * @throws { BusinessError } 13900004 - Interrupted system call 5060 * @throws { BusinessError } 13900006 - No such device or address 5061 * @throws { BusinessError } 13900008 - Bad file descriptor 5062 * @throws { BusinessError } 13900011 - Out of memory 5063 * @throws { BusinessError } 13900012 - Permission denied 5064 * @throws { BusinessError } 13900013 - Bad address 5065 * @throws { BusinessError } 13900014 - Device or resource busy 5066 * @throws { BusinessError } 13900015 - File exists 5067 * @throws { BusinessError } 13900017 - No such device 5068 * @throws { BusinessError } 13900018 - Not a directory 5069 * @throws { BusinessError } 13900019 - Is a directory 5070 * @throws { BusinessError } 13900020 - Invalid argument 5071 * @throws { BusinessError } 13900022 - Too many open files 5072 * @throws { BusinessError } 13900023 - Text file busy 5073 * @throws { BusinessError } 13900024 - File too large 5074 * @throws { BusinessError } 13900025 - No space left on device 5075 * @throws { BusinessError } 13900027 - Read-only file system 5076 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5077 * @throws { BusinessError } 13900030 - File name too long 5078 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5079 * @throws { BusinessError } 13900034 - Operation would block 5080 * @throws { BusinessError } 13900038 - Value too large for defined data type 5081 * @throws { BusinessError } 13900041 - Quota exceeded 5082 * @throws { BusinessError } 13900042 - Unknown error 5083 * @throws { BusinessError } 13900044 - Network is unreachable 5084 * @syscap SystemCapability.FileManagement.File.FileIO 5085 * @crossplatform 5086 * @atomicservice 5087 * @since 12 5088 */ 5089declare function open(path: string, mode?: number): Promise<File>; 5090 5091/** 5092 * Open file. 5093 * 5094 * @param { string } path - path. 5095 * @param { AsyncCallback<File> } callback - The callback is used to return the File object to record the file descriptor. 5096 * @throws { BusinessError } 13900001 - Operation not permitted 5097 * @throws { BusinessError } 13900002 - No such file or directory 5098 * @throws { BusinessError } 13900004 - Interrupted system call 5099 * @throws { BusinessError } 13900006 - No such device or address 5100 * @throws { BusinessError } 13900008 - Bad file descriptor 5101 * @throws { BusinessError } 13900011 - Out of memory 5102 * @throws { BusinessError } 13900012 - Permission denied 5103 * @throws { BusinessError } 13900013 - Bad address 5104 * @throws { BusinessError } 13900014 - Device or resource busy 5105 * @throws { BusinessError } 13900015 - File exists 5106 * @throws { BusinessError } 13900017 - No such device 5107 * @throws { BusinessError } 13900018 - Not a directory 5108 * @throws { BusinessError } 13900019 - Is a directory 5109 * @throws { BusinessError } 13900020 - Invalid argument 5110 * @throws { BusinessError } 13900022 - Too many open files 5111 * @throws { BusinessError } 13900023 - Text file busy 5112 * @throws { BusinessError } 13900024 - File too large 5113 * @throws { BusinessError } 13900025 - No space left on device 5114 * @throws { BusinessError } 13900027 - Read-only file system 5115 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5116 * @throws { BusinessError } 13900030 - File name too long 5117 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5118 * @throws { BusinessError } 13900034 - Operation would block 5119 * @throws { BusinessError } 13900038 - Value too large for defined data type 5120 * @throws { BusinessError } 13900041 - Quota exceeded 5121 * @throws { BusinessError } 13900042 - Unknown error 5122 * @syscap SystemCapability.FileManagement.File.FileIO 5123 * @since 9 5124 */ 5125/** 5126 * Open file. 5127 * 5128 * @param { string } path - path. 5129 * @param { AsyncCallback<File> } callback - The callback is used to return the File object to record the file descriptor. 5130 * @throws { BusinessError } 13900001 - Operation not permitted 5131 * @throws { BusinessError } 13900002 - No such file or directory 5132 * @throws { BusinessError } 13900004 - Interrupted system call 5133 * @throws { BusinessError } 13900006 - No such device or address 5134 * @throws { BusinessError } 13900008 - Bad file descriptor 5135 * @throws { BusinessError } 13900011 - Out of memory 5136 * @throws { BusinessError } 13900012 - Permission denied 5137 * @throws { BusinessError } 13900013 - Bad address 5138 * @throws { BusinessError } 13900014 - Device or resource busy 5139 * @throws { BusinessError } 13900015 - File exists 5140 * @throws { BusinessError } 13900017 - No such device 5141 * @throws { BusinessError } 13900018 - Not a directory 5142 * @throws { BusinessError } 13900019 - Is a directory 5143 * @throws { BusinessError } 13900020 - Invalid argument 5144 * @throws { BusinessError } 13900022 - Too many open files 5145 * @throws { BusinessError } 13900023 - Text file busy 5146 * @throws { BusinessError } 13900024 - File too large 5147 * @throws { BusinessError } 13900025 - No space left on device 5148 * @throws { BusinessError } 13900027 - Read-only file system 5149 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5150 * @throws { BusinessError } 13900030 - File name too long 5151 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5152 * @throws { BusinessError } 13900034 - Operation would block 5153 * @throws { BusinessError } 13900038 - Value too large for defined data type 5154 * @throws { BusinessError } 13900041 - Quota exceeded 5155 * @throws { BusinessError } 13900042 - Unknown error 5156 * @syscap SystemCapability.FileManagement.File.FileIO 5157 * @crossplatform 5158 * @since 10 5159 */ 5160/** 5161 * Opens a file or directory. This API uses an asynchronous callback to return the result. This API supports the use of a URI. 5162 * 5163 * @param { string } path - Application sandbox path or URI of the file. 5164 * @param { AsyncCallback<File> } callback - Callback used to return the result. 5165 * @throws { BusinessError } 13900001 - Operation not permitted 5166 * @throws { BusinessError } 13900002 - No such file or directory 5167 * @throws { BusinessError } 13900004 - Interrupted system call 5168 * @throws { BusinessError } 13900006 - No such device or address 5169 * @throws { BusinessError } 13900008 - Bad file descriptor 5170 * @throws { BusinessError } 13900011 - Out of memory 5171 * @throws { BusinessError } 13900012 - Permission denied 5172 * @throws { BusinessError } 13900013 - Bad address 5173 * @throws { BusinessError } 13900014 - Device or resource busy 5174 * @throws { BusinessError } 13900015 - File exists 5175 * @throws { BusinessError } 13900017 - No such device 5176 * @throws { BusinessError } 13900018 - Not a directory 5177 * @throws { BusinessError } 13900019 - Is a directory 5178 * @throws { BusinessError } 13900020 - Invalid argument 5179 * @throws { BusinessError } 13900022 - Too many open files 5180 * @throws { BusinessError } 13900023 - Text file busy 5181 * @throws { BusinessError } 13900024 - File too large 5182 * @throws { BusinessError } 13900025 - No space left on device 5183 * @throws { BusinessError } 13900027 - Read-only file system 5184 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5185 * @throws { BusinessError } 13900030 - File name too long 5186 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5187 * @throws { BusinessError } 13900034 - Operation would block 5188 * @throws { BusinessError } 13900038 - Value too large for defined data type 5189 * @throws { BusinessError } 13900041 - Quota exceeded 5190 * @throws { BusinessError } 13900042 - Unknown error 5191 * @syscap SystemCapability.FileManagement.File.FileIO 5192 * @crossplatform 5193 * @atomicservice 5194 * @since 11 5195 */ 5196declare function open(path: string, callback: AsyncCallback<File>): void; 5197 5198/** 5199 * Open file. 5200 * 5201 * @param { string } path - path. 5202 * @param { number } [mode = OpenMode.READ_ONLY] - mode. 5203 * @param { AsyncCallback<File> } callback - The callback is used to return the File object to record the file descriptor. 5204 * @throws { BusinessError } 13900001 - Operation not permitted 5205 * @throws { BusinessError } 13900002 - No such file or directory 5206 * @throws { BusinessError } 13900004 - Interrupted system call 5207 * @throws { BusinessError } 13900006 - No such device or address 5208 * @throws { BusinessError } 13900008 - Bad file descriptor 5209 * @throws { BusinessError } 13900011 - Out of memory 5210 * @throws { BusinessError } 13900012 - Permission denied 5211 * @throws { BusinessError } 13900013 - Bad address 5212 * @throws { BusinessError } 13900014 - Device or resource busy 5213 * @throws { BusinessError } 13900015 - File exists 5214 * @throws { BusinessError } 13900017 - No such device 5215 * @throws { BusinessError } 13900018 - Not a directory 5216 * @throws { BusinessError } 13900019 - Is a directory 5217 * @throws { BusinessError } 13900020 - Invalid argument 5218 * @throws { BusinessError } 13900022 - Too many open files 5219 * @throws { BusinessError } 13900023 - Text file busy 5220 * @throws { BusinessError } 13900024 - File too large 5221 * @throws { BusinessError } 13900025 - No space left on device 5222 * @throws { BusinessError } 13900027 - Read-only file system 5223 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5224 * @throws { BusinessError } 13900030 - File name too long 5225 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5226 * @throws { BusinessError } 13900034 - Operation would block 5227 * @throws { BusinessError } 13900038 - Value too large for defined data type 5228 * @throws { BusinessError } 13900041 - Quota exceeded 5229 * @throws { BusinessError } 13900042 - Unknown error 5230 * @syscap SystemCapability.FileManagement.File.FileIO 5231 * @since 9 5232 */ 5233/** 5234 * Open file. 5235 * 5236 * @param { string } path - path. 5237 * @param { number } [mode = OpenMode.READ_ONLY] - mode. 5238 * @param { AsyncCallback<File> } callback - The callback is used to return the File object to record the file descriptor. 5239 * @throws { BusinessError } 13900001 - Operation not permitted 5240 * @throws { BusinessError } 13900002 - No such file or directory 5241 * @throws { BusinessError } 13900004 - Interrupted system call 5242 * @throws { BusinessError } 13900006 - No such device or address 5243 * @throws { BusinessError } 13900008 - Bad file descriptor 5244 * @throws { BusinessError } 13900011 - Out of memory 5245 * @throws { BusinessError } 13900012 - Permission denied 5246 * @throws { BusinessError } 13900013 - Bad address 5247 * @throws { BusinessError } 13900014 - Device or resource busy 5248 * @throws { BusinessError } 13900015 - File exists 5249 * @throws { BusinessError } 13900017 - No such device 5250 * @throws { BusinessError } 13900018 - Not a directory 5251 * @throws { BusinessError } 13900019 - Is a directory 5252 * @throws { BusinessError } 13900020 - Invalid argument 5253 * @throws { BusinessError } 13900022 - Too many open files 5254 * @throws { BusinessError } 13900023 - Text file busy 5255 * @throws { BusinessError } 13900024 - File too large 5256 * @throws { BusinessError } 13900025 - No space left on device 5257 * @throws { BusinessError } 13900027 - Read-only file system 5258 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5259 * @throws { BusinessError } 13900030 - File name too long 5260 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5261 * @throws { BusinessError } 13900034 - Operation would block 5262 * @throws { BusinessError } 13900038 - Value too large for defined data type 5263 * @throws { BusinessError } 13900041 - Quota exceeded 5264 * @throws { BusinessError } 13900042 - Unknown error 5265 * @syscap SystemCapability.FileManagement.File.FileIO 5266 * @crossplatform 5267 * @since 10 5268 */ 5269/** 5270 * Opens a file or directory with the specified mode. This API uses an asynchronous callback to return the result. 5271 * This API supports the use of a URI. 5272 * 5273 * @param { string } path - Application sandbox path or URI of the file. 5274 * @param { number } [mode = OpenMode.READ_ONLY] - Mode for opening the file. 5275 * <br>You must specify one of the following options. By default, the file is opened in read-only mode. 5276 * <br>OpenMode.READ_ONLY(0o0): Open the file in read-only mode. 5277 * <br>OpenMode.WRITE_ONLY(0o1): Open the file in write-only mode. 5278 * <br>OpenMode.READ_WRITE(0o2): Open the file in read/write mode. 5279 * <br>You can add the following function options in bitwise OR mode. By default, no additional option is added. 5280 * <br>OpenMode.CREATE(0o100): Create a file if the file does not exist. 5281 * <br>OpenMode.TRUNC(0o1000): If the file exists and is opened in write mode, truncate the file length to 0. 5282 * <br>OpenMode.APPEND(0o2000): Open the file in append mode. New data will be added to the end of the file. 5283 * <br>OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 5284 * <br>or character special file, perform non-blocking operations on the opened file and in subsequent I/Os. 5285 * <br>OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 5286 * <br>OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 5287 * <br>OpenMode.SYNC(0o4010000): Open the file in synchronous I/O mode. 5288 * @param { AsyncCallback<File> } callback - The callback is used to return the File object to record the file descriptor. 5289 * @throws { BusinessError } 13900001 - Operation not permitted 5290 * @throws { BusinessError } 13900002 - No such file or directory 5291 * @throws { BusinessError } 13900004 - Interrupted system call 5292 * @throws { BusinessError } 13900006 - No such device or address 5293 * @throws { BusinessError } 13900008 - Bad file descriptor 5294 * @throws { BusinessError } 13900011 - Out of memory 5295 * @throws { BusinessError } 13900012 - Permission denied 5296 * @throws { BusinessError } 13900013 - Bad address 5297 * @throws { BusinessError } 13900014 - Device or resource busy 5298 * @throws { BusinessError } 13900015 - File exists 5299 * @throws { BusinessError } 13900017 - No such device 5300 * @throws { BusinessError } 13900018 - Not a directory 5301 * @throws { BusinessError } 13900019 - Is a directory 5302 * @throws { BusinessError } 13900020 - Invalid argument 5303 * @throws { BusinessError } 13900022 - Too many open files 5304 * @throws { BusinessError } 13900023 - Text file busy 5305 * @throws { BusinessError } 13900024 - File too large 5306 * @throws { BusinessError } 13900025 - No space left on device 5307 * @throws { BusinessError } 13900027 - Read-only file system 5308 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5309 * @throws { BusinessError } 13900030 - File name too long 5310 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5311 * @throws { BusinessError } 13900034 - Operation would block 5312 * @throws { BusinessError } 13900038 - Value too large for defined data type 5313 * @throws { BusinessError } 13900041 - Quota exceeded 5314 * @throws { BusinessError } 13900042 - Unknown error 5315 * @syscap SystemCapability.FileManagement.File.FileIO 5316 * @crossplatform 5317 * @atomicservice 5318 * @since 11 5319 */ 5320declare function open(path: string, mode: number, callback: AsyncCallback<File>): void; 5321 5322/** 5323 * Open file with sync interface. 5324 * 5325 * @param { string } path - path. 5326 * @param { number } [mode = OpenMode.READ_ONLY] - mode. 5327 * @returns { File } Returns the File object to record the file descriptor. 5328 * @throws { BusinessError } 13900001 - Operation not permitted 5329 * @throws { BusinessError } 13900002 - No such file or directory 5330 * @throws { BusinessError } 13900004 - Interrupted system call 5331 * @throws { BusinessError } 13900006 - No such device or address 5332 * @throws { BusinessError } 13900008 - Bad file descriptor 5333 * @throws { BusinessError } 13900011 - Out of memory 5334 * @throws { BusinessError } 13900012 - Permission denied 5335 * @throws { BusinessError } 13900013 - Bad address 5336 * @throws { BusinessError } 13900014 - Device or resource busy 5337 * @throws { BusinessError } 13900015 - File exists 5338 * @throws { BusinessError } 13900017 - No such device 5339 * @throws { BusinessError } 13900018 - Not a directory 5340 * @throws { BusinessError } 13900019 - Is a directory 5341 * @throws { BusinessError } 13900020 - Invalid argument 5342 * @throws { BusinessError } 13900022 - Too many open files 5343 * @throws { BusinessError } 13900023 - Text file busy 5344 * @throws { BusinessError } 13900024 - File too large 5345 * @throws { BusinessError } 13900025 - No space left on device 5346 * @throws { BusinessError } 13900027 - Read-only file system 5347 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5348 * @throws { BusinessError } 13900030 - File name too long 5349 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5350 * @throws { BusinessError } 13900034 - Operation would block 5351 * @throws { BusinessError } 13900038 - Value too large for defined data type 5352 * @throws { BusinessError } 13900041 - Quota exceeded 5353 * @throws { BusinessError } 13900042 - Unknown error 5354 * @syscap SystemCapability.FileManagement.File.FileIO 5355 * @since 9 5356 */ 5357/** 5358 * Open file with sync interface. 5359 * 5360 * @param { string } path - path. 5361 * @param { number } [mode = OpenMode.READ_ONLY] - mode. 5362 * @returns { File } Returns the File object to record the file descriptor. 5363 * @throws { BusinessError } 13900001 - Operation not permitted 5364 * @throws { BusinessError } 13900002 - No such file or directory 5365 * @throws { BusinessError } 13900004 - Interrupted system call 5366 * @throws { BusinessError } 13900006 - No such device or address 5367 * @throws { BusinessError } 13900008 - Bad file descriptor 5368 * @throws { BusinessError } 13900011 - Out of memory 5369 * @throws { BusinessError } 13900012 - Permission denied 5370 * @throws { BusinessError } 13900013 - Bad address 5371 * @throws { BusinessError } 13900014 - Device or resource busy 5372 * @throws { BusinessError } 13900015 - File exists 5373 * @throws { BusinessError } 13900017 - No such device 5374 * @throws { BusinessError } 13900018 - Not a directory 5375 * @throws { BusinessError } 13900019 - Is a directory 5376 * @throws { BusinessError } 13900020 - Invalid argument 5377 * @throws { BusinessError } 13900022 - Too many open files 5378 * @throws { BusinessError } 13900023 - Text file busy 5379 * @throws { BusinessError } 13900024 - File too large 5380 * @throws { BusinessError } 13900025 - No space left on device 5381 * @throws { BusinessError } 13900027 - Read-only file system 5382 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5383 * @throws { BusinessError } 13900030 - File name too long 5384 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5385 * @throws { BusinessError } 13900034 - Operation would block 5386 * @throws { BusinessError } 13900038 - Value too large for defined data type 5387 * @throws { BusinessError } 13900041 - Quota exceeded 5388 * @throws { BusinessError } 13900042 - Unknown error 5389 * @syscap SystemCapability.FileManagement.File.FileIO 5390 * @crossplatform 5391 * @since 10 5392 */ 5393/** 5394 * Open file with sync interface. 5395 * 5396 * @param { string } path - path. 5397 * @param { number } [mode = OpenMode.READ_ONLY] - mode. 5398 * @returns { File } Returns the File object to record the file descriptor. 5399 * @throws { BusinessError } 13900001 - Operation not permitted 5400 * @throws { BusinessError } 13900002 - No such file or directory 5401 * @throws { BusinessError } 13900004 - Interrupted system call 5402 * @throws { BusinessError } 13900006 - No such device or address 5403 * @throws { BusinessError } 13900008 - Bad file descriptor 5404 * @throws { BusinessError } 13900011 - Out of memory 5405 * @throws { BusinessError } 13900012 - Permission denied 5406 * @throws { BusinessError } 13900013 - Bad address 5407 * @throws { BusinessError } 13900014 - Device or resource busy 5408 * @throws { BusinessError } 13900015 - File exists 5409 * @throws { BusinessError } 13900017 - No such device 5410 * @throws { BusinessError } 13900018 - Not a directory 5411 * @throws { BusinessError } 13900019 - Is a directory 5412 * @throws { BusinessError } 13900020 - Invalid argument 5413 * @throws { BusinessError } 13900022 - Too many open files 5414 * @throws { BusinessError } 13900023 - Text file busy 5415 * @throws { BusinessError } 13900024 - File too large 5416 * @throws { BusinessError } 13900025 - No space left on device 5417 * @throws { BusinessError } 13900027 - Read-only file system 5418 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5419 * @throws { BusinessError } 13900030 - File name too long 5420 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5421 * @throws { BusinessError } 13900034 - Operation would block 5422 * @throws { BusinessError } 13900038 - Value too large for defined data type 5423 * @throws { BusinessError } 13900041 - Quota exceeded 5424 * @throws { BusinessError } 13900042 - Unknown error 5425 * @syscap SystemCapability.FileManagement.File.FileIO 5426 * @crossplatform 5427 * @atomicservice 5428 * @since 11 5429 */ 5430/** 5431 * Opens a file or directory. This API returns the result synchronously. This API supports the use of a URI. 5432 * 5433 * @param { string } path - Application sandbox path or file URI of the file to open. 5434 * @param { number } [mode = OpenMode.READ_ONLY] - Mode for opening the file. 5435 * <br>You must specify one of the following options. By default, the file is opened in read-only mode. 5436 * <br>OpenMode.READ_ONLY(0o0): Open the file in read-only mode. 5437 * <br>OpenMode.WRITE_ONLY(0o1): Open the file in write-only mode. 5438 * <br>OpenMode.READ_WRITE(0o2): Open the file in read/write mode. 5439 * <br>You can add the following function options in bitwise OR mode. By default, no additional option is added. 5440 * <br>OpenMode.CREATE(0o100): Create a file if the file does not exist. 5441 * <br>OpenMode.TRUNC(0o1000): If the file exists and is opened in write mode, truncate the file length to 0. 5442 * <br>OpenMode.APPEND(0o2000): Open the file in append mode. New data will be added to the end of the file. 5443 * <br>OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 5444 * <br>or character special file, perform non-blocking operations on the opened file and in subsequent I/Os. 5445 * <br>OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 5446 * <br>OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 5447 * <br>OpenMode.SYNC(0o4010000): Open the file in synchronous I/O mode. 5448 * @returns { File } Returns the File object to record the file descriptor. 5449 * @throws { BusinessError } 13900001 - Operation not permitted 5450 * @throws { BusinessError } 13900002 - No such file or directory 5451 * @throws { BusinessError } 13900004 - Interrupted system call 5452 * @throws { BusinessError } 13900006 - No such device or address 5453 * @throws { BusinessError } 13900008 - Bad file descriptor 5454 * @throws { BusinessError } 13900011 - Out of memory 5455 * @throws { BusinessError } 13900012 - Permission denied 5456 * @throws { BusinessError } 13900013 - Bad address 5457 * @throws { BusinessError } 13900014 - Device or resource busy 5458 * @throws { BusinessError } 13900015 - File exists 5459 * @throws { BusinessError } 13900017 - No such device 5460 * @throws { BusinessError } 13900018 - Not a directory 5461 * @throws { BusinessError } 13900019 - Is a directory 5462 * @throws { BusinessError } 13900020 - Invalid argument 5463 * @throws { BusinessError } 13900022 - Too many open files 5464 * @throws { BusinessError } 13900023 - Text file busy 5465 * @throws { BusinessError } 13900024 - File too large 5466 * @throws { BusinessError } 13900025 - No space left on device 5467 * @throws { BusinessError } 13900027 - Read-only file system 5468 * @throws { BusinessError } 13900029 - Resource deadlock would occur 5469 * @throws { BusinessError } 13900030 - File name too long 5470 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5471 * @throws { BusinessError } 13900034 - Operation would block 5472 * @throws { BusinessError } 13900038 - Value too large for defined data type 5473 * @throws { BusinessError } 13900041 - Quota exceeded 5474 * @throws { BusinessError } 13900042 - Unknown error 5475 * @throws { BusinessError } 13900044 - Network is unreachable 5476 * @syscap SystemCapability.FileManagement.File.FileIO 5477 * @crossplatform 5478 * @atomicservice 5479 * @since 12 5480 */ 5481declare function openSync(path: string, mode?: number): File; 5482 5483/** 5484 * Read file. 5485 * 5486 * @param { number } fd - file descriptor. 5487 * @param { ArrayBuffer } buffer - buffer. 5488 * @param { object } [options] - options. 5489 * @returns { Promise<number> } Returns the number of file bytes read to buffer in promise mode. 5490 * @throws { BusinessError } 13900004 - Interrupted system call 5491 * @throws { BusinessError } 13900005 - I/O error 5492 * @throws { BusinessError } 13900008 - Bad file descriptor 5493 * @throws { BusinessError } 13900010 - Try again 5494 * @throws { BusinessError } 13900013 - Bad address 5495 * @throws { BusinessError } 13900019 - Is a directory 5496 * @throws { BusinessError } 13900020 - Invalid argument 5497 * @throws { BusinessError } 13900034 - Operation would block 5498 * @throws { BusinessError } 13900042 - Unknown error 5499 * @syscap SystemCapability.FileManagement.File.FileIO 5500 * @since 9 5501 */ 5502/** 5503 * Read file. 5504 * 5505 * @param { number } fd - file descriptor. 5506 * @param { ArrayBuffer } buffer - buffer. 5507 * @param { object } [options] - options. 5508 * @returns { Promise<number> } Returns the number of file bytes read to buffer in promise mode. 5509 * @throws { BusinessError } 13900004 - Interrupted system call 5510 * @throws { BusinessError } 13900005 - I/O error 5511 * @throws { BusinessError } 13900008 - Bad file descriptor 5512 * @throws { BusinessError } 13900010 - Try again 5513 * @throws { BusinessError } 13900013 - Bad address 5514 * @throws { BusinessError } 13900019 - Is a directory 5515 * @throws { BusinessError } 13900020 - Invalid argument 5516 * @throws { BusinessError } 13900034 - Operation would block 5517 * @throws { BusinessError } 13900042 - Unknown error 5518 * @syscap SystemCapability.FileManagement.File.FileIO 5519 * @crossplatform 5520 * @since 10 5521 */ 5522/** 5523 * Read file. 5524 * 5525 * @param { number } fd - file descriptor. 5526 * @param { ArrayBuffer } buffer - buffer. 5527 * @param { ReadOptions } [options] - options. 5528 * @returns { Promise<number> } Returns the number of file bytes read to buffer in promise mode. 5529 * @throws { BusinessError } 13900004 - Interrupted system call 5530 * @throws { BusinessError } 13900005 - I/O error 5531 * @throws { BusinessError } 13900008 - Bad file descriptor 5532 * @throws { BusinessError } 13900010 - Try again 5533 * @throws { BusinessError } 13900013 - Bad address 5534 * @throws { BusinessError } 13900019 - Is a directory 5535 * @throws { BusinessError } 13900020 - Invalid argument 5536 * @throws { BusinessError } 13900034 - Operation would block 5537 * @throws { BusinessError } 13900042 - Unknown error 5538 * @syscap SystemCapability.FileManagement.File.FileIO 5539 * @crossplatform 5540 * @atomicservice 5541 * @since 11 5542 */ 5543/** 5544 * Reads file data. This API uses a promise to return the result. 5545 * 5546 * @param { number } fd - FD of the file. 5547 * @param { ArrayBuffer } buffer - Buffer used to store the file data read. 5548 * @param { ReadOptions } [options] - The options are as follows: 5549 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 5550 * <br>offset (number): start position to read the data (it is determined by filePointer plus offset). 5551 * <br>This parameter is optional. By default, data is read from the filePointer. 5552 * @returns { Promise<number> } Promise used to return the length of the data read, in bytes. 5553 * @throws { BusinessError } 13900004 - Interrupted system call 5554 * @throws { BusinessError } 13900005 - I/O error 5555 * @throws { BusinessError } 13900008 - Bad file descriptor 5556 * @throws { BusinessError } 13900010 - Try again 5557 * @throws { BusinessError } 13900013 - Bad address 5558 * @throws { BusinessError } 13900019 - Is a directory 5559 * @throws { BusinessError } 13900020 - Invalid argument 5560 * @throws { BusinessError } 13900034 - Operation would block 5561 * @throws { BusinessError } 13900042 - Unknown error 5562 * @throws { BusinessError } 13900044 - Network is unreachable 5563 * @syscap SystemCapability.FileManagement.File.FileIO 5564 * @crossplatform 5565 * @atomicservice 5566 * @since 12 5567 */ 5568declare function read( 5569 fd: number, 5570 buffer: ArrayBuffer, 5571 options?: ReadOptions 5572): Promise<number>; 5573 5574/** 5575 * Read file. 5576 * 5577 * @param { number } fd - file descriptor. 5578 * @param { ArrayBuffer } buffer - buffer. 5579 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer. 5580 * @throws { BusinessError } 13900004 - Interrupted system call 5581 * @throws { BusinessError } 13900005 - I/O error 5582 * @throws { BusinessError } 13900008 - Bad file descriptor 5583 * @throws { BusinessError } 13900010 - Try again 5584 * @throws { BusinessError } 13900013 - Bad address 5585 * @throws { BusinessError } 13900019 - Is a directory 5586 * @throws { BusinessError } 13900020 - Invalid argument 5587 * @throws { BusinessError } 13900034 - Operation would block 5588 * @throws { BusinessError } 13900042 - Unknown error 5589 * @syscap SystemCapability.FileManagement.File.FileIO 5590 * @since 9 5591 */ 5592/** 5593 * Read file. 5594 * 5595 * @param { number } fd - file descriptor. 5596 * @param { ArrayBuffer } buffer - buffer. 5597 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer. 5598 * @throws { BusinessError } 13900004 - Interrupted system call 5599 * @throws { BusinessError } 13900005 - I/O error 5600 * @throws { BusinessError } 13900008 - Bad file descriptor 5601 * @throws { BusinessError } 13900010 - Try again 5602 * @throws { BusinessError } 13900013 - Bad address 5603 * @throws { BusinessError } 13900019 - Is a directory 5604 * @throws { BusinessError } 13900020 - Invalid argument 5605 * @throws { BusinessError } 13900034 - Operation would block 5606 * @throws { BusinessError } 13900042 - Unknown error 5607 * @syscap SystemCapability.FileManagement.File.FileIO 5608 * @crossplatform 5609 * @since 10 5610 */ 5611/** 5612 * Reads data from a file. This API uses an asynchronous callback to return the result. 5613 * 5614 * @param { number } fd - FD of the file. 5615 * @param { ArrayBuffer } buffer - Buffer used to store the file data read. 5616 * @param { AsyncCallback<number> } callback - Callback used to return the length of the data read, in bytes. 5617 * @throws { BusinessError } 13900004 - Interrupted system call 5618 * @throws { BusinessError } 13900005 - I/O error 5619 * @throws { BusinessError } 13900008 - Bad file descriptor 5620 * @throws { BusinessError } 13900010 - Try again 5621 * @throws { BusinessError } 13900013 - Bad address 5622 * @throws { BusinessError } 13900019 - Is a directory 5623 * @throws { BusinessError } 13900020 - Invalid argument 5624 * @throws { BusinessError } 13900034 - Operation would block 5625 * @throws { BusinessError } 13900042 - Unknown error 5626 * @syscap SystemCapability.FileManagement.File.FileIO 5627 * @crossplatform 5628 * @atomicservice 5629 * @since 11 5630 */ 5631declare function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback<number>): void; 5632 5633/** 5634 * Read file. 5635 * 5636 * @param { number } fd - file descriptor. 5637 * @param { ArrayBuffer } buffer - buffer. 5638 * @param { object } [options] - options. 5639 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer. 5640 * @throws { BusinessError } 13900004 - Interrupted system call 5641 * @throws { BusinessError } 13900005 - I/O error 5642 * @throws { BusinessError } 13900008 - Bad file descriptor 5643 * @throws { BusinessError } 13900010 - Try again 5644 * @throws { BusinessError } 13900013 - Bad address 5645 * @throws { BusinessError } 13900019 - Is a directory 5646 * @throws { BusinessError } 13900020 - Invalid argument 5647 * @throws { BusinessError } 13900034 - Operation would block 5648 * @throws { BusinessError } 13900042 - Unknown error 5649 * @syscap SystemCapability.FileManagement.File.FileIO 5650 * @since 9 5651 */ 5652/** 5653 * Read file. 5654 * 5655 * @param { number } fd - file descriptor. 5656 * @param { ArrayBuffer } buffer - buffer. 5657 * @param { object } [options] - options. 5658 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer. 5659 * @throws { BusinessError } 13900004 - Interrupted system call 5660 * @throws { BusinessError } 13900005 - I/O error 5661 * @throws { BusinessError } 13900008 - Bad file descriptor 5662 * @throws { BusinessError } 13900010 - Try again 5663 * @throws { BusinessError } 13900013 - Bad address 5664 * @throws { BusinessError } 13900019 - Is a directory 5665 * @throws { BusinessError } 13900020 - Invalid argument 5666 * @throws { BusinessError } 13900034 - Operation would block 5667 * @throws { BusinessError } 13900042 - Unknown error 5668 * @syscap SystemCapability.FileManagement.File.FileIO 5669 * @crossplatform 5670 * @since 10 5671 */ 5672/** 5673 * Reads data from a file. This API uses an asynchronous callback to return the result. 5674 * 5675 * @param { number } fd - FD of the file. 5676 * @param { ArrayBuffer } buffer - Buffer used to store the file data read. 5677 * @param { ReadOptions } [options] - The options are as follows: 5678 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 5679 * <br>offset (number): start position to read the data (it is determined by filePointer plus offset). 5680 * <br>This parameter is optional. By default, data is read from the filePointer. 5681 * @param { AsyncCallback<number> } callback - Callback used to return the length of the data read, in bytes. 5682 * @throws { BusinessError } 13900004 - Interrupted system call 5683 * @throws { BusinessError } 13900005 - I/O error 5684 * @throws { BusinessError } 13900008 - Bad file descriptor 5685 * @throws { BusinessError } 13900010 - Try again 5686 * @throws { BusinessError } 13900013 - Bad address 5687 * @throws { BusinessError } 13900019 - Is a directory 5688 * @throws { BusinessError } 13900020 - Invalid argument 5689 * @throws { BusinessError } 13900034 - Operation would block 5690 * @throws { BusinessError } 13900042 - Unknown error 5691 * @syscap SystemCapability.FileManagement.File.FileIO 5692 * @crossplatform 5693 * @atomicservice 5694 * @since 11 5695 */ 5696declare function read( 5697 fd: number, 5698 buffer: ArrayBuffer, 5699 options: ReadOptions, 5700 callback: AsyncCallback<number> 5701): void; 5702 5703/** 5704 * Read file with sync interface. 5705 * 5706 * @param { number } fd - file descriptor. 5707 * @param { ArrayBuffer } buffer - buffer. 5708 * @param { object } [options] - options. 5709 * @returns { number } Returns the number of file bytes read to buffer. 5710 * @throws { BusinessError } 13900004 - Interrupted system call 5711 * @throws { BusinessError } 13900005 - I/O error 5712 * @throws { BusinessError } 13900008 - Bad file descriptor 5713 * @throws { BusinessError } 13900010 - Try again 5714 * @throws { BusinessError } 13900013 - Bad address 5715 * @throws { BusinessError } 13900019 - Is a directory 5716 * @throws { BusinessError } 13900020 - Invalid argument 5717 * @throws { BusinessError } 13900034 - Operation would block 5718 * @throws { BusinessError } 13900042 - Unknown error 5719 * @syscap SystemCapability.FileManagement.File.FileIO 5720 * @since 9 5721 */ 5722/** 5723 * Read file with sync interface. 5724 * 5725 * @param { number } fd - file descriptor. 5726 * @param { ArrayBuffer } buffer - buffer. 5727 * @param { object } [options] - options. 5728 * @returns { number } Returns the number of file bytes read to buffer. 5729 * @throws { BusinessError } 13900004 - Interrupted system call 5730 * @throws { BusinessError } 13900005 - I/O error 5731 * @throws { BusinessError } 13900008 - Bad file descriptor 5732 * @throws { BusinessError } 13900010 - Try again 5733 * @throws { BusinessError } 13900013 - Bad address 5734 * @throws { BusinessError } 13900019 - Is a directory 5735 * @throws { BusinessError } 13900020 - Invalid argument 5736 * @throws { BusinessError } 13900034 - Operation would block 5737 * @throws { BusinessError } 13900042 - Unknown error 5738 * @syscap SystemCapability.FileManagement.File.FileIO 5739 * @crossplatform 5740 * @since 10 5741 */ 5742/** 5743 * Read file with sync interface. 5744 * 5745 * @param { number } fd - file descriptor. 5746 * @param { ArrayBuffer } buffer - buffer. 5747 * @param { ReadOptions } [options] - options. 5748 * @returns { number } Returns the number of file bytes read to buffer. 5749 * @throws { BusinessError } 13900004 - Interrupted system call 5750 * @throws { BusinessError } 13900005 - I/O error 5751 * @throws { BusinessError } 13900008 - Bad file descriptor 5752 * @throws { BusinessError } 13900010 - Try again 5753 * @throws { BusinessError } 13900013 - Bad address 5754 * @throws { BusinessError } 13900019 - Is a directory 5755 * @throws { BusinessError } 13900020 - Invalid argument 5756 * @throws { BusinessError } 13900034 - Operation would block 5757 * @throws { BusinessError } 13900042 - Unknown error 5758 * @syscap SystemCapability.FileManagement.File.FileIO 5759 * @crossplatform 5760 * @atomicservice 5761 * @since 11 5762 */ 5763/** 5764 * Reads data from a file. This API returns the result synchronously. 5765 * 5766 * @param { number } fd - FD of the file. 5767 * @param { ArrayBuffer } buffer - Buffer used to store the file data read. 5768 * @param { ReadOptions } [options] - The options are as follows: 5769 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 5770 * <br>offset (number): start position to read the data (it is determined by filePointer plus offset). 5771 * <br>This parameter is optional. By default, data is read from the filePointer. 5772 * @returns { number } Length of the data read, in bytes. 5773 * @throws { BusinessError } 13900004 - Interrupted system call 5774 * @throws { BusinessError } 13900005 - I/O error 5775 * @throws { BusinessError } 13900008 - Bad file descriptor 5776 * @throws { BusinessError } 13900010 - Try again 5777 * @throws { BusinessError } 13900013 - Bad address 5778 * @throws { BusinessError } 13900019 - Is a directory 5779 * @throws { BusinessError } 13900020 - Invalid argument 5780 * @throws { BusinessError } 13900034 - Operation would block 5781 * @throws { BusinessError } 13900042 - Unknown error 5782 * @throws { BusinessError } 13900044 - Network is unreachable 5783 * @syscap SystemCapability.FileManagement.File.FileIO 5784 * @crossplatform 5785 * @atomicservice 5786 * @since 12 5787 */ 5788declare function readSync( 5789 fd: number, 5790 buffer: ArrayBuffer, 5791 options?: ReadOptions 5792): number; 5793 5794/** 5795 * Read content line by line. 5796 * 5797 * @param { string } filePath - file path. 5798 * @param { Options } [options] - optional parameters 5799 * @returns { Promise<ReaderIterator> } Returns the iterator object in promise mode. 5800 * @throws { BusinessError } 13900002 - No such file or directory 5801 * @throws { BusinessError } 13900012 - Permission denied 5802 * @throws { BusinessError } 13900015 - File exists 5803 * @throws { BusinessError } 13900019 - Is a directory 5804 * @throws { BusinessError } 13900020 - Invalid argument 5805 * @throws { BusinessError } 13900022 - Too many open files 5806 * @throws { BusinessError } 13900025 - No space left on device 5807 * @throws { BusinessError } 13900027 - Read-only file system 5808 * @throws { BusinessError } 13900030 - File name too long 5809 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5810 * @throws { BusinessError } 13900041 - Quota exceeded 5811 * @throws { BusinessError } 13900042 - Unknown error 5812 * @syscap SystemCapability.FileManagement.File.FileIO 5813 * @since 11 5814 */ 5815/** 5816 * Reads the text content of a file line by line. This API uses a promise to return the result. 5817 * Only the files in UTF-8 format are supported. 5818 * 5819 * @param { string } filePath - Application sandbox path of the file. 5820 * @param { Options } [options] - Options for reading the text. The options are as follows: 5821 * <br>encoding (string): format of the data to be encoded. It is valid only when the data is of the string type. 5822 * <br>The default value is 'utf-8', which is the only value supported. 5823 * @returns { Promise<ReaderIterator> } Promise used to return a ReaderIterator object. 5824 * @throws { BusinessError } 13900002 - No such file or directory 5825 * @throws { BusinessError } 13900012 - Permission denied 5826 * @throws { BusinessError } 13900015 - File exists 5827 * @throws { BusinessError } 13900019 - Is a directory 5828 * @throws { BusinessError } 13900020 - Invalid argument 5829 * @throws { BusinessError } 13900022 - Too many open files 5830 * @throws { BusinessError } 13900025 - No space left on device 5831 * @throws { BusinessError } 13900027 - Read-only file system 5832 * @throws { BusinessError } 13900030 - File name too long 5833 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5834 * @throws { BusinessError } 13900041 - Quota exceeded 5835 * @throws { BusinessError } 13900042 - Unknown error 5836 * @throws { BusinessError } 13900044 - Network is unreachable 5837 * @syscap SystemCapability.FileManagement.File.FileIO 5838 * @since 12 5839 */ 5840/** 5841 * Reads the text content of a file line by line. This API uses a promise to return the result. 5842 * Only the files in UTF-8 format are supported. 5843 * 5844 * @param { string } filePath - Application sandbox path of the file. 5845 * @param { Options } [options] - Options for reading the text. The options are as follows: 5846 * <br>encoding (string): format of the data to be encoded. It is valid only when the data is of the string type. 5847 * <br>The default value is 'utf-8', which is the only value supported. 5848 * @returns { Promise<ReaderIterator> } Promise used to return a ReaderIterator object. 5849 * @throws { BusinessError } 13900002 - No such file or directory 5850 * @throws { BusinessError } 13900012 - Permission denied 5851 * @throws { BusinessError } 13900015 - File exists 5852 * @throws { BusinessError } 13900019 - Is a directory 5853 * @throws { BusinessError } 13900020 - Invalid argument 5854 * @throws { BusinessError } 13900022 - Too many open files 5855 * @throws { BusinessError } 13900025 - No space left on device 5856 * @throws { BusinessError } 13900027 - Read-only file system 5857 * @throws { BusinessError } 13900030 - File name too long 5858 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5859 * @throws { BusinessError } 13900041 - Quota exceeded 5860 * @throws { BusinessError } 13900042 - Unknown error 5861 * @throws { BusinessError } 13900044 - Network is unreachable 5862 * @syscap SystemCapability.FileManagement.File.FileIO 5863 * @crossplatform 5864 * @since 20 5865 */ 5866declare function readLines(filePath: string, options?: Options): Promise<ReaderIterator>; 5867 5868/** 5869 * Reads a file text line by line. This API uses an asynchronous callback to return the result. 5870 * Only the files in UTF-8 format are supported. 5871 * 5872 * @param { string } filePath - Application sandbox path of the file. 5873 * @param { AsyncCallback<ReaderIterator> } callback - Callback used to return a ReaderIterator object. 5874 * @throws { BusinessError } 13900002 - No such file or directory 5875 * @throws { BusinessError } 13900012 - Permission denied 5876 * @throws { BusinessError } 13900015 - File exists 5877 * @throws { BusinessError } 13900019 - Is a directory 5878 * @throws { BusinessError } 13900020 - Invalid argument 5879 * @throws { BusinessError } 13900022 - Too many open files 5880 * @throws { BusinessError } 13900025 - No space left on device 5881 * @throws { BusinessError } 13900027 - Read-only file system 5882 * @throws { BusinessError } 13900030 - File name too long 5883 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5884 * @throws { BusinessError } 13900041 - Quota exceeded 5885 * @throws { BusinessError } 13900042 - Unknown error 5886 * @syscap SystemCapability.FileManagement.File.FileIO 5887 * @since 11 5888 */ 5889/** 5890 * Reads a file text line by line. This API uses an asynchronous callback to return the result. 5891 * Only the files in UTF-8 format are supported. 5892 * 5893 * @param { string } filePath - Application sandbox path of the file. 5894 * @param { AsyncCallback<ReaderIterator> } callback - Callback used to return a ReaderIterator object. 5895 * @throws { BusinessError } 13900002 - No such file or directory 5896 * @throws { BusinessError } 13900012 - Permission denied 5897 * @throws { BusinessError } 13900015 - File exists 5898 * @throws { BusinessError } 13900019 - Is a directory 5899 * @throws { BusinessError } 13900020 - Invalid argument 5900 * @throws { BusinessError } 13900022 - Too many open files 5901 * @throws { BusinessError } 13900025 - No space left on device 5902 * @throws { BusinessError } 13900027 - Read-only file system 5903 * @throws { BusinessError } 13900030 - File name too long 5904 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5905 * @throws { BusinessError } 13900041 - Quota exceeded 5906 * @throws { BusinessError } 13900042 - Unknown error 5907 * @syscap SystemCapability.FileManagement.File.FileIO 5908 * @crossplatform 5909 * @since 20 5910 */ 5911declare function readLines(filePath: string, callback: AsyncCallback<ReaderIterator>): void; 5912 5913/** 5914 * Reads a file text line by line. This API uses an asynchronous callback to return the result. 5915 * Only the files in UTF-8 format are supported. 5916 * 5917 * @param { string } filePath - Application sandbox path of the file. 5918 * @param { Options } options - Options for reading the text. The options are as follows: 5919 * <br>encoding (string): format of the data to be encoded. It is valid only when the data is of the string type. 5920 * <br>The default value is 'utf-8', which is the only value supported. 5921 * @param { AsyncCallback<ReaderIterator> } callback - Callback used to return a ReaderIterator object. 5922 * @throws { BusinessError } 13900002 - No such file or directory 5923 * @throws { BusinessError } 13900012 - Permission denied 5924 * @throws { BusinessError } 13900015 - File exists 5925 * @throws { BusinessError } 13900019 - Is a directory 5926 * @throws { BusinessError } 13900020 - Invalid argument 5927 * @throws { BusinessError } 13900022 - Too many open files 5928 * @throws { BusinessError } 13900025 - No space left on device 5929 * @throws { BusinessError } 13900027 - Read-only file system 5930 * @throws { BusinessError } 13900030 - File name too long 5931 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5932 * @throws { BusinessError } 13900041 - Quota exceeded 5933 * @throws { BusinessError } 13900042 - Unknown error 5934 * @syscap SystemCapability.FileManagement.File.FileIO 5935 * @since 11 5936 */ 5937/** 5938 * Reads a file text line by line. This API uses an asynchronous callback to return the result. 5939 * Only the files in UTF-8 format are supported. 5940 * 5941 * @param { string } filePath - Application sandbox path of the file. 5942 * @param { Options } options - Options for reading the text. The options are as follows: 5943 * <br>encoding (string): format of the data to be encoded. It is valid only when the data is of the string type. 5944 * <br>The default value is 'utf-8', which is the only value supported. 5945 * @param { AsyncCallback<ReaderIterator> } callback - Callback used to return a ReaderIterator object. 5946 * @throws { BusinessError } 13900002 - No such file or directory 5947 * @throws { BusinessError } 13900012 - Permission denied 5948 * @throws { BusinessError } 13900015 - File exists 5949 * @throws { BusinessError } 13900019 - Is a directory 5950 * @throws { BusinessError } 13900020 - Invalid argument 5951 * @throws { BusinessError } 13900022 - Too many open files 5952 * @throws { BusinessError } 13900025 - No space left on device 5953 * @throws { BusinessError } 13900027 - Read-only file system 5954 * @throws { BusinessError } 13900030 - File name too long 5955 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5956 * @throws { BusinessError } 13900041 - Quota exceeded 5957 * @throws { BusinessError } 13900042 - Unknown error 5958 * @syscap SystemCapability.FileManagement.File.FileIO 5959 * @crossplatform 5960 * @since 20 5961 */ 5962declare function readLines(filePath: string, options: Options, callback: AsyncCallback<ReaderIterator>): void; 5963 5964/** 5965 * Read content line by line with sync interface. 5966 * 5967 * @param { string } filePath - file path. 5968 * @param { Options } [options] - optional parameters 5969 * @returns { ReaderIterator } Returns the iterator object. 5970 * @throws { BusinessError } 13900002 - No such file or directory 5971 * @throws { BusinessError } 13900012 - Permission denied 5972 * @throws { BusinessError } 13900015 - File exists 5973 * @throws { BusinessError } 13900019 - Is a directory 5974 * @throws { BusinessError } 13900020 - Invalid argument 5975 * @throws { BusinessError } 13900022 - Too many open files 5976 * @throws { BusinessError } 13900025 - No space left on device 5977 * @throws { BusinessError } 13900027 - Read-only file system 5978 * @throws { BusinessError } 13900030 - File name too long 5979 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 5980 * @throws { BusinessError } 13900041 - Quota exceeded 5981 * @throws { BusinessError } 13900042 - Unknown error 5982 * @syscap SystemCapability.FileManagement.File.FileIO 5983 * @since 11 5984 */ 5985/** 5986 * Reads the text content of a file line by line. This API returns the result synchronously. 5987 * 5988 * @param { string } filePath - Application sandbox path of the file. 5989 * @param { Options } [options] - Options for reading the text. The options are as follows: 5990 * <br>encoding (string): format of the data to be encoded. It is valid only when the data is of the string type. 5991 * <br>The default value is 'utf-8', which is the only value supported. 5992 * @returns { ReaderIterator } Returns the iterator object. 5993 * @throws { BusinessError } 13900002 - No such file or directory 5994 * @throws { BusinessError } 13900012 - Permission denied 5995 * @throws { BusinessError } 13900015 - File exists 5996 * @throws { BusinessError } 13900019 - Is a directory 5997 * @throws { BusinessError } 13900020 - Invalid argument 5998 * @throws { BusinessError } 13900022 - Too many open files 5999 * @throws { BusinessError } 13900025 - No space left on device 6000 * @throws { BusinessError } 13900027 - Read-only file system 6001 * @throws { BusinessError } 13900030 - File name too long 6002 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6003 * @throws { BusinessError } 13900041 - Quota exceeded 6004 * @throws { BusinessError } 13900042 - Unknown error 6005 * @throws { BusinessError } 13900044 - Network is unreachable 6006 * @syscap SystemCapability.FileManagement.File.FileIO 6007 * @since 12 6008 */ 6009/** 6010 * Reads the text content of a file line by line. This API returns the result synchronously. 6011 * 6012 * @param { string } filePath - Application sandbox path of the file. 6013 * @param { Options } [options] - Options for reading the text. The options are as follows: 6014 * <br>encoding (string): format of the data to be encoded. It is valid only when the data is of the string type. 6015 * <br>The default value is 'utf-8', which is the only value supported. 6016 * @returns { ReaderIterator } Returns the iterator object. 6017 * @throws { BusinessError } 13900002 - No such file or directory 6018 * @throws { BusinessError } 13900012 - Permission denied 6019 * @throws { BusinessError } 13900015 - File exists 6020 * @throws { BusinessError } 13900019 - Is a directory 6021 * @throws { BusinessError } 13900020 - Invalid argument 6022 * @throws { BusinessError } 13900022 - Too many open files 6023 * @throws { BusinessError } 13900025 - No space left on device 6024 * @throws { BusinessError } 13900027 - Read-only file system 6025 * @throws { BusinessError } 13900030 - File name too long 6026 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6027 * @throws { BusinessError } 13900041 - Quota exceeded 6028 * @throws { BusinessError } 13900042 - Unknown error 6029 * @throws { BusinessError } 13900044 - Network is unreachable 6030 * @syscap SystemCapability.FileManagement.File.FileIO 6031 * @crossplatform 6032 * @since 20 6033 */ 6034declare function readLinesSync(filePath: string, options?: Options): ReaderIterator; 6035 6036/** 6037 * Read text. 6038 * 6039 * @param { string } filePath - file path. 6040 * @param { object } [options] - options. 6041 * @returns { Promise<string> } Returns the contents of the read file in promise mode. 6042 * @throws { BusinessError } 13900001 - Operation not permitted 6043 * @throws { BusinessError } 13900004 - Interrupted system call 6044 * @throws { BusinessError } 13900005 - I/O error 6045 * @throws { BusinessError } 13900008 - Bad file descriptor 6046 * @throws { BusinessError } 13900010 - Try again 6047 * @throws { BusinessError } 13900013 - Bad address 6048 * @throws { BusinessError } 13900019 - Is a directory 6049 * @throws { BusinessError } 13900020 - Invalid argument 6050 * @throws { BusinessError } 13900024 - File too large 6051 * @throws { BusinessError } 13900025 - No space left on device 6052 * @throws { BusinessError } 13900034 - Operation would block 6053 * @throws { BusinessError } 13900041 - Quota exceeded 6054 * @throws { BusinessError } 13900042 - Unknown error 6055 * @syscap SystemCapability.FileManagement.File.FileIO 6056 * @since 9 6057 */ 6058/** 6059 * Read text. 6060 * 6061 * @param { string } filePath - file path. 6062 * @param { object } [options] - options. 6063 * @returns { Promise<string> } Returns the contents of the read file in promise mode. 6064 * @throws { BusinessError } 13900001 - Operation not permitted 6065 * @throws { BusinessError } 13900004 - Interrupted system call 6066 * @throws { BusinessError } 13900005 - I/O error 6067 * @throws { BusinessError } 13900008 - Bad file descriptor 6068 * @throws { BusinessError } 13900010 - Try again 6069 * @throws { BusinessError } 13900013 - Bad address 6070 * @throws { BusinessError } 13900019 - Is a directory 6071 * @throws { BusinessError } 13900020 - Invalid argument 6072 * @throws { BusinessError } 13900024 - File too large 6073 * @throws { BusinessError } 13900025 - No space left on device 6074 * @throws { BusinessError } 13900034 - Operation would block 6075 * @throws { BusinessError } 13900041 - Quota exceeded 6076 * @throws { BusinessError } 13900042 - Unknown error 6077 * @syscap SystemCapability.FileManagement.File.FileIO 6078 * @crossplatform 6079 * @since 10 6080 */ 6081/** 6082 * Read text. 6083 * 6084 * @param { string } filePath - file path. 6085 * @param { ReadTextOptions } [options] - options. 6086 * @returns { Promise<string> } Returns the contents of the read file in promise mode. 6087 * @throws { BusinessError } 13900001 - Operation not permitted 6088 * @throws { BusinessError } 13900004 - Interrupted system call 6089 * @throws { BusinessError } 13900005 - I/O error 6090 * @throws { BusinessError } 13900008 - Bad file descriptor 6091 * @throws { BusinessError } 13900010 - Try again 6092 * @throws { BusinessError } 13900013 - Bad address 6093 * @throws { BusinessError } 13900019 - Is a directory 6094 * @throws { BusinessError } 13900020 - Invalid argument 6095 * @throws { BusinessError } 13900024 - File too large 6096 * @throws { BusinessError } 13900025 - No space left on device 6097 * @throws { BusinessError } 13900034 - Operation would block 6098 * @throws { BusinessError } 13900041 - Quota exceeded 6099 * @throws { BusinessError } 13900042 - Unknown error 6100 * @syscap SystemCapability.FileManagement.File.FileIO 6101 * @crossplatform 6102 * @atomicservice 6103 * @since 11 6104 */ 6105/** 6106 * Reads the text content of a file. This API uses a promise to return the result. 6107 * 6108 * @param { string } filePath - Application sandbox path of the file. 6109 * @param { ReadTextOptions } [options] - The options are as follows: 6110 * <br>offset (number): start position to read the data. This parameter is optional. By default, data is read from the current position. 6111 * <br>length (number): length of the data to read. This parameter is optional. The default value is the file length. 6112 * <br>encoding (string): format of the data to be encoded. It is valid only when the data is of the string type. 6113 * <br>The default value is 'utf-8', which is the only value supported. 6114 * @returns { Promise<string> } Promise used to return the file content read. 6115 * @throws { BusinessError } 13900001 - Operation not permitted 6116 * @throws { BusinessError } 13900004 - Interrupted system call 6117 * @throws { BusinessError } 13900005 - I/O error 6118 * @throws { BusinessError } 13900008 - Bad file descriptor 6119 * @throws { BusinessError } 13900010 - Try again 6120 * @throws { BusinessError } 13900013 - Bad address 6121 * @throws { BusinessError } 13900019 - Is a directory 6122 * @throws { BusinessError } 13900020 - Invalid argument 6123 * @throws { BusinessError } 13900024 - File too large 6124 * @throws { BusinessError } 13900025 - No space left on device 6125 * @throws { BusinessError } 13900034 - Operation would block 6126 * @throws { BusinessError } 13900041 - Quota exceeded 6127 * @throws { BusinessError } 13900042 - Unknown error 6128 * @throws { BusinessError } 13900044 - Network is unreachable 6129 * @syscap SystemCapability.FileManagement.File.FileIO 6130 * @crossplatform 6131 * @atomicservice 6132 * @since 12 6133 */ 6134declare function readText( 6135 filePath: string, 6136 options?: ReadTextOptions 6137): Promise<string>; 6138 6139/** 6140 * Read text. 6141 * 6142 * @param { string } filePath - file path. 6143 * @param { AsyncCallback<string> } callback - The callback is used to return the contents of the read file. 6144 * @throws { BusinessError } 13900001 - Operation not permitted 6145 * @throws { BusinessError } 13900004 - Interrupted system call 6146 * @throws { BusinessError } 13900005 - I/O error 6147 * @throws { BusinessError } 13900008 - Bad file descriptor 6148 * @throws { BusinessError } 13900010 - Try again 6149 * @throws { BusinessError } 13900013 - Bad address 6150 * @throws { BusinessError } 13900019 - Is a directory 6151 * @throws { BusinessError } 13900020 - Invalid argument 6152 * @throws { BusinessError } 13900024 - File too large 6153 * @throws { BusinessError } 13900025 - No space left on device 6154 * @throws { BusinessError } 13900034 - Operation would block 6155 * @throws { BusinessError } 13900041 - Quota exceeded 6156 * @throws { BusinessError } 13900042 - Unknown error 6157 * @syscap SystemCapability.FileManagement.File.FileIO 6158 * @since 9 6159 */ 6160/** 6161 * Read text. 6162 * 6163 * @param { string } filePath - file path. 6164 * @param { AsyncCallback<string> } callback - The callback is used to return the contents of the read file. 6165 * @throws { BusinessError } 13900001 - Operation not permitted 6166 * @throws { BusinessError } 13900004 - Interrupted system call 6167 * @throws { BusinessError } 13900005 - I/O error 6168 * @throws { BusinessError } 13900008 - Bad file descriptor 6169 * @throws { BusinessError } 13900010 - Try again 6170 * @throws { BusinessError } 13900013 - Bad address 6171 * @throws { BusinessError } 13900019 - Is a directory 6172 * @throws { BusinessError } 13900020 - Invalid argument 6173 * @throws { BusinessError } 13900024 - File too large 6174 * @throws { BusinessError } 13900025 - No space left on device 6175 * @throws { BusinessError } 13900034 - Operation would block 6176 * @throws { BusinessError } 13900041 - Quota exceeded 6177 * @throws { BusinessError } 13900042 - Unknown error 6178 * @syscap SystemCapability.FileManagement.File.FileIO 6179 * @crossplatform 6180 * @since 10 6181 */ 6182/** 6183 * Reads the text content of a file. This API uses an asynchronous callback to return the result. 6184 * 6185 * @param { string } filePath - Application sandbox path of the file. 6186 * @param { AsyncCallback<string> } callback - Callback used to return the content read. 6187 * @throws { BusinessError } 13900001 - Operation not permitted 6188 * @throws { BusinessError } 13900004 - Interrupted system call 6189 * @throws { BusinessError } 13900005 - I/O error 6190 * @throws { BusinessError } 13900008 - Bad file descriptor 6191 * @throws { BusinessError } 13900010 - Try again 6192 * @throws { BusinessError } 13900013 - Bad address 6193 * @throws { BusinessError } 13900019 - Is a directory 6194 * @throws { BusinessError } 13900020 - Invalid argument 6195 * @throws { BusinessError } 13900024 - File too large 6196 * @throws { BusinessError } 13900025 - No space left on device 6197 * @throws { BusinessError } 13900034 - Operation would block 6198 * @throws { BusinessError } 13900041 - Quota exceeded 6199 * @throws { BusinessError } 13900042 - Unknown error 6200 * @syscap SystemCapability.FileManagement.File.FileIO 6201 * @crossplatform 6202 * @atomicservice 6203 * @since 11 6204 */ 6205declare function readText(filePath: string, callback: AsyncCallback<string>): void; 6206 6207/** 6208 * Read text. 6209 * 6210 * @param { string } filePath - file path. 6211 * @param { object } [options] - options. 6212 * @param { AsyncCallback<string> } callback - The callback is used to return the contents of the read file. 6213 * @throws { BusinessError } 13900001 - Operation not permitted 6214 * @throws { BusinessError } 13900004 - Interrupted system call 6215 * @throws { BusinessError } 13900005 - I/O error 6216 * @throws { BusinessError } 13900008 - Bad file descriptor 6217 * @throws { BusinessError } 13900010 - Try again 6218 * @throws { BusinessError } 13900013 - Bad address 6219 * @throws { BusinessError } 13900019 - Is a directory 6220 * @throws { BusinessError } 13900020 - Invalid argument 6221 * @throws { BusinessError } 13900024 - File too large 6222 * @throws { BusinessError } 13900025 - No space left on device 6223 * @throws { BusinessError } 13900034 - Operation would block 6224 * @throws { BusinessError } 13900041 - Quota exceeded 6225 * @throws { BusinessError } 13900042 - Unknown error 6226 * @syscap SystemCapability.FileManagement.File.FileIO 6227 * @since 9 6228 */ 6229/** 6230 * Read text. 6231 * 6232 * @param { string } filePath - file path. 6233 * @param { object } [options] - options. 6234 * @param { AsyncCallback<string> } callback - The callback is used to return the contents of the read file. 6235 * @throws { BusinessError } 13900001 - Operation not permitted 6236 * @throws { BusinessError } 13900004 - Interrupted system call 6237 * @throws { BusinessError } 13900005 - I/O error 6238 * @throws { BusinessError } 13900008 - Bad file descriptor 6239 * @throws { BusinessError } 13900010 - Try again 6240 * @throws { BusinessError } 13900013 - Bad address 6241 * @throws { BusinessError } 13900019 - Is a directory 6242 * @throws { BusinessError } 13900020 - Invalid argument 6243 * @throws { BusinessError } 13900024 - File too large 6244 * @throws { BusinessError } 13900025 - No space left on device 6245 * @throws { BusinessError } 13900034 - Operation would block 6246 * @throws { BusinessError } 13900041 - Quota exceeded 6247 * @throws { BusinessError } 13900042 - Unknown error 6248 * @syscap SystemCapability.FileManagement.File.FileIO 6249 * @crossplatform 6250 * @since 10 6251 */ 6252/** 6253 * Reads the text content of a file. This API uses an asynchronous callback to return the result. 6254 * 6255 * @param { string } filePath - Application sandbox path of the file. 6256 * @param { ReadTextOptions } [options] - The options are as follows: 6257 * <br>offset (number): start position to read the data. This parameter is optional. By default, data is read from the current position. 6258 * <br>length (number): length of the data to read. This parameter is optional. The default value is the file length. 6259 * <br>encoding (string): format of the data to be encoded. It is valid only when the data is of the string type. 6260 * <br>The default value is 'utf-8', which is the only value supported. 6261 * @param { AsyncCallback<string> } callback - Callback used to return the content read. 6262 * @throws { BusinessError } 13900001 - Operation not permitted 6263 * @throws { BusinessError } 13900004 - Interrupted system call 6264 * @throws { BusinessError } 13900005 - I/O error 6265 * @throws { BusinessError } 13900008 - Bad file descriptor 6266 * @throws { BusinessError } 13900010 - Try again 6267 * @throws { BusinessError } 13900013 - Bad address 6268 * @throws { BusinessError } 13900019 - Is a directory 6269 * @throws { BusinessError } 13900020 - Invalid argument 6270 * @throws { BusinessError } 13900024 - File too large 6271 * @throws { BusinessError } 13900025 - No space left on device 6272 * @throws { BusinessError } 13900034 - Operation would block 6273 * @throws { BusinessError } 13900041 - Quota exceeded 6274 * @throws { BusinessError } 13900042 - Unknown error 6275 * @syscap SystemCapability.FileManagement.File.FileIO 6276 * @crossplatform 6277 * @atomicservice 6278 * @since 11 6279 */ 6280declare function readText( 6281 filePath: string, 6282 options: ReadTextOptions, 6283 callback: AsyncCallback<string> 6284): void; 6285 6286/** 6287 * Read text with sync interface. 6288 * 6289 * @param { string } filePath - file path. 6290 * @param { object } [options] - options. 6291 * @returns { string } Returns the contents of the read file. 6292 * @throws { BusinessError } 13900001 - Operation not permitted 6293 * @throws { BusinessError } 13900004 - Interrupted system call 6294 * @throws { BusinessError } 13900005 - I/O error 6295 * @throws { BusinessError } 13900008 - Bad file descriptor 6296 * @throws { BusinessError } 13900010 - Try again 6297 * @throws { BusinessError } 13900013 - Bad address 6298 * @throws { BusinessError } 13900019 - Is a directory 6299 * @throws { BusinessError } 13900020 - Invalid argument 6300 * @throws { BusinessError } 13900024 - File too large 6301 * @throws { BusinessError } 13900025 - No space left on device 6302 * @throws { BusinessError } 13900034 - Operation would block 6303 * @throws { BusinessError } 13900041 - Quota exceeded 6304 * @throws { BusinessError } 13900042 - Unknown error 6305 * @syscap SystemCapability.FileManagement.File.FileIO 6306 * @since 9 6307 */ 6308/** 6309 * Read text with sync interface. 6310 * 6311 * @param { string } filePath - file path. 6312 * @param { object } [options] - options. 6313 * @returns { string } Returns the contents of the read file. 6314 * @throws { BusinessError } 13900001 - Operation not permitted 6315 * @throws { BusinessError } 13900004 - Interrupted system call 6316 * @throws { BusinessError } 13900005 - I/O error 6317 * @throws { BusinessError } 13900008 - Bad file descriptor 6318 * @throws { BusinessError } 13900010 - Try again 6319 * @throws { BusinessError } 13900013 - Bad address 6320 * @throws { BusinessError } 13900019 - Is a directory 6321 * @throws { BusinessError } 13900020 - Invalid argument 6322 * @throws { BusinessError } 13900024 - File too large 6323 * @throws { BusinessError } 13900025 - No space left on device 6324 * @throws { BusinessError } 13900034 - Operation would block 6325 * @throws { BusinessError } 13900041 - Quota exceeded 6326 * @throws { BusinessError } 13900042 - Unknown error 6327 * @syscap SystemCapability.FileManagement.File.FileIO 6328 * @crossplatform 6329 * @since 10 6330 */ 6331/** 6332 * Read text with sync interface. 6333 * 6334 * @param { string } filePath - file path. 6335 * @param { ReadTextOptions } [options] - options. 6336 * @returns { string } Returns the contents of the read file. 6337 * @throws { BusinessError } 13900001 - Operation not permitted 6338 * @throws { BusinessError } 13900004 - Interrupted system call 6339 * @throws { BusinessError } 13900005 - I/O error 6340 * @throws { BusinessError } 13900008 - Bad file descriptor 6341 * @throws { BusinessError } 13900010 - Try again 6342 * @throws { BusinessError } 13900013 - Bad address 6343 * @throws { BusinessError } 13900019 - Is a directory 6344 * @throws { BusinessError } 13900020 - Invalid argument 6345 * @throws { BusinessError } 13900024 - File too large 6346 * @throws { BusinessError } 13900025 - No space left on device 6347 * @throws { BusinessError } 13900034 - Operation would block 6348 * @throws { BusinessError } 13900041 - Quota exceeded 6349 * @throws { BusinessError } 13900042 - Unknown error 6350 * @syscap SystemCapability.FileManagement.File.FileIO 6351 * @crossplatform 6352 * @atomicservice 6353 * @since 11 6354 */ 6355/** 6356 * Reads the text of a file. This API returns the result synchronously. 6357 * 6358 * @param { string } filePath - Application sandbox path of the file. 6359 * @param { ReadTextOptions } [options] - The options are as follows: 6360 * <br>offset (number): start position to read the data. This parameter is optional. By default, data is read from the current position. 6361 * <br>length (number): length of the data to read. This parameter is optional. The default value is the file length. 6362 * <br>encoding (string): format of the data to be encoded. It is valid only when the data is of the string type. 6363 * <br>The default value is 'utf-8', which is the only value supported. 6364 * @returns { string } Returns the contents of the read file. 6365 * @throws { BusinessError } 13900001 - Operation not permitted 6366 * @throws { BusinessError } 13900004 - Interrupted system call 6367 * @throws { BusinessError } 13900005 - I/O error 6368 * @throws { BusinessError } 13900008 - Bad file descriptor 6369 * @throws { BusinessError } 13900010 - Try again 6370 * @throws { BusinessError } 13900013 - Bad address 6371 * @throws { BusinessError } 13900019 - Is a directory 6372 * @throws { BusinessError } 13900020 - Invalid argument 6373 * @throws { BusinessError } 13900024 - File too large 6374 * @throws { BusinessError } 13900025 - No space left on device 6375 * @throws { BusinessError } 13900034 - Operation would block 6376 * @throws { BusinessError } 13900041 - Quota exceeded 6377 * @throws { BusinessError } 13900042 - Unknown error 6378 * @throws { BusinessError } 13900044 - Network is unreachable 6379 * @syscap SystemCapability.FileManagement.File.FileIO 6380 * @crossplatform 6381 * @atomicservice 6382 * @since 12 6383 */ 6384declare function readTextSync( 6385 filePath: string, 6386 options?: ReadTextOptions 6387): string; 6388 6389/** 6390 * Rename file. 6391 * 6392 * @param { string } oldPath - oldPath. 6393 * @param { string } newPath - newPath. 6394 * @returns { Promise<void> } The promise returned by the function. 6395 * @throws { BusinessError } 13900001 - Operation not permitted 6396 * @throws { BusinessError } 13900002 - No such file or directory 6397 * @throws { BusinessError } 13900008 - Bad file descriptor 6398 * @throws { BusinessError } 13900011 - Out of memory 6399 * @throws { BusinessError } 13900012 - Permission denied 6400 * @throws { BusinessError } 13900013 - Bad address 6401 * @throws { BusinessError } 13900014 - Device or resource busy 6402 * @throws { BusinessError } 13900015 - File exists 6403 * @throws { BusinessError } 13900016 - Cross-device link 6404 * @throws { BusinessError } 13900018 - Not a directory 6405 * @throws { BusinessError } 13900019 - Is a directory 6406 * @throws { BusinessError } 13900020 - Invalid argument 6407 * @throws { BusinessError } 13900025 - No space left on device 6408 * @throws { BusinessError } 13900027 - Read-only file system 6409 * @throws { BusinessError } 13900028 - Too many links 6410 * @throws { BusinessError } 13900032 - Directory not empty 6411 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6412 * @throws { BusinessError } 13900041 - Quota exceeded 6413 * @throws { BusinessError } 13900042 - Unknown error 6414 * @syscap SystemCapability.FileManagement.File.FileIO 6415 * @since 9 6416 */ 6417/** 6418 * Rename file. 6419 * 6420 * @param { string } oldPath - oldPath. 6421 * @param { string } newPath - newPath. 6422 * @returns { Promise<void> } The promise returned by the function. 6423 * @throws { BusinessError } 13900001 - Operation not permitted 6424 * @throws { BusinessError } 13900002 - No such file or directory 6425 * @throws { BusinessError } 13900008 - Bad file descriptor 6426 * @throws { BusinessError } 13900011 - Out of memory 6427 * @throws { BusinessError } 13900012 - Permission denied 6428 * @throws { BusinessError } 13900013 - Bad address 6429 * @throws { BusinessError } 13900014 - Device or resource busy 6430 * @throws { BusinessError } 13900015 - File exists 6431 * @throws { BusinessError } 13900016 - Cross-device link 6432 * @throws { BusinessError } 13900018 - Not a directory 6433 * @throws { BusinessError } 13900019 - Is a directory 6434 * @throws { BusinessError } 13900020 - Invalid argument 6435 * @throws { BusinessError } 13900025 - No space left on device 6436 * @throws { BusinessError } 13900027 - Read-only file system 6437 * @throws { BusinessError } 13900028 - Too many links 6438 * @throws { BusinessError } 13900032 - Directory not empty 6439 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6440 * @throws { BusinessError } 13900041 - Quota exceeded 6441 * @throws { BusinessError } 13900042 - Unknown error 6442 * @syscap SystemCapability.FileManagement.File.FileIO 6443 * @crossplatform 6444 * @since 10 6445 */ 6446/** 6447 * Renames a file or directory. This API uses a promise to return the result. 6448 * 6449 * @param { string } oldPath - Application sandbox path of the file or directory to rename. 6450 * @param { string } newPath - Application sandbox path of the renamed file or directory. 6451 * @returns { Promise<void> } Promise that returns no value. 6452 * @throws { BusinessError } 13900001 - Operation not permitted 6453 * @throws { BusinessError } 13900002 - No such file or directory 6454 * @throws { BusinessError } 13900008 - Bad file descriptor 6455 * @throws { BusinessError } 13900011 - Out of memory 6456 * @throws { BusinessError } 13900012 - Permission denied 6457 * @throws { BusinessError } 13900013 - Bad address 6458 * @throws { BusinessError } 13900014 - Device or resource busy 6459 * @throws { BusinessError } 13900015 - File exists 6460 * @throws { BusinessError } 13900016 - Cross-device link 6461 * @throws { BusinessError } 13900018 - Not a directory 6462 * @throws { BusinessError } 13900019 - Is a directory 6463 * @throws { BusinessError } 13900020 - Invalid argument 6464 * @throws { BusinessError } 13900025 - No space left on device 6465 * @throws { BusinessError } 13900027 - Read-only file system 6466 * @throws { BusinessError } 13900028 - Too many links 6467 * @throws { BusinessError } 13900032 - Directory not empty 6468 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6469 * @throws { BusinessError } 13900041 - Quota exceeded 6470 * @throws { BusinessError } 13900042 - Unknown error 6471 * @syscap SystemCapability.FileManagement.File.FileIO 6472 * @crossplatform 6473 * @atomicservice 6474 * @since 11 6475 */ 6476declare function rename(oldPath: string, newPath: string): Promise<void>; 6477 6478/** 6479 * Rename file. 6480 * 6481 * @param { string } oldPath - oldPath. 6482 * @param { string } newPath - newPath. 6483 * @param { AsyncCallback<void> } callback - Returns the callback function. 6484 * @throws { BusinessError } 13900001 - Operation not permitted 6485 * @throws { BusinessError } 13900002 - No such file or directory 6486 * @throws { BusinessError } 13900008 - Bad file descriptor 6487 * @throws { BusinessError } 13900011 - Out of memory 6488 * @throws { BusinessError } 13900012 - Permission denied 6489 * @throws { BusinessError } 13900013 - Bad address 6490 * @throws { BusinessError } 13900014 - Device or resource busy 6491 * @throws { BusinessError } 13900015 - File exists 6492 * @throws { BusinessError } 13900016 - Cross-device link 6493 * @throws { BusinessError } 13900018 - Not a directory 6494 * @throws { BusinessError } 13900019 - Is a directory 6495 * @throws { BusinessError } 13900020 - Invalid argument 6496 * @throws { BusinessError } 13900025 - No space left on device 6497 * @throws { BusinessError } 13900027 - Read-only file system 6498 * @throws { BusinessError } 13900028 - Too many links 6499 * @throws { BusinessError } 13900032 - Directory not empty 6500 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6501 * @throws { BusinessError } 13900041 - Quota exceeded 6502 * @throws { BusinessError } 13900042 - Unknown error 6503 * @syscap SystemCapability.FileManagement.File.FileIO 6504 * @since 9 6505 */ 6506/** 6507 * Rename file. 6508 * 6509 * @param { string } oldPath - oldPath. 6510 * @param { string } newPath - newPath. 6511 * @param { AsyncCallback<void> } callback - Returns the callback function. 6512 * @throws { BusinessError } 13900001 - Operation not permitted 6513 * @throws { BusinessError } 13900002 - No such file or directory 6514 * @throws { BusinessError } 13900008 - Bad file descriptor 6515 * @throws { BusinessError } 13900011 - Out of memory 6516 * @throws { BusinessError } 13900012 - Permission denied 6517 * @throws { BusinessError } 13900013 - Bad address 6518 * @throws { BusinessError } 13900014 - Device or resource busy 6519 * @throws { BusinessError } 13900015 - File exists 6520 * @throws { BusinessError } 13900016 - Cross-device link 6521 * @throws { BusinessError } 13900018 - Not a directory 6522 * @throws { BusinessError } 13900019 - Is a directory 6523 * @throws { BusinessError } 13900020 - Invalid argument 6524 * @throws { BusinessError } 13900025 - No space left on device 6525 * @throws { BusinessError } 13900027 - Read-only file system 6526 * @throws { BusinessError } 13900028 - Too many links 6527 * @throws { BusinessError } 13900032 - Directory not empty 6528 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6529 * @throws { BusinessError } 13900041 - Quota exceeded 6530 * @throws { BusinessError } 13900042 - Unknown error 6531 * @syscap SystemCapability.FileManagement.File.FileIO 6532 * @crossplatform 6533 * @since 10 6534 */ 6535/** 6536 * Renames a file or directory. This API uses an asynchronous callback to return the result. 6537 * 6538 * @param { string } oldPath - Application sandbox path of the file or directory to rename. 6539 * @param { string } newPath - Application sandbox path of the renamed file or directory. 6540 * @param { AsyncCallback<void> } callback - Callback used to return the result. 6541 * @throws { BusinessError } 13900001 - Operation not permitted 6542 * @throws { BusinessError } 13900002 - No such file or directory 6543 * @throws { BusinessError } 13900008 - Bad file descriptor 6544 * @throws { BusinessError } 13900011 - Out of memory 6545 * @throws { BusinessError } 13900012 - Permission denied 6546 * @throws { BusinessError } 13900013 - Bad address 6547 * @throws { BusinessError } 13900014 - Device or resource busy 6548 * @throws { BusinessError } 13900015 - File exists 6549 * @throws { BusinessError } 13900016 - Cross-device link 6550 * @throws { BusinessError } 13900018 - Not a directory 6551 * @throws { BusinessError } 13900019 - Is a directory 6552 * @throws { BusinessError } 13900020 - Invalid argument 6553 * @throws { BusinessError } 13900025 - No space left on device 6554 * @throws { BusinessError } 13900027 - Read-only file system 6555 * @throws { BusinessError } 13900028 - Too many links 6556 * @throws { BusinessError } 13900032 - Directory not empty 6557 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6558 * @throws { BusinessError } 13900041 - Quota exceeded 6559 * @throws { BusinessError } 13900042 - Unknown error 6560 * @syscap SystemCapability.FileManagement.File.FileIO 6561 * @crossplatform 6562 * @atomicservice 6563 * @since 11 6564 */ 6565declare function rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): void; 6566 6567/** 6568 * Rename file with sync interface. 6569 * 6570 * @param { string } oldPath - oldPath. 6571 * @param { string } newPath - newPath. 6572 * @throws { BusinessError } 13900001 - Operation not permitted 6573 * @throws { BusinessError } 13900002 - No such file or directory 6574 * @throws { BusinessError } 13900008 - Bad file descriptor 6575 * @throws { BusinessError } 13900011 - Out of memory 6576 * @throws { BusinessError } 13900012 - Permission denied 6577 * @throws { BusinessError } 13900013 - Bad address 6578 * @throws { BusinessError } 13900014 - Device or resource busy 6579 * @throws { BusinessError } 13900015 - File exists 6580 * @throws { BusinessError } 13900016 - Cross-device link 6581 * @throws { BusinessError } 13900018 - Not a directory 6582 * @throws { BusinessError } 13900019 - Is a directory 6583 * @throws { BusinessError } 13900020 - Invalid argument 6584 * @throws { BusinessError } 13900025 - No space left on device 6585 * @throws { BusinessError } 13900027 - Read-only file system 6586 * @throws { BusinessError } 13900028 - Too many links 6587 * @throws { BusinessError } 13900032 - Directory not empty 6588 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6589 * @throws { BusinessError } 13900041 - Quota exceeded 6590 * @throws { BusinessError } 13900042 - Unknown error 6591 * @syscap SystemCapability.FileManagement.File.FileIO 6592 * @since 9 6593 */ 6594/** 6595 * Rename file with sync interface. 6596 * 6597 * @param { string } oldPath - oldPath. 6598 * @param { string } newPath - newPath. 6599 * @throws { BusinessError } 13900001 - Operation not permitted 6600 * @throws { BusinessError } 13900002 - No such file or directory 6601 * @throws { BusinessError } 13900008 - Bad file descriptor 6602 * @throws { BusinessError } 13900011 - Out of memory 6603 * @throws { BusinessError } 13900012 - Permission denied 6604 * @throws { BusinessError } 13900013 - Bad address 6605 * @throws { BusinessError } 13900014 - Device or resource busy 6606 * @throws { BusinessError } 13900015 - File exists 6607 * @throws { BusinessError } 13900016 - Cross-device link 6608 * @throws { BusinessError } 13900018 - Not a directory 6609 * @throws { BusinessError } 13900019 - Is a directory 6610 * @throws { BusinessError } 13900020 - Invalid argument 6611 * @throws { BusinessError } 13900025 - No space left on device 6612 * @throws { BusinessError } 13900027 - Read-only file system 6613 * @throws { BusinessError } 13900028 - Too many links 6614 * @throws { BusinessError } 13900032 - Directory not empty 6615 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6616 * @throws { BusinessError } 13900041 - Quota exceeded 6617 * @throws { BusinessError } 13900042 - Unknown error 6618 * @syscap SystemCapability.FileManagement.File.FileIO 6619 * @crossplatform 6620 * @since 10 6621 */ 6622/** 6623 * Renames a file or directory. This API returns the result synchronously. 6624 * 6625 * @param { string } oldPath - Application sandbox path of the file or directory to rename. 6626 * @param { string } newPath - Application sandbox path of the renamed file or directory. 6627 * @throws { BusinessError } 13900001 - Operation not permitted 6628 * @throws { BusinessError } 13900002 - No such file or directory 6629 * @throws { BusinessError } 13900008 - Bad file descriptor 6630 * @throws { BusinessError } 13900011 - Out of memory 6631 * @throws { BusinessError } 13900012 - Permission denied 6632 * @throws { BusinessError } 13900013 - Bad address 6633 * @throws { BusinessError } 13900014 - Device or resource busy 6634 * @throws { BusinessError } 13900015 - File exists 6635 * @throws { BusinessError } 13900016 - Cross-device link 6636 * @throws { BusinessError } 13900018 - Not a directory 6637 * @throws { BusinessError } 13900019 - Is a directory 6638 * @throws { BusinessError } 13900020 - Invalid argument 6639 * @throws { BusinessError } 13900025 - No space left on device 6640 * @throws { BusinessError } 13900027 - Read-only file system 6641 * @throws { BusinessError } 13900028 - Too many links 6642 * @throws { BusinessError } 13900032 - Directory not empty 6643 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6644 * @throws { BusinessError } 13900041 - Quota exceeded 6645 * @throws { BusinessError } 13900042 - Unknown error 6646 * @syscap SystemCapability.FileManagement.File.FileIO 6647 * @crossplatform 6648 * @atomicservice 6649 * @since 11 6650 */ 6651declare function renameSync(oldPath: string, newPath: string): void; 6652 6653/** 6654 * Delete dir. 6655 * 6656 * @param { string } path - path. 6657 * @returns { Promise<void> } The promise returned by the function. 6658 * @throws { BusinessError } 13900001 - Operation not permitted 6659 * @throws { BusinessError } 13900002 - No such file or directory 6660 * @throws { BusinessError } 13900011 - Out of memory 6661 * @throws { BusinessError } 13900012 - Permission denied 6662 * @throws { BusinessError } 13900013 - Bad address 6663 * @throws { BusinessError } 13900014 - Device or resource busy 6664 * @throws { BusinessError } 13900018 - Not a directory 6665 * @throws { BusinessError } 13900020 - Invalid argument 6666 * @throws { BusinessError } 13900027 - Read-only file system1 6667 * @throws { BusinessError } 13900030 - File name too long 6668 * @throws { BusinessError } 13900032 - Directory not empty 6669 * @throws { BusinessError } 13900042 - Unknown error 6670 * @syscap SystemCapability.FileManagement.File.FileIO 6671 * @since 9 6672 */ 6673/** 6674 * Delete dir. 6675 * 6676 * @param { string } path - path. 6677 * @returns { Promise<void> } The promise returned by the function. 6678 * @throws { BusinessError } 13900001 - Operation not permitted 6679 * @throws { BusinessError } 13900002 - No such file or directory 6680 * @throws { BusinessError } 13900011 - Out of memory 6681 * @throws { BusinessError } 13900012 - Permission denied 6682 * @throws { BusinessError } 13900013 - Bad address 6683 * @throws { BusinessError } 13900014 - Device or resource busy 6684 * @throws { BusinessError } 13900018 - Not a directory 6685 * @throws { BusinessError } 13900020 - Invalid argument 6686 * @throws { BusinessError } 13900027 - Read-only file system1 6687 * @throws { BusinessError } 13900030 - File name too long 6688 * @throws { BusinessError } 13900032 - Directory not empty 6689 * @throws { BusinessError } 13900042 - Unknown error 6690 * @syscap SystemCapability.FileManagement.File.FileIO 6691 * @crossplatform 6692 * @since 10 6693 */ 6694/** 6695 * Removes a directory. This API uses a promise to return the result. 6696 * 6697 * @param { string } path - Application sandbox path of the directory. 6698 * @returns { Promise<void> } Promise that returns no value. 6699 * @throws { BusinessError } 13900001 - Operation not permitted 6700 * @throws { BusinessError } 13900002 - No such file or directory 6701 * @throws { BusinessError } 13900011 - Out of memory 6702 * @throws { BusinessError } 13900012 - Permission denied 6703 * @throws { BusinessError } 13900013 - Bad address 6704 * @throws { BusinessError } 13900014 - Device or resource busy 6705 * @throws { BusinessError } 13900018 - Not a directory 6706 * @throws { BusinessError } 13900020 - Invalid argument 6707 * @throws { BusinessError } 13900027 - Read-only file system1 6708 * @throws { BusinessError } 13900030 - File name too long 6709 * @throws { BusinessError } 13900032 - Directory not empty 6710 * @throws { BusinessError } 13900042 - Unknown error 6711 * @syscap SystemCapability.FileManagement.File.FileIO 6712 * @crossplatform 6713 * @atomicservice 6714 * @since 11 6715 */ 6716declare function rmdir(path: string): Promise<void>; 6717 6718/** 6719 * Delete dir. 6720 * 6721 * @param { string } path - path. 6722 * @param { AsyncCallback<void> } callback - Return the callback function. 6723 * @throws { BusinessError } 13900001 - Operation not permitted 6724 * @throws { BusinessError } 13900002 - No such file or directory 6725 * @throws { BusinessError } 13900011 - Out of memory 6726 * @throws { BusinessError } 13900012 - Permission denied 6727 * @throws { BusinessError } 13900013 - Bad address 6728 * @throws { BusinessError } 13900014 - Device or resource busy 6729 * @throws { BusinessError } 13900018 - Not a directory 6730 * @throws { BusinessError } 13900020 - Invalid argument 6731 * @throws { BusinessError } 13900027 - Read-only file system1 6732 * @throws { BusinessError } 13900030 - File name too long 6733 * @throws { BusinessError } 13900032 - Directory not empty 6734 * @throws { BusinessError } 13900042 - Unknown error 6735 * @syscap SystemCapability.FileManagement.File.FileIO 6736 * @since 9 6737 */ 6738/** 6739 * Delete dir. 6740 * 6741 * @param { string } path - path. 6742 * @param { AsyncCallback<void> } callback - Return the callback function. 6743 * @throws { BusinessError } 13900001 - Operation not permitted 6744 * @throws { BusinessError } 13900002 - No such file or directory 6745 * @throws { BusinessError } 13900011 - Out of memory 6746 * @throws { BusinessError } 13900012 - Permission denied 6747 * @throws { BusinessError } 13900013 - Bad address 6748 * @throws { BusinessError } 13900014 - Device or resource busy 6749 * @throws { BusinessError } 13900018 - Not a directory 6750 * @throws { BusinessError } 13900020 - Invalid argument 6751 * @throws { BusinessError } 13900027 - Read-only file system1 6752 * @throws { BusinessError } 13900030 - File name too long 6753 * @throws { BusinessError } 13900032 - Directory not empty 6754 * @throws { BusinessError } 13900042 - Unknown error 6755 * @syscap SystemCapability.FileManagement.File.FileIO 6756 * @crossplatform 6757 * @since 10 6758 */ 6759/** 6760 * Removes a directory. This API uses an asynchronous callback to return the result. 6761 * 6762 * @param { string } path - Application sandbox path of the directory. 6763 * @param { AsyncCallback<void> } callback - Callback used to return the result. 6764 * @throws { BusinessError } 13900001 - Operation not permitted 6765 * @throws { BusinessError } 13900002 - No such file or directory 6766 * @throws { BusinessError } 13900011 - Out of memory 6767 * @throws { BusinessError } 13900012 - Permission denied 6768 * @throws { BusinessError } 13900013 - Bad address 6769 * @throws { BusinessError } 13900014 - Device or resource busy 6770 * @throws { BusinessError } 13900018 - Not a directory 6771 * @throws { BusinessError } 13900020 - Invalid argument 6772 * @throws { BusinessError } 13900027 - Read-only file system1 6773 * @throws { BusinessError } 13900030 - File name too long 6774 * @throws { BusinessError } 13900032 - Directory not empty 6775 * @throws { BusinessError } 13900042 - Unknown error 6776 * @syscap SystemCapability.FileManagement.File.FileIO 6777 * @crossplatform 6778 * @atomicservice 6779 * @since 11 6780 */ 6781declare function rmdir(path: string, callback: AsyncCallback<void>): void; 6782 6783/** 6784 * Delete dir with sync interface. 6785 * 6786 * @param { string } path - path. 6787 * @throws { BusinessError } 13900001 - Operation not permitted 6788 * @throws { BusinessError } 13900002 - No such file or directory 6789 * @throws { BusinessError } 13900011 - Out of memory 6790 * @throws { BusinessError } 13900012 - Permission denied 6791 * @throws { BusinessError } 13900013 - Bad address 6792 * @throws { BusinessError } 13900014 - Device or resource busy 6793 * @throws { BusinessError } 13900018 - Not a directory 6794 * @throws { BusinessError } 13900020 - Invalid argument 6795 * @throws { BusinessError } 13900027 - Read-only file system1 6796 * @throws { BusinessError } 13900030 - File name too long 6797 * @throws { BusinessError } 13900032 - Directory not empty 6798 * @throws { BusinessError } 13900042 - Unknown error 6799 * @syscap SystemCapability.FileManagement.File.FileIO 6800 * @since 9 6801 */ 6802/** 6803 * Delete dir with sync interface. 6804 * 6805 * @param { string } path - path. 6806 * @throws { BusinessError } 13900001 - Operation not permitted 6807 * @throws { BusinessError } 13900002 - No such file or directory 6808 * @throws { BusinessError } 13900011 - Out of memory 6809 * @throws { BusinessError } 13900012 - Permission denied 6810 * @throws { BusinessError } 13900013 - Bad address 6811 * @throws { BusinessError } 13900014 - Device or resource busy 6812 * @throws { BusinessError } 13900018 - Not a directory 6813 * @throws { BusinessError } 13900020 - Invalid argument 6814 * @throws { BusinessError } 13900027 - Read-only file system1 6815 * @throws { BusinessError } 13900030 - File name too long 6816 * @throws { BusinessError } 13900032 - Directory not empty 6817 * @throws { BusinessError } 13900042 - Unknown error 6818 * @syscap SystemCapability.FileManagement.File.FileIO 6819 * @crossplatform 6820 * @since 10 6821 */ 6822/** 6823 * Removes a directory. This API returns the result synchronously. 6824 * 6825 * @param { string } path - Application sandbox path of the directory. 6826 * @throws { BusinessError } 13900001 - Operation not permitted 6827 * @throws { BusinessError } 13900002 - No such file or directory 6828 * @throws { BusinessError } 13900011 - Out of memory 6829 * @throws { BusinessError } 13900012 - Permission denied 6830 * @throws { BusinessError } 13900013 - Bad address 6831 * @throws { BusinessError } 13900014 - Device or resource busy 6832 * @throws { BusinessError } 13900018 - Not a directory 6833 * @throws { BusinessError } 13900020 - Invalid argument 6834 * @throws { BusinessError } 13900027 - Read-only file system1 6835 * @throws { BusinessError } 13900030 - File name too long 6836 * @throws { BusinessError } 13900032 - Directory not empty 6837 * @throws { BusinessError } 13900042 - Unknown error 6838 * @syscap SystemCapability.FileManagement.File.FileIO 6839 * @crossplatform 6840 * @atomicservice 6841 * @since 11 6842 */ 6843declare function rmdirSync(path: string): void; 6844 6845/** 6846 * Get file information. 6847 * 6848 * @param { string | number } file - path or file descriptor. 6849 * @returns { Promise<Stat> } Returns the Stat object in promise mode. 6850 * @throws { BusinessError } 13900002 - No such file or directory 6851 * @throws { BusinessError } 13900004 - Interrupted system call 6852 * @throws { BusinessError } 13900005 - I/O error 6853 * @throws { BusinessError } 13900008 - Bad file descriptor 6854 * @throws { BusinessError } 13900011 - Out of memory 6855 * @throws { BusinessError } 13900012 - Permission denied 6856 * @throws { BusinessError } 13900013 - Bad address 6857 * @throws { BusinessError } 13900018 - Not a directory 6858 * @throws { BusinessError } 13900030 - File name too long 6859 * @throws { BusinessError } 13900031 - Function not implemented 6860 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6861 * @throws { BusinessError } 13900038 - Value too large for defined data type 6862 * @throws { BusinessError } 13900042 - Unknown error 6863 * @syscap SystemCapability.FileManagement.File.FileIO 6864 * @since 9 6865 */ 6866/** 6867 * Get file information. 6868 * 6869 * @param { string | number } file - path or file descriptor. 6870 * @returns { Promise<Stat> } Returns the Stat object in promise mode. 6871 * @throws { BusinessError } 13900002 - No such file or directory 6872 * @throws { BusinessError } 13900004 - Interrupted system call 6873 * @throws { BusinessError } 13900005 - I/O error 6874 * @throws { BusinessError } 13900008 - Bad file descriptor 6875 * @throws { BusinessError } 13900011 - Out of memory 6876 * @throws { BusinessError } 13900012 - Permission denied 6877 * @throws { BusinessError } 13900013 - Bad address 6878 * @throws { BusinessError } 13900018 - Not a directory 6879 * @throws { BusinessError } 13900030 - File name too long 6880 * @throws { BusinessError } 13900031 - Function not implemented 6881 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6882 * @throws { BusinessError } 13900038 - Value too large for defined data type 6883 * @throws { BusinessError } 13900042 - Unknown error 6884 * @syscap SystemCapability.FileManagement.File.FileIO 6885 * @crossplatform 6886 * @since 10 6887 */ 6888/** 6889 * Obtains detailed attribute information of a file or directory. This API uses a promise to return the result. 6890 * 6891 * @param { string | number } file - Application sandbox path or FD of the file. 6892 * @returns { Promise<Stat> } Promise used to return detailed file information. 6893 * @throws { BusinessError } 13900002 - No such file or directory 6894 * @throws { BusinessError } 13900004 - Interrupted system call 6895 * @throws { BusinessError } 13900005 - I/O error 6896 * @throws { BusinessError } 13900008 - Bad file descriptor 6897 * @throws { BusinessError } 13900011 - Out of memory 6898 * @throws { BusinessError } 13900012 - Permission denied 6899 * @throws { BusinessError } 13900013 - Bad address 6900 * @throws { BusinessError } 13900018 - Not a directory 6901 * @throws { BusinessError } 13900030 - File name too long 6902 * @throws { BusinessError } 13900031 - Function not implemented 6903 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6904 * @throws { BusinessError } 13900038 - Value too large for defined data type 6905 * @throws { BusinessError } 13900042 - Unknown error 6906 * @syscap SystemCapability.FileManagement.File.FileIO 6907 * @crossplatform 6908 * @atomicservice 6909 * @since 11 6910 */ 6911declare function stat(file: string | number): Promise<Stat>; 6912 6913/** 6914 * Get file information. 6915 * 6916 * @param { string | number } file - path or file descriptor. 6917 * @param { AsyncCallback<Stat> } callback - The callback is used to return the Stat object. 6918 * @throws { BusinessError } 13900002 - No such file or directory 6919 * @throws { BusinessError } 13900004 - Interrupted system call 6920 * @throws { BusinessError } 13900005 - I/O error 6921 * @throws { BusinessError } 13900008 - Bad file descriptor 6922 * @throws { BusinessError } 13900011 - Out of memory 6923 * @throws { BusinessError } 13900012 - Permission denied 6924 * @throws { BusinessError } 13900013 - Bad address 6925 * @throws { BusinessError } 13900018 - Not a directory 6926 * @throws { BusinessError } 13900030 - File name too long 6927 * @throws { BusinessError } 13900031 - Function not implemented 6928 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6929 * @throws { BusinessError } 13900038 - Value too large for defined data type 6930 * @throws { BusinessError } 13900042 - Unknown error 6931 * @syscap SystemCapability.FileManagement.File.FileIO 6932 * @since 9 6933 */ 6934/** 6935 * Get file information. 6936 * 6937 * @param { string | number } file - path or file descriptor. 6938 * @param { AsyncCallback<Stat> } callback - The callback is used to return the Stat object. 6939 * @throws { BusinessError } 13900002 - No such file or directory 6940 * @throws { BusinessError } 13900004 - Interrupted system call 6941 * @throws { BusinessError } 13900005 - I/O error 6942 * @throws { BusinessError } 13900008 - Bad file descriptor 6943 * @throws { BusinessError } 13900011 - Out of memory 6944 * @throws { BusinessError } 13900012 - Permission denied 6945 * @throws { BusinessError } 13900013 - Bad address 6946 * @throws { BusinessError } 13900018 - Not a directory 6947 * @throws { BusinessError } 13900030 - File name too long 6948 * @throws { BusinessError } 13900031 - Function not implemented 6949 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6950 * @throws { BusinessError } 13900038 - Value too large for defined data type 6951 * @throws { BusinessError } 13900042 - Unknown error 6952 * @syscap SystemCapability.FileManagement.File.FileIO 6953 * @crossplatform 6954 * @since 10 6955 */ 6956/** 6957 * Obtains detailed attribute information of a file or directory. 6958 * This API uses an asynchronous callback to return the result. 6959 * 6960 * @param { string | number } file - Application sandbox path or FD of the file. 6961 * @param { AsyncCallback<Stat> } callback - Callback used to return the file information obtained. 6962 * @throws { BusinessError } 13900002 - No such file or directory 6963 * @throws { BusinessError } 13900004 - Interrupted system call 6964 * @throws { BusinessError } 13900005 - I/O error 6965 * @throws { BusinessError } 13900008 - Bad file descriptor 6966 * @throws { BusinessError } 13900011 - Out of memory 6967 * @throws { BusinessError } 13900012 - Permission denied 6968 * @throws { BusinessError } 13900013 - Bad address 6969 * @throws { BusinessError } 13900018 - Not a directory 6970 * @throws { BusinessError } 13900030 - File name too long 6971 * @throws { BusinessError } 13900031 - Function not implemented 6972 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6973 * @throws { BusinessError } 13900038 - Value too large for defined data type 6974 * @throws { BusinessError } 13900042 - Unknown error 6975 * @syscap SystemCapability.FileManagement.File.FileIO 6976 * @crossplatform 6977 * @atomicservice 6978 * @since 11 6979 */ 6980declare function stat(file: string | number, callback: AsyncCallback<Stat>): void; 6981 6982/** 6983 * Get file information with sync interface. 6984 * 6985 * @param { string | number } file - path or file descriptor. 6986 * @returns { Stat } Returns the Stat object. 6987 * @throws { BusinessError } 13900002 - No such file or directory 6988 * @throws { BusinessError } 13900004 - Interrupted system call 6989 * @throws { BusinessError } 13900005 - I/O error 6990 * @throws { BusinessError } 13900008 - Bad file descriptor 6991 * @throws { BusinessError } 13900011 - Out of memory 6992 * @throws { BusinessError } 13900012 - Permission denied 6993 * @throws { BusinessError } 13900013 - Bad address 6994 * @throws { BusinessError } 13900018 - Not a directory 6995 * @throws { BusinessError } 13900030 - File name too long 6996 * @throws { BusinessError } 13900031 - Function not implemented 6997 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 6998 * @throws { BusinessError } 13900038 - Value too large for defined data type 6999 * @throws { BusinessError } 13900042 - Unknown error 7000 * @syscap SystemCapability.FileManagement.File.FileIO 7001 * @since 9 7002 */ 7003/** 7004 * Get file information with sync interface. 7005 * 7006 * @param { string | number } file - path or file descriptor. 7007 * @returns { Stat } Returns the Stat object. 7008 * @throws { BusinessError } 13900002 - No such file or directory 7009 * @throws { BusinessError } 13900004 - Interrupted system call 7010 * @throws { BusinessError } 13900005 - I/O error 7011 * @throws { BusinessError } 13900008 - Bad file descriptor 7012 * @throws { BusinessError } 13900011 - Out of memory 7013 * @throws { BusinessError } 13900012 - Permission denied 7014 * @throws { BusinessError } 13900013 - Bad address 7015 * @throws { BusinessError } 13900018 - Not a directory 7016 * @throws { BusinessError } 13900030 - File name too long 7017 * @throws { BusinessError } 13900031 - Function not implemented 7018 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7019 * @throws { BusinessError } 13900038 - Value too large for defined data type 7020 * @throws { BusinessError } 13900042 - Unknown error 7021 * @syscap SystemCapability.FileManagement.File.FileIO 7022 * @crossplatform 7023 * @since 10 7024 */ 7025/** 7026 * Obtains detailed attribute information of a file or directory. This API returns the result synchronously. 7027 * 7028 * @param { string | number } file - Application sandbox path or FD of the file. 7029 * @returns { Stat } File information obtained. 7030 * @throws { BusinessError } 13900002 - No such file or directory 7031 * @throws { BusinessError } 13900004 - Interrupted system call 7032 * @throws { BusinessError } 13900005 - I/O error 7033 * @throws { BusinessError } 13900008 - Bad file descriptor 7034 * @throws { BusinessError } 13900011 - Out of memory 7035 * @throws { BusinessError } 13900012 - Permission denied 7036 * @throws { BusinessError } 13900013 - Bad address 7037 * @throws { BusinessError } 13900018 - Not a directory 7038 * @throws { BusinessError } 13900030 - File name too long 7039 * @throws { BusinessError } 13900031 - Function not implemented 7040 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7041 * @throws { BusinessError } 13900038 - Value too large for defined data type 7042 * @throws { BusinessError } 13900042 - Unknown error 7043 * @syscap SystemCapability.FileManagement.File.FileIO 7044 * @crossplatform 7045 * @atomicservice 7046 * @since 11 7047 */ 7048declare function statSync(file: string | number): Stat; 7049 7050/** 7051 * Creates a symbolic link based on a file path. This API uses a promise to return the result. 7052 * 7053 * @param { string } target - Application sandbox path of the target file. 7054 * @param { string } srcPath - Application sandbox path of the symbolic link. 7055 * @returns { Promise<void> } Promise that returns no value. 7056 * @throws { BusinessError } 13900001 - Operation not permitted 7057 * @throws { BusinessError } 13900002 - No such file or directory 7058 * @throws { BusinessError } 13900005 - I/O error 7059 * @throws { BusinessError } 13900008 - Bad file descriptor 7060 * @throws { BusinessError } 13900011 - Out of memory 7061 * @throws { BusinessError } 13900012 - Permission denied 7062 * @throws { BusinessError } 13900013 - Bad address 7063 * @throws { BusinessError } 13900015 - File exists 7064 * @throws { BusinessError } 13900018 - Not a directory 7065 * @throws { BusinessError } 13900025 - No space left on device 7066 * @throws { BusinessError } 13900027 - Read-only file system 7067 * @throws { BusinessError } 13900030 - File name too long 7068 * @throws { BusinessError } 13900041 - Quota exceeded 7069 * @throws { BusinessError } 13900042 - Unknown error 7070 * @syscap SystemCapability.FileManagement.File.FileIO 7071 * @since 9 7072 */ 7073declare function symlink(target: string, srcPath: string): Promise<void>; 7074 7075/** 7076 * Creates a symbolic link based on a file path. This API uses an asynchronous callback to return the result. 7077 * 7078 * @param { string } target - Application sandbox path of the target file. 7079 * @param { string } srcPath - Application sandbox path of the symbolic link. 7080 * @param { AsyncCallback<void> } callback - Callback used to return the result. 7081 * @throws { BusinessError } 13900001 - Operation not permitted 7082 * @throws { BusinessError } 13900002 - No such file or directory 7083 * @throws { BusinessError } 13900005 - I/O error 7084 * @throws { BusinessError } 13900008 - Bad file descriptor 7085 * @throws { BusinessError } 13900011 - Out of memory 7086 * @throws { BusinessError } 13900012 - Permission denied 7087 * @throws { BusinessError } 13900013 - Bad address 7088 * @throws { BusinessError } 13900015 - File exists 7089 * @throws { BusinessError } 13900018 - Not a directory 7090 * @throws { BusinessError } 13900025 - No space left on device 7091 * @throws { BusinessError } 13900027 - Read-only file system 7092 * @throws { BusinessError } 13900030 - File name too long 7093 * @throws { BusinessError } 13900041 - Quota exceeded 7094 * @throws { BusinessError } 13900042 - Unknown error 7095 * @syscap SystemCapability.FileManagement.File.FileIO 7096 * @since 9 7097 */ 7098declare function symlink(target: string, srcPath: string, callback: AsyncCallback<void>): void; 7099 7100/** 7101 * Creates a symbolic link based on a file path. This API returns the result synchronously. 7102 * 7103 * @param { string } target - Application sandbox path of the target file. 7104 * @param { string } srcPath - Application sandbox path of the symbolic link. 7105 * @throws { BusinessError } 13900001 - Operation not permitted 7106 * @throws { BusinessError } 13900002 - No such file or directory 7107 * @throws { BusinessError } 13900005 - I/O error 7108 * @throws { BusinessError } 13900008 - Bad file descriptor 7109 * @throws { BusinessError } 13900011 - Out of memory 7110 * @throws { BusinessError } 13900012 - Permission denied 7111 * @throws { BusinessError } 13900013 - Bad address 7112 * @throws { BusinessError } 13900015 - File exists 7113 * @throws { BusinessError } 13900018 - Not a directory 7114 * @throws { BusinessError } 13900025 - No space left on device 7115 * @throws { BusinessError } 13900027 - Read-only file system 7116 * @throws { BusinessError } 13900030 - File name too long 7117 * @throws { BusinessError } 13900041 - Quota exceeded 7118 * @throws { BusinessError } 13900042 - Unknown error 7119 * @syscap SystemCapability.FileManagement.File.FileIO 7120 * @since 9 7121 */ 7122declare function symlinkSync(target: string, srcPath: string): void; 7123 7124/** 7125 * Truncate file. 7126 * 7127 * @param { string | number } file - path or file descriptor. 7128 * @param { number } [len = 0] - len. 7129 * @returns { Promise<void> } The promise returned by the function. 7130 * @throws { BusinessError } 13900001 - Operation not permitted 7131 * @throws { BusinessError } 13900002 - No such file or directory 7132 * @throws { BusinessError } 13900004 - Interrupted system call 7133 * @throws { BusinessError } 13900005 - I/O error 7134 * @throws { BusinessError } 13900008 - Bad file descriptor 7135 * @throws { BusinessError } 13900012 - Permission denied 7136 * @throws { BusinessError } 13900013 - Bad address 7137 * @throws { BusinessError } 13900018 - Not a directory 7138 * @throws { BusinessError } 13900019 - Is a directory 7139 * @throws { BusinessError } 13900020 - Invalid argument 7140 * @throws { BusinessError } 13900023 - Text file busy 7141 * @throws { BusinessError } 13900024 - File too large 7142 * @throws { BusinessError } 13900027 - Read-only file system 7143 * @throws { BusinessError } 13900030 - File name too long 7144 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7145 * @throws { BusinessError } 13900042 - Unknown error 7146 * @syscap SystemCapability.FileManagement.File.FileIO 7147 * @since 9 7148 */ 7149/** 7150 * Truncate file. 7151 * 7152 * @param { string | number } file - path or file descriptor. 7153 * @param { number } [len = 0] - len. 7154 * @returns { Promise<void> } The promise returned by the function. 7155 * @throws { BusinessError } 13900001 - Operation not permitted 7156 * @throws { BusinessError } 13900002 - No such file or directory 7157 * @throws { BusinessError } 13900004 - Interrupted system call 7158 * @throws { BusinessError } 13900005 - I/O error 7159 * @throws { BusinessError } 13900008 - Bad file descriptor 7160 * @throws { BusinessError } 13900012 - Permission denied 7161 * @throws { BusinessError } 13900013 - Bad address 7162 * @throws { BusinessError } 13900018 - Not a directory 7163 * @throws { BusinessError } 13900019 - Is a directory 7164 * @throws { BusinessError } 13900020 - Invalid argument 7165 * @throws { BusinessError } 13900023 - Text file busy 7166 * @throws { BusinessError } 13900024 - File too large 7167 * @throws { BusinessError } 13900027 - Read-only file system 7168 * @throws { BusinessError } 13900030 - File name too long 7169 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7170 * @throws { BusinessError } 13900042 - Unknown error 7171 * @syscap SystemCapability.FileManagement.File.FileIO 7172 * @crossplatform 7173 * @since 10 7174 */ 7175/** 7176 * Truncates a file. This API uses a promise to return the result. 7177 * 7178 * @param { string | number } file - Application sandbox path or FD of the file. 7179 * @param { number } [len = 0] - File length, in bytes, after truncation. The default value is 0. 7180 * @returns { Promise<void> } Promise that returns no value. 7181 * @throws { BusinessError } 13900001 - Operation not permitted 7182 * @throws { BusinessError } 13900002 - No such file or directory 7183 * @throws { BusinessError } 13900004 - Interrupted system call 7184 * @throws { BusinessError } 13900005 - I/O error 7185 * @throws { BusinessError } 13900008 - Bad file descriptor 7186 * @throws { BusinessError } 13900012 - Permission denied 7187 * @throws { BusinessError } 13900013 - Bad address 7188 * @throws { BusinessError } 13900018 - Not a directory 7189 * @throws { BusinessError } 13900019 - Is a directory 7190 * @throws { BusinessError } 13900020 - Invalid argument 7191 * @throws { BusinessError } 13900023 - Text file busy 7192 * @throws { BusinessError } 13900024 - File too large 7193 * @throws { BusinessError } 13900027 - Read-only file system 7194 * @throws { BusinessError } 13900030 - File name too long 7195 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7196 * @throws { BusinessError } 13900042 - Unknown error 7197 * @syscap SystemCapability.FileManagement.File.FileIO 7198 * @crossplatform 7199 * @atomicservice 7200 * @since 11 7201 */ 7202declare function truncate(file: string | number, len?: number): Promise<void>; 7203 7204/** 7205 * Truncate file. 7206 * 7207 * @param { string | number } file - path or file descriptor. 7208 * @param { AsyncCallback<void> } callback - Return the callback function. 7209 * @throws { BusinessError } 13900001 - Operation not permitted 7210 * @throws { BusinessError } 13900002 - No such file or directory 7211 * @throws { BusinessError } 13900004 - Interrupted system call 7212 * @throws { BusinessError } 13900005 - I/O error 7213 * @throws { BusinessError } 13900008 - Bad file descriptor 7214 * @throws { BusinessError } 13900012 - Permission denied 7215 * @throws { BusinessError } 13900013 - Bad address 7216 * @throws { BusinessError } 13900018 - Not a directory 7217 * @throws { BusinessError } 13900019 - Is a directory 7218 * @throws { BusinessError } 13900020 - Invalid argument 7219 * @throws { BusinessError } 13900023 - Text file busy 7220 * @throws { BusinessError } 13900024 - File too large 7221 * @throws { BusinessError } 13900027 - Read-only file system 7222 * @throws { BusinessError } 13900030 - File name too long 7223 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7224 * @throws { BusinessError } 13900042 - Unknown error 7225 * @syscap SystemCapability.FileManagement.File.FileIO 7226 * @since 9 7227 */ 7228/** 7229 * Truncate file. 7230 * 7231 * @param { string | number } file - path or file descriptor. 7232 * @param { AsyncCallback<void> } callback - Return the callback function. 7233 * @throws { BusinessError } 13900001 - Operation not permitted 7234 * @throws { BusinessError } 13900002 - No such file or directory 7235 * @throws { BusinessError } 13900004 - Interrupted system call 7236 * @throws { BusinessError } 13900005 - I/O error 7237 * @throws { BusinessError } 13900008 - Bad file descriptor 7238 * @throws { BusinessError } 13900012 - Permission denied 7239 * @throws { BusinessError } 13900013 - Bad address 7240 * @throws { BusinessError } 13900018 - Not a directory 7241 * @throws { BusinessError } 13900019 - Is a directory 7242 * @throws { BusinessError } 13900020 - Invalid argument 7243 * @throws { BusinessError } 13900023 - Text file busy 7244 * @throws { BusinessError } 13900024 - File too large 7245 * @throws { BusinessError } 13900027 - Read-only file system 7246 * @throws { BusinessError } 13900030 - File name too long 7247 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7248 * @throws { BusinessError } 13900042 - Unknown error 7249 * @syscap SystemCapability.FileManagement.File.FileIO 7250 * @crossplatform 7251 * @since 10 7252 */ 7253/** 7254 * Truncates a file. This API uses an asynchronous callback to return the result. 7255 * 7256 * @param { string | number } file - Application sandbox path or FD of the file. 7257 * @param { AsyncCallback<void> } callback - Callback that returns no value. 7258 * @throws { BusinessError } 13900001 - Operation not permitted 7259 * @throws { BusinessError } 13900002 - No such file or directory 7260 * @throws { BusinessError } 13900004 - Interrupted system call 7261 * @throws { BusinessError } 13900005 - I/O error 7262 * @throws { BusinessError } 13900008 - Bad file descriptor 7263 * @throws { BusinessError } 13900012 - Permission denied 7264 * @throws { BusinessError } 13900013 - Bad address 7265 * @throws { BusinessError } 13900018 - Not a directory 7266 * @throws { BusinessError } 13900019 - Is a directory 7267 * @throws { BusinessError } 13900020 - Invalid argument 7268 * @throws { BusinessError } 13900023 - Text file busy 7269 * @throws { BusinessError } 13900024 - File too large 7270 * @throws { BusinessError } 13900027 - Read-only file system 7271 * @throws { BusinessError } 13900030 - File name too long 7272 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7273 * @throws { BusinessError } 13900042 - Unknown error 7274 * @syscap SystemCapability.FileManagement.File.FileIO 7275 * @crossplatform 7276 * @atomicservice 7277 * @since 11 7278 */ 7279declare function truncate(file: string | number, callback: AsyncCallback<void>): void; 7280 7281/** 7282 * Truncate file. 7283 * 7284 * @param { string | number } file - path or file descriptor. 7285 * @param { number } [len = 0] - len. 7286 * @param { AsyncCallback<void> } callback - Return the callback function. 7287 * @throws { BusinessError } 13900001 - Operation not permitted 7288 * @throws { BusinessError } 13900002 - No such file or directory 7289 * @throws { BusinessError } 13900004 - Interrupted system call 7290 * @throws { BusinessError } 13900005 - I/O error 7291 * @throws { BusinessError } 13900008 - Bad file descriptor 7292 * @throws { BusinessError } 13900012 - Permission denied 7293 * @throws { BusinessError } 13900013 - Bad address 7294 * @throws { BusinessError } 13900018 - Not a directory 7295 * @throws { BusinessError } 13900019 - Is a directory 7296 * @throws { BusinessError } 13900020 - Invalid argument 7297 * @throws { BusinessError } 13900023 - Text file busy 7298 * @throws { BusinessError } 13900024 - File too large 7299 * @throws { BusinessError } 13900027 - Read-only file system 7300 * @throws { BusinessError } 13900030 - File name too long 7301 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7302 * @throws { BusinessError } 13900042 - Unknown error 7303 * @syscap SystemCapability.FileManagement.File.FileIO 7304 * @since 9 7305 */ 7306/** 7307 * Truncate file. 7308 * 7309 * @param { string | number } file - path or file descriptor. 7310 * @param { number } [len = 0] - len. 7311 * @param { AsyncCallback<void> } callback - Return the callback function. 7312 * @throws { BusinessError } 13900001 - Operation not permitted 7313 * @throws { BusinessError } 13900002 - No such file or directory 7314 * @throws { BusinessError } 13900004 - Interrupted system call 7315 * @throws { BusinessError } 13900005 - I/O error 7316 * @throws { BusinessError } 13900008 - Bad file descriptor 7317 * @throws { BusinessError } 13900012 - Permission denied 7318 * @throws { BusinessError } 13900013 - Bad address 7319 * @throws { BusinessError } 13900018 - Not a directory 7320 * @throws { BusinessError } 13900019 - Is a directory 7321 * @throws { BusinessError } 13900020 - Invalid argument 7322 * @throws { BusinessError } 13900023 - Text file busy 7323 * @throws { BusinessError } 13900024 - File too large 7324 * @throws { BusinessError } 13900027 - Read-only file system 7325 * @throws { BusinessError } 13900030 - File name too long 7326 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7327 * @throws { BusinessError } 13900042 - Unknown error 7328 * @syscap SystemCapability.FileManagement.File.FileIO 7329 * @crossplatform 7330 * @since 10 7331 */ 7332/** 7333 * Truncates a file. This API uses an asynchronous callback to return the result. 7334 * 7335 * @param { string | number } file - Application sandbox path or FD of the file. 7336 * @param { number } len - File length, in bytes, after truncation. 7337 * @param { AsyncCallback<void> } callback - Callback that returns no value. 7338 * @throws { BusinessError } 13900001 - Operation not permitted 7339 * @throws { BusinessError } 13900002 - No such file or directory 7340 * @throws { BusinessError } 13900004 - Interrupted system call 7341 * @throws { BusinessError } 13900005 - I/O error 7342 * @throws { BusinessError } 13900008 - Bad file descriptor 7343 * @throws { BusinessError } 13900012 - Permission denied 7344 * @throws { BusinessError } 13900013 - Bad address 7345 * @throws { BusinessError } 13900018 - Not a directory 7346 * @throws { BusinessError } 13900019 - Is a directory 7347 * @throws { BusinessError } 13900020 - Invalid argument 7348 * @throws { BusinessError } 13900023 - Text file busy 7349 * @throws { BusinessError } 13900024 - File too large 7350 * @throws { BusinessError } 13900027 - Read-only file system 7351 * @throws { BusinessError } 13900030 - File name too long 7352 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7353 * @throws { BusinessError } 13900042 - Unknown error 7354 * @syscap SystemCapability.FileManagement.File.FileIO 7355 * @crossplatform 7356 * @atomicservice 7357 * @since 11 7358 */ 7359declare function truncate(file: string | number, len: number, callback: AsyncCallback<void>): void; 7360 7361/** 7362 * Truncate file with sync interface. 7363 * 7364 * @param { string | number } file - path or file descriptor. 7365 * @param { number } [len = 0] - len. 7366 * @throws { BusinessError } 13900001 - Operation not permitted 7367 * @throws { BusinessError } 13900002 - No such file or directory 7368 * @throws { BusinessError } 13900004 - Interrupted system call 7369 * @throws { BusinessError } 13900005 - I/O error 7370 * @throws { BusinessError } 13900008 - Bad file descriptor 7371 * @throws { BusinessError } 13900012 - Permission denied 7372 * @throws { BusinessError } 13900013 - Bad address 7373 * @throws { BusinessError } 13900018 - Not a directory 7374 * @throws { BusinessError } 13900019 - Is a directory 7375 * @throws { BusinessError } 13900020 - Invalid argument 7376 * @throws { BusinessError } 13900023 - Text file busy 7377 * @throws { BusinessError } 13900024 - File too large 7378 * @throws { BusinessError } 13900027 - Read-only file system 7379 * @throws { BusinessError } 13900030 - File name too long 7380 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7381 * @throws { BusinessError } 13900042 - Unknown error 7382 * @syscap SystemCapability.FileManagement.File.FileIO 7383 * @since 9 7384 */ 7385/** 7386 * Truncate file with sync interface. 7387 * 7388 * @param { string | number } file - path or file descriptor. 7389 * @param { number } [len = 0] - len. 7390 * @throws { BusinessError } 13900001 - Operation not permitted 7391 * @throws { BusinessError } 13900002 - No such file or directory 7392 * @throws { BusinessError } 13900004 - Interrupted system call 7393 * @throws { BusinessError } 13900005 - I/O error 7394 * @throws { BusinessError } 13900008 - Bad file descriptor 7395 * @throws { BusinessError } 13900012 - Permission denied 7396 * @throws { BusinessError } 13900013 - Bad address 7397 * @throws { BusinessError } 13900018 - Not a directory 7398 * @throws { BusinessError } 13900019 - Is a directory 7399 * @throws { BusinessError } 13900020 - Invalid argument 7400 * @throws { BusinessError } 13900023 - Text file busy 7401 * @throws { BusinessError } 13900024 - File too large 7402 * @throws { BusinessError } 13900027 - Read-only file system 7403 * @throws { BusinessError } 13900030 - File name too long 7404 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7405 * @throws { BusinessError } 13900042 - Unknown error 7406 * @syscap SystemCapability.FileManagement.File.FileIO 7407 * @crossplatform 7408 * @since 10 7409 */ 7410/** 7411 * Truncates the file content. This API returns the result synchronously. 7412 * 7413 * @param { string | number } file - Application sandbox path or FD of the file. 7414 * @param { number } [len = 0] - File length, in bytes, after truncation. The default value is 0. 7415 * @throws { BusinessError } 13900001 - Operation not permitted 7416 * @throws { BusinessError } 13900002 - No such file or directory 7417 * @throws { BusinessError } 13900004 - Interrupted system call 7418 * @throws { BusinessError } 13900005 - I/O error 7419 * @throws { BusinessError } 13900008 - Bad file descriptor 7420 * @throws { BusinessError } 13900012 - Permission denied 7421 * @throws { BusinessError } 13900013 - Bad address 7422 * @throws { BusinessError } 13900018 - Not a directory 7423 * @throws { BusinessError } 13900019 - Is a directory 7424 * @throws { BusinessError } 13900020 - Invalid argument 7425 * @throws { BusinessError } 13900023 - Text file busy 7426 * @throws { BusinessError } 13900024 - File too large 7427 * @throws { BusinessError } 13900027 - Read-only file system 7428 * @throws { BusinessError } 13900030 - File name too long 7429 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7430 * @throws { BusinessError } 13900042 - Unknown error 7431 * @syscap SystemCapability.FileManagement.File.FileIO 7432 * @crossplatform 7433 * @atomicservice 7434 * @since 11 7435 */ 7436declare function truncateSync(file: string | number, len?: number): void; 7437 7438/** 7439 * Delete file. 7440 * 7441 * @param { string } path - path. 7442 * @returns { Promise<void> } The promise returned by the function. 7443 * @throws { BusinessError } 13900001 - Operation not permitted 7444 * @throws { BusinessError } 13900002 - No such file or directory 7445 * @throws { BusinessError } 13900005 - I/O error 7446 * @throws { BusinessError } 13900008 - Bad file descriptor 7447 * @throws { BusinessError } 13900011 - Out of memory 7448 * @throws { BusinessError } 13900012 - Permission denied 7449 * @throws { BusinessError } 13900013 - Bad address 7450 * @throws { BusinessError } 13900014 - Device or resource busy 7451 * @throws { BusinessError } 13900018 - Not a directory 7452 * @throws { BusinessError } 13900019 - Is a directory 7453 * @throws { BusinessError } 13900020 - Invalid argument 7454 * @throws { BusinessError } 13900027 - Read-only file system 7455 * @throws { BusinessError } 13900030 - File name too long 7456 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7457 * @throws { BusinessError } 13900042 - Unknown error 7458 * @syscap SystemCapability.FileManagement.File.FileIO 7459 * @since 9 7460 */ 7461/** 7462 * Delete file. 7463 * 7464 * @param { string } path - path. 7465 * @returns { Promise<void> } The promise returned by the function. 7466 * @throws { BusinessError } 13900001 - Operation not permitted 7467 * @throws { BusinessError } 13900002 - No such file or directory 7468 * @throws { BusinessError } 13900005 - I/O error 7469 * @throws { BusinessError } 13900008 - Bad file descriptor 7470 * @throws { BusinessError } 13900011 - Out of memory 7471 * @throws { BusinessError } 13900012 - Permission denied 7472 * @throws { BusinessError } 13900013 - Bad address 7473 * @throws { BusinessError } 13900014 - Device or resource busy 7474 * @throws { BusinessError } 13900018 - Not a directory 7475 * @throws { BusinessError } 13900019 - Is a directory 7476 * @throws { BusinessError } 13900020 - Invalid argument 7477 * @throws { BusinessError } 13900027 - Read-only file system 7478 * @throws { BusinessError } 13900030 - File name too long 7479 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7480 * @throws { BusinessError } 13900042 - Unknown error 7481 * @syscap SystemCapability.FileManagement.File.FileIO 7482 * @crossplatform 7483 * @since 10 7484 */ 7485/** 7486 * Deletes a file. This API uses a promise to return the result. 7487 * 7488 * @param { string } path - Application sandbox path of the file. 7489 * @returns { Promise<void> } Promise that returns no value. 7490 * @throws { BusinessError } 13900001 - Operation not permitted 7491 * @throws { BusinessError } 13900002 - No such file or directory 7492 * @throws { BusinessError } 13900005 - I/O error 7493 * @throws { BusinessError } 13900008 - Bad file descriptor 7494 * @throws { BusinessError } 13900011 - Out of memory 7495 * @throws { BusinessError } 13900012 - Permission denied 7496 * @throws { BusinessError } 13900013 - Bad address 7497 * @throws { BusinessError } 13900014 - Device or resource busy 7498 * @throws { BusinessError } 13900018 - Not a directory 7499 * @throws { BusinessError } 13900019 - Is a directory 7500 * @throws { BusinessError } 13900020 - Invalid argument 7501 * @throws { BusinessError } 13900027 - Read-only file system 7502 * @throws { BusinessError } 13900030 - File name too long 7503 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7504 * @throws { BusinessError } 13900042 - Unknown error 7505 * @syscap SystemCapability.FileManagement.File.FileIO 7506 * @crossplatform 7507 * @atomicservice 7508 * @since 11 7509 */ 7510declare function unlink(path: string): Promise<void>; 7511 7512/** 7513 * Delete file. 7514 * 7515 * @param { string } path - path. 7516 * @param { AsyncCallback<void> } callback - Return the callback function. 7517 * @throws { BusinessError } 13900001 - Operation not permitted 7518 * @throws { BusinessError } 13900002 - No such file or directory 7519 * @throws { BusinessError } 13900005 - I/O error 7520 * @throws { BusinessError } 13900008 - Bad file descriptor 7521 * @throws { BusinessError } 13900011 - Out of memory 7522 * @throws { BusinessError } 13900012 - Permission denied 7523 * @throws { BusinessError } 13900013 - Bad address 7524 * @throws { BusinessError } 13900014 - Device or resource busy 7525 * @throws { BusinessError } 13900018 - Not a directory 7526 * @throws { BusinessError } 13900019 - Is a directory 7527 * @throws { BusinessError } 13900020 - Invalid argument 7528 * @throws { BusinessError } 13900027 - Read-only file system 7529 * @throws { BusinessError } 13900030 - File name too long 7530 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7531 * @throws { BusinessError } 13900042 - Unknown error 7532 * @syscap SystemCapability.FileManagement.File.FileIO 7533 * @since 9 7534 */ 7535/** 7536 * Delete file. 7537 * 7538 * @param { string } path - path. 7539 * @param { AsyncCallback<void> } callback - Return the callback function. 7540 * @throws { BusinessError } 13900001 - Operation not permitted 7541 * @throws { BusinessError } 13900002 - No such file or directory 7542 * @throws { BusinessError } 13900005 - I/O error 7543 * @throws { BusinessError } 13900008 - Bad file descriptor 7544 * @throws { BusinessError } 13900011 - Out of memory 7545 * @throws { BusinessError } 13900012 - Permission denied 7546 * @throws { BusinessError } 13900013 - Bad address 7547 * @throws { BusinessError } 13900014 - Device or resource busy 7548 * @throws { BusinessError } 13900018 - Not a directory 7549 * @throws { BusinessError } 13900019 - Is a directory 7550 * @throws { BusinessError } 13900020 - Invalid argument 7551 * @throws { BusinessError } 13900027 - Read-only file system 7552 * @throws { BusinessError } 13900030 - File name too long 7553 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7554 * @throws { BusinessError } 13900042 - Unknown error 7555 * @syscap SystemCapability.FileManagement.File.FileIO 7556 * @crossplatform 7557 * @since 10 7558 */ 7559/** 7560 * Deletes a file. This API uses an asynchronous callback to return the result. 7561 * 7562 * @param { string } path - Application sandbox path of the file. 7563 * @param { AsyncCallback<void> } callback - Callback invoked immediately after the file is deleted. 7564 * @throws { BusinessError } 13900001 - Operation not permitted 7565 * @throws { BusinessError } 13900002 - No such file or directory 7566 * @throws { BusinessError } 13900005 - I/O error 7567 * @throws { BusinessError } 13900008 - Bad file descriptor 7568 * @throws { BusinessError } 13900011 - Out of memory 7569 * @throws { BusinessError } 13900012 - Permission denied 7570 * @throws { BusinessError } 13900013 - Bad address 7571 * @throws { BusinessError } 13900014 - Device or resource busy 7572 * @throws { BusinessError } 13900018 - Not a directory 7573 * @throws { BusinessError } 13900019 - Is a directory 7574 * @throws { BusinessError } 13900020 - Invalid argument 7575 * @throws { BusinessError } 13900027 - Read-only file system 7576 * @throws { BusinessError } 13900030 - File name too long 7577 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7578 * @throws { BusinessError } 13900042 - Unknown error 7579 * @syscap SystemCapability.FileManagement.File.FileIO 7580 * @crossplatform 7581 * @atomicservice 7582 * @since 11 7583 */ 7584declare function unlink(path: string, callback: AsyncCallback<void>): void; 7585 7586/** 7587 * Delete file with sync interface. 7588 * 7589 * @param { string } path - path. 7590 * @throws { BusinessError } 13900001 - Operation not permitted 7591 * @throws { BusinessError } 13900002 - No such file or directory 7592 * @throws { BusinessError } 13900005 - I/O error 7593 * @throws { BusinessError } 13900008 - Bad file descriptor 7594 * @throws { BusinessError } 13900011 - Out of memory 7595 * @throws { BusinessError } 13900012 - Permission denied 7596 * @throws { BusinessError } 13900013 - Bad address 7597 * @throws { BusinessError } 13900014 - Device or resource busy 7598 * @throws { BusinessError } 13900018 - Not a directory 7599 * @throws { BusinessError } 13900019 - Is a directory 7600 * @throws { BusinessError } 13900020 - Invalid argument 7601 * @throws { BusinessError } 13900027 - Read-only file system 7602 * @throws { BusinessError } 13900030 - File name too long 7603 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7604 * @throws { BusinessError } 13900042 - Unknown error 7605 * @syscap SystemCapability.FileManagement.File.FileIO 7606 * @since 9 7607 */ 7608/** 7609 * Delete file with sync interface. 7610 * 7611 * @param { string } path - path. 7612 * @throws { BusinessError } 13900001 - Operation not permitted 7613 * @throws { BusinessError } 13900002 - No such file or directory 7614 * @throws { BusinessError } 13900005 - I/O error 7615 * @throws { BusinessError } 13900008 - Bad file descriptor 7616 * @throws { BusinessError } 13900011 - Out of memory 7617 * @throws { BusinessError } 13900012 - Permission denied 7618 * @throws { BusinessError } 13900013 - Bad address 7619 * @throws { BusinessError } 13900014 - Device or resource busy 7620 * @throws { BusinessError } 13900018 - Not a directory 7621 * @throws { BusinessError } 13900019 - Is a directory 7622 * @throws { BusinessError } 13900020 - Invalid argument 7623 * @throws { BusinessError } 13900027 - Read-only file system 7624 * @throws { BusinessError } 13900030 - File name too long 7625 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7626 * @throws { BusinessError } 13900042 - Unknown error 7627 * @syscap SystemCapability.FileManagement.File.FileIO 7628 * @crossplatform 7629 * @since 10 7630 */ 7631/** 7632 * Deletes a file. This API returns the result synchronously. 7633 * 7634 * @param { string } path - Application sandbox path of the file. 7635 * @throws { BusinessError } 13900001 - Operation not permitted 7636 * @throws { BusinessError } 13900002 - No such file or directory 7637 * @throws { BusinessError } 13900005 - I/O error 7638 * @throws { BusinessError } 13900008 - Bad file descriptor 7639 * @throws { BusinessError } 13900011 - Out of memory 7640 * @throws { BusinessError } 13900012 - Permission denied 7641 * @throws { BusinessError } 13900013 - Bad address 7642 * @throws { BusinessError } 13900014 - Device or resource busy 7643 * @throws { BusinessError } 13900018 - Not a directory 7644 * @throws { BusinessError } 13900019 - Is a directory 7645 * @throws { BusinessError } 13900020 - Invalid argument 7646 * @throws { BusinessError } 13900027 - Read-only file system 7647 * @throws { BusinessError } 13900030 - File name too long 7648 * @throws { BusinessError } 13900033 - Too many symbolic links encountered 7649 * @throws { BusinessError } 13900042 - Unknown error 7650 * @syscap SystemCapability.FileManagement.File.FileIO 7651 * @crossplatform 7652 * @atomicservice 7653 * @since 11 7654 */ 7655declare function unlinkSync(path: string): void; 7656 7657/** 7658 * Change file mtime. 7659 * 7660 * @param { string } path - path. 7661 * @param { number } mtime - last modification time 7662 * @throws { BusinessError } 13900001 - Operation not permitted 7663 * @throws { BusinessError } 13900002 - No such file or directory 7664 * @throws { BusinessError } 13900012 - Permission denied 7665 * @throws { BusinessError } 13900020 - Invalid argument 7666 * @throws { BusinessError } 13900027 - Read-only file system 7667 * @throws { BusinessError } 13900042 - Unknown error 7668 * @syscap SystemCapability.FileManagement.File.FileIO 7669 * @since 11 7670 */ 7671/** 7672 * Updates the latest access timestamp of a file. 7673 * 7674 * @param { string } path - Application sandbox path of the file. 7675 * @param { number } mtime - New timestamp. The value is the number of milliseconds elapsed since the Epoch time (00:00:00 UTC on January 1, 1970). 7676 * <br>Only the last access time of a file can be modified. 7677 * @throws { BusinessError } 13900001 - Operation not permitted 7678 * @throws { BusinessError } 13900002 - No such file or directory 7679 * @throws { BusinessError } 13900012 - Permission denied 7680 * @throws { BusinessError } 13900020 - Invalid argument 7681 * @throws { BusinessError } 13900027 - Read-only file system 7682 * @throws { BusinessError } 13900042 - Unknown error 7683 * @syscap SystemCapability.FileManagement.File.FileIO 7684 * @crossplatform 7685 * @since 12 7686 */ 7687declare function utimes(path: string, mtime: number): void; 7688 7689/** 7690 * Write file. 7691 * 7692 * @param { number } fd - file descriptor. 7693 * @param { ArrayBuffer | string } buffer - buffer. 7694 * @param { object } [options] - options. 7695 * @returns { Promise<number> } Returns the number of bytes written to the file in promise mode. 7696 * @throws { BusinessError } 13900001 - Operation not permitted 7697 * @throws { BusinessError } 13900004 - Interrupted system call 7698 * @throws { BusinessError } 13900005 - I/O error 7699 * @throws { BusinessError } 13900008 - Bad file descriptor 7700 * @throws { BusinessError } 13900010 - Try again 7701 * @throws { BusinessError } 13900013 - Bad address 7702 * @throws { BusinessError } 13900020 - Invalid argument 7703 * @throws { BusinessError } 13900024 - File too large 7704 * @throws { BusinessError } 13900025 - No space left on device 7705 * @throws { BusinessError } 13900034 - Operation would block 7706 * @throws { BusinessError } 13900041 - Quota exceeded 7707 * @throws { BusinessError } 13900042 - Unknown error 7708 * @syscap SystemCapability.FileManagement.File.FileIO 7709 * @since 9 7710 */ 7711/** 7712 * Write file. 7713 * 7714 * @param { number } fd - file descriptor. 7715 * @param { ArrayBuffer | string } buffer - buffer. 7716 * @param { object } [options] - options. 7717 * @returns { Promise<number> } Returns the number of bytes written to the file in promise mode. 7718 * @throws { BusinessError } 13900001 - Operation not permitted 7719 * @throws { BusinessError } 13900004 - Interrupted system call 7720 * @throws { BusinessError } 13900005 - I/O error 7721 * @throws { BusinessError } 13900008 - Bad file descriptor 7722 * @throws { BusinessError } 13900010 - Try again 7723 * @throws { BusinessError } 13900013 - Bad address 7724 * @throws { BusinessError } 13900020 - Invalid argument 7725 * @throws { BusinessError } 13900024 - File too large 7726 * @throws { BusinessError } 13900025 - No space left on device 7727 * @throws { BusinessError } 13900034 - Operation would block 7728 * @throws { BusinessError } 13900041 - Quota exceeded 7729 * @throws { BusinessError } 13900042 - Unknown error 7730 * @syscap SystemCapability.FileManagement.File.FileIO 7731 * @crossplatform 7732 * @since 10 7733 */ 7734/** 7735 * Writes data into a file. This API uses a promise to return the result. 7736 * 7737 * @param { number } fd - FD of the file. 7738 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 7739 * @param { WriteOptions } [options] - Defines the options use din write(). It inherits from Options. 7740 * @returns { Promise<number> } Returns the number of bytes written to the file in promise mode. 7741 * @throws { BusinessError } 13900001 - Operation not permitted 7742 * @throws { BusinessError } 13900004 - Interrupted system call 7743 * @throws { BusinessError } 13900005 - I/O error 7744 * @throws { BusinessError } 13900008 - Bad file descriptor 7745 * @throws { BusinessError } 13900010 - Try again 7746 * @throws { BusinessError } 13900013 - Bad address 7747 * @throws { BusinessError } 13900020 - Invalid argument 7748 * @throws { BusinessError } 13900024 - File too large 7749 * @throws { BusinessError } 13900025 - No space left on device 7750 * @throws { BusinessError } 13900034 - Operation would block 7751 * @throws { BusinessError } 13900041 - Quota exceeded 7752 * @throws { BusinessError } 13900042 - Unknown error 7753 * @syscap SystemCapability.FileManagement.File.FileIO 7754 * @crossplatform 7755 * @atomicservice 7756 * @since 11 7757 */ 7758declare function write( 7759 fd: number, 7760 buffer: ArrayBuffer | string, 7761 options?: WriteOptions 7762): Promise<number>; 7763 7764/** 7765 * Write file. 7766 * 7767 * @param { number } fd - file descriptor. 7768 * @param { ArrayBuffer | string } buffer - buffer. 7769 * @param { AsyncCallback<number> } callback - The callback is used to return the number of bytes written to the file. 7770 * @throws { BusinessError } 13900001 - Operation not permitted 7771 * @throws { BusinessError } 13900004 - Interrupted system call 7772 * @throws { BusinessError } 13900005 - I/O error 7773 * @throws { BusinessError } 13900008 - Bad file descriptor 7774 * @throws { BusinessError } 13900010 - Try again 7775 * @throws { BusinessError } 13900013 - Bad address 7776 * @throws { BusinessError } 13900020 - Invalid argument 7777 * @throws { BusinessError } 13900024 - File too large 7778 * @throws { BusinessError } 13900025 - No space left on device 7779 * @throws { BusinessError } 13900034 - Operation would block 7780 * @throws { BusinessError } 13900041 - Quota exceeded 7781 * @throws { BusinessError } 13900042 - Unknown error 7782 * @syscap SystemCapability.FileManagement.File.FileIO 7783 * @since 9 7784 */ 7785/** 7786 * Write file. 7787 * 7788 * @param { number } fd - file descriptor. 7789 * @param { ArrayBuffer | string } buffer - buffer. 7790 * @param { AsyncCallback<number> } callback - The callback is used to return the number of bytes written to the file. 7791 * @throws { BusinessError } 13900001 - Operation not permitted 7792 * @throws { BusinessError } 13900004 - Interrupted system call 7793 * @throws { BusinessError } 13900005 - I/O error 7794 * @throws { BusinessError } 13900008 - Bad file descriptor 7795 * @throws { BusinessError } 13900010 - Try again 7796 * @throws { BusinessError } 13900013 - Bad address 7797 * @throws { BusinessError } 13900020 - Invalid argument 7798 * @throws { BusinessError } 13900024 - File too large 7799 * @throws { BusinessError } 13900025 - No space left on device 7800 * @throws { BusinessError } 13900034 - Operation would block 7801 * @throws { BusinessError } 13900041 - Quota exceeded 7802 * @throws { BusinessError } 13900042 - Unknown error 7803 * @syscap SystemCapability.FileManagement.File.FileIO 7804 * @crossplatform 7805 * @since 10 7806 */ 7807/** 7808 * Writes data to a file. This API uses an asynchronous callback to return the result. 7809 * 7810 * @param { number } fd - FD of the file. 7811 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 7812 * @param { AsyncCallback<number> } callback - Callback used to return the result. 7813 * @throws { BusinessError } 13900001 - Operation not permitted 7814 * @throws { BusinessError } 13900004 - Interrupted system call 7815 * @throws { BusinessError } 13900005 - I/O error 7816 * @throws { BusinessError } 13900008 - Bad file descriptor 7817 * @throws { BusinessError } 13900010 - Try again 7818 * @throws { BusinessError } 13900013 - Bad address 7819 * @throws { BusinessError } 13900020 - Invalid argument 7820 * @throws { BusinessError } 13900024 - File too large 7821 * @throws { BusinessError } 13900025 - No space left on device 7822 * @throws { BusinessError } 13900034 - Operation would block 7823 * @throws { BusinessError } 13900041 - Quota exceeded 7824 * @throws { BusinessError } 13900042 - Unknown error 7825 * @syscap SystemCapability.FileManagement.File.FileIO 7826 * @crossplatform 7827 * @atomicservice 7828 * @since 11 7829 */ 7830declare function write(fd: number, buffer: ArrayBuffer | string, callback: AsyncCallback<number>): void; 7831 7832/** 7833 * Write file. 7834 * 7835 * @param { number } fd - file descriptor. 7836 * @param { ArrayBuffer | string } buffer - buffer. 7837 * @param { object } [options] - options. 7838 * @param { AsyncCallback<number> } callback - The callback is used to return the number of bytes written to the file. 7839 * @throws { BusinessError } 13900001 - Operation not permitted 7840 * @throws { BusinessError } 13900004 - Interrupted system call 7841 * @throws { BusinessError } 13900005 - I/O error 7842 * @throws { BusinessError } 13900008 - Bad file descriptor 7843 * @throws { BusinessError } 13900010 - Try again 7844 * @throws { BusinessError } 13900013 - Bad address 7845 * @throws { BusinessError } 13900020 - Invalid argument 7846 * @throws { BusinessError } 13900024 - File too large 7847 * @throws { BusinessError } 13900025 - No space left on device 7848 * @throws { BusinessError } 13900034 - Operation would block 7849 * @throws { BusinessError } 13900041 - Quota exceeded 7850 * @throws { BusinessError } 13900042 - Unknown error 7851 * @syscap SystemCapability.FileManagement.File.FileIO 7852 * @since 9 7853 */ 7854/** 7855 * Write file. 7856 * 7857 * @param { number } fd - file descriptor. 7858 * @param { ArrayBuffer | string } buffer - buffer. 7859 * @param { object } [options] - options. 7860 * @param { AsyncCallback<number> } callback - The callback is used to return the number of bytes written to the file. 7861 * @throws { BusinessError } 13900001 - Operation not permitted 7862 * @throws { BusinessError } 13900004 - Interrupted system call 7863 * @throws { BusinessError } 13900005 - I/O error 7864 * @throws { BusinessError } 13900008 - Bad file descriptor 7865 * @throws { BusinessError } 13900010 - Try again 7866 * @throws { BusinessError } 13900013 - Bad address 7867 * @throws { BusinessError } 13900020 - Invalid argument 7868 * @throws { BusinessError } 13900024 - File too large 7869 * @throws { BusinessError } 13900025 - No space left on device 7870 * @throws { BusinessError } 13900034 - Operation would block 7871 * @throws { BusinessError } 13900041 - Quota exceeded 7872 * @throws { BusinessError } 13900042 - Unknown error 7873 * @syscap SystemCapability.FileManagement.File.FileIO 7874 * @crossplatform 7875 * @since 10 7876 */ 7877/** 7878 * Writes data to a file. This API uses an asynchronous callback to return the result. 7879 * 7880 * @param { number } fd - FD of the file. 7881 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 7882 * @param { WriteOptions } [options] - The options are as follows: 7883 * <br>length (number): length of the data to write. This parameter is optional. The default value is the buffer length. 7884 * <br>offset (number): start position to write the data in the file. This parameter is optional. 7885 * <br>By default, data is written from the current position. 7886 * <br>encoding (string): format of the data to be encoded when the data is a string. 7887 * <br>The default value is 'utf-8', which is the only value supported. 7888 * @param { AsyncCallback<number> } callback - The callback is used to return the number of bytes written to the file. 7889 * @throws { BusinessError } 13900001 - Operation not permitted 7890 * @throws { BusinessError } 13900004 - Interrupted system call 7891 * @throws { BusinessError } 13900005 - I/O error 7892 * @throws { BusinessError } 13900008 - Bad file descriptor 7893 * @throws { BusinessError } 13900010 - Try again 7894 * @throws { BusinessError } 13900013 - Bad address 7895 * @throws { BusinessError } 13900020 - Invalid argument 7896 * @throws { BusinessError } 13900024 - File too large 7897 * @throws { BusinessError } 13900025 - No space left on device 7898 * @throws { BusinessError } 13900034 - Operation would block 7899 * @throws { BusinessError } 13900041 - Quota exceeded 7900 * @throws { BusinessError } 13900042 - Unknown error 7901 * @syscap SystemCapability.FileManagement.File.FileIO 7902 * @crossplatform 7903 * @atomicservice 7904 * @since 11 7905 */ 7906declare function write( 7907 fd: number, 7908 buffer: ArrayBuffer | string, 7909 options: WriteOptions, 7910 callback: AsyncCallback<number> 7911): void; 7912 7913/** 7914 * Write file with sync interface. 7915 * 7916 * @param { number } fd - file descriptor. 7917 * @param { ArrayBuffer | string } buffer - buffer. 7918 * @param { object } [options] - options. 7919 * @returns { number } Returns the number of bytes written to the file. 7920 * @throws { BusinessError } 13900001 - Operation not permitted 7921 * @throws { BusinessError } 13900004 - Interrupted system call 7922 * @throws { BusinessError } 13900005 - I/O error 7923 * @throws { BusinessError } 13900008 - Bad file descriptor 7924 * @throws { BusinessError } 13900010 - Try again 7925 * @throws { BusinessError } 13900013 - Bad address 7926 * @throws { BusinessError } 13900020 - Invalid argument 7927 * @throws { BusinessError } 13900024 - File too large 7928 * @throws { BusinessError } 13900025 - No space left on device 7929 * @throws { BusinessError } 13900034 - Operation would block 7930 * @throws { BusinessError } 13900041 - Quota exceeded 7931 * @throws { BusinessError } 13900042 - Unknown error 7932 * @syscap SystemCapability.FileManagement.File.FileIO 7933 * @since 9 7934 */ 7935/** 7936 * Write file with sync interface. 7937 * 7938 * @param { number } fd - file descriptor. 7939 * @param { ArrayBuffer | string } buffer - buffer. 7940 * @param { object } [options] - options. 7941 * @returns { number } Returns the number of bytes written to the file. 7942 * @throws { BusinessError } 13900001 - Operation not permitted 7943 * @throws { BusinessError } 13900004 - Interrupted system call 7944 * @throws { BusinessError } 13900005 - I/O error 7945 * @throws { BusinessError } 13900008 - Bad file descriptor 7946 * @throws { BusinessError } 13900010 - Try again 7947 * @throws { BusinessError } 13900013 - Bad address 7948 * @throws { BusinessError } 13900020 - Invalid argument 7949 * @throws { BusinessError } 13900024 - File too large 7950 * @throws { BusinessError } 13900025 - No space left on device 7951 * @throws { BusinessError } 13900034 - Operation would block 7952 * @throws { BusinessError } 13900041 - Quota exceeded 7953 * @throws { BusinessError } 13900042 - Unknown error 7954 * @syscap SystemCapability.FileManagement.File.FileIO 7955 * @crossplatform 7956 * @since 10 7957 */ 7958/** 7959 * Writes data to a file. This API returns the result synchronously. 7960 * 7961 * @param { number } fd - FD of the file. 7962 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 7963 * @param { WriteOptions } [options] - The options are as follows: 7964 * <br>length (number): length of the data to write. This parameter is optional. The default value is the buffer length. 7965 * <br>offset (number): start position to write the data in the file. This parameter is optional. 7966 * <br>By default, data is written from the current position. 7967 * <br>encoding (string): format of the data to be encoded when the data is a string. 7968 * <br>The default value is 'utf-8', which is the only value supported. 7969 * @returns { number } Length of the data written, in bytes. 7970 * @throws { BusinessError } 13900001 - Operation not permitted 7971 * @throws { BusinessError } 13900004 - Interrupted system call 7972 * @throws { BusinessError } 13900005 - I/O error 7973 * @throws { BusinessError } 13900008 - Bad file descriptor 7974 * @throws { BusinessError } 13900010 - Try again 7975 * @throws { BusinessError } 13900013 - Bad address 7976 * @throws { BusinessError } 13900020 - Invalid argument 7977 * @throws { BusinessError } 13900024 - File too large 7978 * @throws { BusinessError } 13900025 - No space left on device 7979 * @throws { BusinessError } 13900034 - Operation would block 7980 * @throws { BusinessError } 13900041 - Quota exceeded 7981 * @throws { BusinessError } 13900042 - Unknown error 7982 * @syscap SystemCapability.FileManagement.File.FileIO 7983 * @crossplatform 7984 * @atomicservice 7985 * @since 11 7986 */ 7987declare function writeSync( 7988 fd: number, 7989 buffer: ArrayBuffer | string, 7990 options?: WriteOptions 7991): number; 7992 7993/** 7994 * Connect Distributed File System. 7995 * 7996 * @permission ohos.permission.DISTRIBUTED_DATASYNC 7997 * @param { string } networkId - The networkId of device. 7998 * @param { DfsListeners } listeners - The listeners of Distributed File System. 7999 * @returns { Promise<void> } The promise returned by the function. 8000 * @throws { BusinessError } 201 - Permission denied. 8001 * @throws { BusinessError } 401 - The parameter check failed.Possible causes:1.Mandatory parameters are left unspecified; 8002 * <br>2.Incorrect parameter types. 8003 * @throws { BusinessError } 13900045 - Connection failed. 8004 * @throws { BusinessError } 13900046 - Software caused connection abort. 8005 * @syscap SystemCapability.FileManagement.File.FileIO 8006 * @since 12 8007 */ 8008declare function connectDfs(networkId: string, listeners: DfsListeners): Promise<void>; 8009 8010/** 8011 * Disconnect Distributed File System. 8012 * 8013 * @permission ohos.permission.DISTRIBUTED_DATASYNC 8014 * @param { string } networkId - The networkId of device. 8015 * @returns { Promise<void> } The promise returned by the function. 8016 * @throws { BusinessError } 201 - Permission denied. 8017 * @throws { BusinessError } 401 - The parameter check failed.Possible causes:1.Mandatory parameters are left unspecified; 8018 * <br>2.Incorrect parameter types. 8019 * @throws { BusinessError } 13600004 - Unmount failed. 8020 * @syscap SystemCapability.FileManagement.File.FileIO 8021 * @since 12 8022 */ 8023declare function disconnectDfs(networkId: string): Promise<void>; 8024 8025/** 8026 * Sets an extended attribute of a file or directory. 8027 * 8028 * @param { string } path - Application sandbox path of the directory. 8029 * @param { string } key - Key of the extended attribute to obtain. 8030 * <br>The value is a string of less than 256 bytes and can contain only the user. prefix. 8031 * @param { string } value -Value of the extended attribute to set. 8032 * @returns { Promise<void> } Promise that returns no value. 8033 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 8034 * <br>2.Incorrect parameter types. 8035 * @throws { BusinessError } 13900002 - No such file or directory 8036 * @throws { BusinessError } 13900011 - Out of memory 8037 * @throws { BusinessError } 13900012 - Permission denied 8038 * @throws { BusinessError } 13900020 - Invalid argument 8039 * @throws { BusinessError } 13900025 - No space left on device 8040 * @throws { BusinessError } 13900031 - Function not implemented 8041 * @throws { BusinessError } 13900038 - Value too large for defined data type 8042 * @throws { BusinessError } 13900041 - Quota exceeded 8043 * @throws { BusinessError } 13900042 - Unknown error 8044 * @syscap SystemCapability.FileManagement.File.FileIO 8045 * @since 12 8046 */ 8047/** 8048 * Sets an extended attribute of a file or directory. 8049 * 8050 * @param { string } path - Application sandbox path of the directory. 8051 * @param { string } key - Key of the extended attribute to obtain. 8052 * <br>The value is a string of less than 256 bytes and can contain only the user. prefix. 8053 * @param { string } value -Value of the extended attribute to set. 8054 * @returns { Promise<void> } Promise that returns no value. 8055 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 8056 * <br>2.Incorrect parameter types. 8057 * @throws { BusinessError } 13900002 - No such file or directory 8058 * @throws { BusinessError } 13900011 - Out of memory 8059 * @throws { BusinessError } 13900012 - Permission denied 8060 * @throws { BusinessError } 13900020 - Invalid argument 8061 * @throws { BusinessError } 13900025 - No space left on device 8062 * @throws { BusinessError } 13900031 - Function not implemented 8063 * @throws { BusinessError } 13900038 - Value too large for defined data type 8064 * @throws { BusinessError } 13900041 - Quota exceeded 8065 * @throws { BusinessError } 13900042 - Unknown error 8066 * @syscap SystemCapability.FileManagement.File.FileIO 8067 * @crossplatform 8068 * @since 20 8069 */ 8070declare function setxattr(path: string, key: string, value: string): Promise<void>; 8071 8072/** 8073 * Sets an extended attribute of a file or directory. 8074 * 8075 * @param { string } path - Application sandbox path of the directory. 8076 * @param { string } key - Key of the extended attribute to obtain. 8077 * <br>The value is a string of less than 256 bytes and can contain only the user. prefix. 8078 * @param { string } value - Value of the extended attribute to set. 8079 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 8080 * <br>2.Incorrect parameter types. 8081 * @throws { BusinessError } 13900002 - No such file or directory 8082 * @throws { BusinessError } 13900011 - Out of memory 8083 * @throws { BusinessError } 13900012 - Permission denied 8084 * @throws { BusinessError } 13900020 - Invalid argument 8085 * @throws { BusinessError } 13900025 - No space left on device 8086 * @throws { BusinessError } 13900031 - Function not implemented 8087 * @throws { BusinessError } 13900038 - Value too large for defined data type 8088 * @throws { BusinessError } 13900041 - Quota exceeded 8089 * @throws { BusinessError } 13900042 - Unknown error 8090 * @syscap SystemCapability.FileManagement.File.FileIO 8091 * @since 12 8092 */ 8093/** 8094 * Sets an extended attribute of a file or directory. 8095 * 8096 * @param { string } path - Application sandbox path of the directory. 8097 * @param { string } key - Key of the extended attribute to obtain. 8098 * <br>The value is a string of less than 256 bytes and can contain only the user. prefix. 8099 * @param { string } value - Value of the extended attribute to set. 8100 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 8101 * <br>2.Incorrect parameter types. 8102 * @throws { BusinessError } 13900002 - No such file or directory 8103 * @throws { BusinessError } 13900011 - Out of memory 8104 * @throws { BusinessError } 13900012 - Permission denied 8105 * @throws { BusinessError } 13900020 - Invalid argument 8106 * @throws { BusinessError } 13900025 - No space left on device 8107 * @throws { BusinessError } 13900031 - Function not implemented 8108 * @throws { BusinessError } 13900038 - Value too large for defined data type 8109 * @throws { BusinessError } 13900041 - Quota exceeded 8110 * @throws { BusinessError } 13900042 - Unknown error 8111 * @syscap SystemCapability.FileManagement.File.FileIO 8112 * @crossplatform 8113 * @since 20 8114 */ 8115declare function setxattrSync(path: string, key: string, value: string): void; 8116 8117/** 8118 * Obtains an extended attribute of a file or directory. 8119 * 8120 * @param { string } path - Application sandbox path of the directory. 8121 * @param { string } key - Key of the extended attribute to obtain. 8122 * @returns { Promise<string> } Promise used to return the value of the extended attribute obtained. 8123 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 8124 * <br>2.Incorrect parameter types. 8125 * @throws { BusinessError } 13900002 - No such file or directory 8126 * @throws { BusinessError } 13900007 - Arg list too long 8127 * @throws { BusinessError } 13900012 - Permission denied 8128 * @throws { BusinessError } 13900031 - Function not implemented 8129 * @throws { BusinessError } 13900037 - No data available 8130 * @throws { BusinessError } 13900038 - Value too large for defined data type 8131 * @throws { BusinessError } 13900042 - Unknown error 8132 * @syscap SystemCapability.FileManagement.File.FileIO 8133 * @since 12 8134 */ 8135/** 8136 * Obtains an extended attribute of a file or directory. 8137 * 8138 * @param { string } path - Application sandbox path of the directory. 8139 * @param { string } key - Key of the extended attribute to obtain. 8140 * @returns { Promise<string> } Promise used to return the value of the extended attribute obtained. 8141 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 8142 * <br>2.Incorrect parameter types. 8143 * @throws { BusinessError } 13900002 - No such file or directory 8144 * @throws { BusinessError } 13900007 - Arg list too long 8145 * @throws { BusinessError } 13900012 - Permission denied 8146 * @throws { BusinessError } 13900031 - Function not implemented 8147 * @throws { BusinessError } 13900037 - No data available 8148 * @throws { BusinessError } 13900038 - Value too large for defined data type 8149 * @throws { BusinessError } 13900042 - Unknown error 8150 * @syscap SystemCapability.FileManagement.File.FileIO 8151 * @crossplatform 8152 * @since 20 8153 */ 8154declare function getxattr(path: string, key: string): Promise<string>; 8155 8156/** 8157 * Obtains an extended attribute of a file. This API returns the result synchronously. 8158 * 8159 * @param { string } path - Application sandbox path of the directory. 8160 * @param { string } key - Key of the extended attribute to obtain. 8161 * @returns { string } Value of the extended attribute obtained. 8162 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 8163 * <br>2.Incorrect parameter types. 8164 * @throws { BusinessError } 13900002 - No such file or directory 8165 * @throws { BusinessError } 13900007 - Arg list too long 8166 * @throws { BusinessError } 13900012 - Permission denied 8167 * @throws { BusinessError } 13900031 - Function not implemented 8168 * @throws { BusinessError } 13900037 - No data available 8169 * @throws { BusinessError } 13900038 - Value too large for defined data type 8170 * @throws { BusinessError } 13900042 - Unknown error 8171 * @syscap SystemCapability.FileManagement.File.FileIO 8172 * @since 12 8173 */ 8174/** 8175 * Obtains an extended attribute of a file. This API returns the result synchronously. 8176 * 8177 * @param { string } path - Application sandbox path of the directory. 8178 * @param { string } key - Key of the extended attribute to obtain. 8179 * @returns { string } Value of the extended attribute obtained. 8180 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 8181 * <br>2.Incorrect parameter types. 8182 * @throws { BusinessError } 13900002 - No such file or directory 8183 * @throws { BusinessError } 13900007 - Arg list too long 8184 * @throws { BusinessError } 13900012 - Permission denied 8185 * @throws { BusinessError } 13900031 - Function not implemented 8186 * @throws { BusinessError } 13900037 - No data available 8187 * @throws { BusinessError } 13900038 - Value too large for defined data type 8188 * @throws { BusinessError } 13900042 - Unknown error 8189 * @syscap SystemCapability.FileManagement.File.FileIO 8190 * @crossplatform 8191 * @since 20 8192 */ 8193declare function getxattrSync(path: string, key: string): string; 8194 8195/** 8196 * Defines the copy progress information. 8197 * 8198 * @typedef Progress 8199 * @syscap SystemCapability.FileManagement.File.FileIO 8200 * @since 11 8201 */ 8202interface Progress { 8203 /** 8204 * Size of the copied data. 8205 * 8206 * @type { number } 8207 * @readonly 8208 * @syscap SystemCapability.FileManagement.File.FileIO 8209 * @since 11 8210 */ 8211 readonly processedSize: number; 8212 8213 /** 8214 * Total size of the data to be copied. 8215 * 8216 * @type { number } 8217 * @readonly 8218 * @syscap SystemCapability.FileManagement.File.FileIO 8219 * @since 11 8220 */ 8221 readonly totalSize: number; 8222} 8223 8224/** 8225 * Provides APIs for interrupting a copy task. 8226 * 8227 * @syscap SystemCapability.FileManagement.File.FileIO 8228 * @since 12 8229 */ 8230export class TaskSignal { 8231 /** 8232 * Cancels a copy task. 8233 * 8234 * @throws { BusinessError } 13900010 - Try again 8235 * @throws { BusinessError } 13900012 - Permission denied by the file system 8236 * @throws { BusinessError } 13900043 - No task can be canceled. 8237 * @syscap SystemCapability.FileManagement.File.FileIO 8238 * @since 12 8239 */ 8240 cancel(): void; 8241 8242 /** 8243 * Subscribes to the event reported when a copy task is canceled. 8244 * 8245 * @returns { Promise<string> } Return the result of the cancel event. 8246 * @throws { BusinessError } 13900004 - Interrupted system call 8247 * @throws { BusinessError } 13900008 - Bad file descriptor 8248 * @throws { BusinessError } 13900042 - Unknown error 8249 * @syscap SystemCapability.FileManagement.File.FileIO 8250 * @since 12 8251 */ 8252 onCancel(): Promise<string>; 8253} 8254 8255/** 8256 * Defines the callback for listening for the copy progress. 8257 * 8258 * @typedef CopyOptions 8259 * @syscap SystemCapability.FileManagement.File.FileIO 8260 * @since 11 8261 */ 8262interface CopyOptions { 8263 /** 8264 * Listener used to observe the copy progress. 8265 * 8266 * @type { ?ProgressListener } 8267 * @syscap SystemCapability.FileManagement.File.FileIO 8268 * @since 11 8269 */ 8270 progressListener?: ProgressListener; 8271 /** 8272 * Signal used to cancel a copy task. 8273 * 8274 * @type { ?TaskSignal } 8275 * @syscap SystemCapability.FileManagement.File.FileIO 8276 * @since 12 8277 */ 8278 copySignal?: TaskSignal; 8279} 8280 8281/** 8282 * Signal used to cancel a copy task. 8283 * 8284 * @typedef { function } ProgressListener 8285 * @param { Progress } progress - indicates the progress data of copyFile 8286 * @syscap SystemCapability.FileManagement.File.FileIO 8287 * @since 11 8288 */ 8289type ProgressListener = (progress: Progress) => void; 8290 8291/** 8292 * File object. 8293 * 8294 * @interface File 8295 * @syscap SystemCapability.FileManagement.File.FileIO 8296 * @since 9 8297 */ 8298/** 8299 * File object. 8300 * 8301 * @interface File 8302 * @syscap SystemCapability.FileManagement.File.FileIO 8303 * @crossplatform 8304 * @since 10 8305 */ 8306/** 8307 * Represents a File object opened by open(). 8308 * 8309 * @interface File 8310 * @syscap SystemCapability.FileManagement.File.FileIO 8311 * @crossplatform 8312 * @atomicservice 8313 * @since 11 8314 */ 8315declare interface File { 8316 /** 8317 * @type { number } 8318 * @readonly 8319 * @syscap SystemCapability.FileManagement.File.FileIO 8320 * @since 9 8321 */ 8322 /** 8323 * @type { number } 8324 * @readonly 8325 * @syscap SystemCapability.FileManagement.File.FileIO 8326 * @crossplatform 8327 * @since 10 8328 */ 8329 /** 8330 * FD of the file. 8331 * 8332 * @type { number } 8333 * @readonly 8334 * @syscap SystemCapability.FileManagement.File.FileIO 8335 * @crossplatform 8336 * @atomicservice 8337 * @since 11 8338 */ 8339 readonly fd: number; 8340 8341 /** 8342 * Path of the file. 8343 * 8344 * @type { string } 8345 * @readonly 8346 * @throws { BusinessError } 13900005 - I/O error 8347 * @throws { BusinessError } 13900042 - Unknown error 8348 * @throws { BusinessError } 14300002 - Invalid URI 8349 * @syscap SystemCapability.FileManagement.File.FileIO 8350 * @since 10 8351 */ 8352 readonly path: string; 8353 8354 /** 8355 * Name of the file. 8356 * 8357 * @type { string } 8358 * @readonly 8359 * @throws { BusinessError } 13900005 - I/O error 8360 * @throws { BusinessError } 13900042 - Unknown error 8361 * @syscap SystemCapability.FileManagement.File.FileIO 8362 * @since 10 8363 */ 8364 readonly name: string; 8365 8366 /** 8367 * Obtains the parent directory of this file object. 8368 * 8369 * @returns { string } Parent directory obtained. 8370 * @throws { BusinessError } 13900005 - I/O error 8371 * @throws { BusinessError } 13900042 - Unknown error 8372 * @throws { BusinessError } 14300002 - Invalid URI 8373 * @syscap SystemCapability.FileManagement.File.FileIO 8374 * @since 11 8375 */ 8376 /** 8377 * Obtains the parent directory of this file object. 8378 * 8379 * @returns { string } Parent directory obtained. 8380 * @throws { BusinessError } 13900005 - I/O error 8381 * @throws { BusinessError } 13900042 - Unknown error 8382 * @throws { BusinessError } 14300002 - Invalid URI 8383 * @syscap SystemCapability.FileManagement.File.FileIO 8384 * @crossplatform 8385 * @since 20 8386 */ 8387 getParent(): string; 8388 8389 /** 8390 * Applies an exclusive lock or a shared lock on this file in blocking mode. 8391 * This API uses a promise to return the result. 8392 * 8393 * @param { boolean } exclusive - Lock to apply. The value true means an exclusive lock, 8394 * <br>and the value false (default) means a shared lock. 8395 * @returns { Promise<void> } Promise that returns no value. 8396 * @throws { BusinessError } 13900004 - Interrupted system call 8397 * @throws { BusinessError } 13900008 - Bad file descriptor 8398 * @throws { BusinessError } 13900020 - Invalid argument 8399 * @throws { BusinessError } 13900034 - Operation would block 8400 * @throws { BusinessError } 13900042 - Unknown error 8401 * @throws { BusinessError } 13900043 - No record locks available 8402 * @syscap SystemCapability.FileManagement.File.FileIO 8403 * @since 9 8404 */ 8405 lock(exclusive?: boolean): Promise<void>; 8406 8407 /** 8408 * Applies an exclusive lock or a shared lock on this file in blocking mode. 8409 * This API uses an asynchronous callback to return the result. 8410 * 8411 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8412 * @throws { BusinessError } 13900004 - Interrupted system call 8413 * @throws { BusinessError } 13900008 - Bad file descriptor 8414 * @throws { BusinessError } 13900020 - Invalid argument 8415 * @throws { BusinessError } 13900034 - Operation would block 8416 * @throws { BusinessError } 13900042 - Unknown error 8417 * @throws { BusinessError } 13900043 - No record locks available 8418 * @syscap SystemCapability.FileManagement.File.FileIO 8419 * @since 9 8420 */ 8421 lock(callback: AsyncCallback<void>): void; 8422 8423 /** 8424 * Applies an exclusive lock or a shared lock on this file in blocking mode. 8425 * This API uses an asynchronous callback to return the result. 8426 * 8427 * @param { boolean } exclusive - Lock to apply. The value true means an exclusive lock, 8428 * <br>and the value false (default) means a shared lock. 8429 * @param { AsyncCallback<void> } callback - Callback used to return the result. 8430 * @throws { BusinessError } 13900004 - Interrupted system call 8431 * @throws { BusinessError } 13900008 - Bad file descriptor 8432 * @throws { BusinessError } 13900020 - Invalid argument 8433 * @throws { BusinessError } 13900034 - Operation would block 8434 * @throws { BusinessError } 13900042 - Unknown error 8435 * @throws { BusinessError } 13900043 - No record locks available 8436 * @syscap SystemCapability.FileManagement.File.FileIO 8437 * @since 9 8438 */ 8439 lock(exclusive: boolean, callback: AsyncCallback<void>): void; 8440 8441 /** 8442 * Applies an exclusive lock or a shared lock on this file in non-blocking mode. 8443 * 8444 * @param { boolean } exclusive - Lock to apply. The value true means an exclusive lock, 8445 * <br>and the value false (default) means a shared lock. 8446 * @throws { BusinessError } 13900004 - Interrupted system call 8447 * @throws { BusinessError } 13900008 - Bad file descriptor 8448 * @throws { BusinessError } 13900020 - Invalid argument 8449 * @throws { BusinessError } 13900034 - Operation would block 8450 * @throws { BusinessError } 13900042 - Unknown error 8451 * @throws { BusinessError } 13900043 - No record locks available 8452 * @syscap SystemCapability.FileManagement.File.FileIO 8453 * @since 9 8454 */ 8455 tryLock(exclusive?: boolean): void; 8456 8457 /** 8458 * Unlocks a file. 8459 * 8460 * @throws { BusinessError } 13900004 - Interrupted system call 8461 * @throws { BusinessError } 13900008 - Bad file descriptor 8462 * @throws { BusinessError } 13900020 - Invalid argument 8463 * @throws { BusinessError } 13900034 - Operation would block 8464 * @throws { BusinessError } 13900042 - Unknown error 8465 * @throws { BusinessError } 13900043 - No record locks available 8466 * @syscap SystemCapability.FileManagement.File.FileIO 8467 * @since 9 8468 */ 8469 unlock(): void; 8470} 8471 8472/** 8473 * Provides APIs for randomly reading and writing a stream. Before invoking any API of RandomAccessFile, 8474 * you need to use createRandomAccessFile() to create a RandomAccessFile instance synchronously or asynchronously 8475 * 8476 * @interface RandomAccessFile 8477 * @syscap SystemCapability.FileManagement.File.FileIO 8478 * @since 10 8479 */ 8480/** 8481 * Provides APIs for randomly reading and writing a stream. Before invoking any API of RandomAccessFile, 8482 * you need to use createRandomAccessFile() to create a RandomAccessFile instance synchronously or asynchronously 8483 * 8484 * @interface RandomAccessFile 8485 * @syscap SystemCapability.FileManagement.File.FileIO 8486 * @crossplatform 8487 * @since 20 8488 */ 8489declare interface RandomAccessFile { 8490 8491 /** 8492 * FD of the file. 8493 * 8494 * @type { number } 8495 * @readonly 8496 * @syscap SystemCapability.FileManagement.File.FileIO 8497 * @since 10 8498 */ 8499 /** 8500 * FD of the file. 8501 * 8502 * @type { number } 8503 * @readonly 8504 * @syscap SystemCapability.FileManagement.File.FileIO 8505 * @crossplatform 8506 * @since 20 8507 */ 8508 readonly fd: number; 8509 8510 /** 8511 * Offset pointer to the RandomAccessFile instance. 8512 * 8513 * @type { number } 8514 * @readonly 8515 * @syscap SystemCapability.FileManagement.File.FileIO 8516 * @since 10 8517 */ 8518 /** 8519 * Offset pointer to the RandomAccessFile instance. 8520 * 8521 * @type { number } 8522 * @readonly 8523 * @syscap SystemCapability.FileManagement.File.FileIO 8524 * @crossplatform 8525 * @since 20 8526 */ 8527 readonly filePointer: number; 8528 8529 /** 8530 * Sets the file offset pointer. 8531 * 8532 * @param { number } filePointer - Offset pointer to the RandomAccessFile instance. 8533 * @throws { BusinessError } 13900004 - Interrupted system call 8534 * @throws { BusinessError } 13900005 - I/O error 8535 * @throws { BusinessError } 13900008 - Bad file descriptor 8536 * @throws { BusinessError } 13900020 - Invalid argument 8537 * @throws { BusinessError } 13900042 - Unknown error 8538 * @syscap SystemCapability.FileManagement.File.FileIO 8539 * @since 10 8540 */ 8541 /** 8542 * Sets the file offset pointer. 8543 * 8544 * @param { number } filePointer - Offset pointer to the RandomAccessFile instance. 8545 * @throws { BusinessError } 13900004 - Interrupted system call 8546 * @throws { BusinessError } 13900005 - I/O error 8547 * @throws { BusinessError } 13900008 - Bad file descriptor 8548 * @throws { BusinessError } 13900020 - Invalid argument 8549 * @throws { BusinessError } 13900042 - Unknown error 8550 * @syscap SystemCapability.FileManagement.File.FileIO 8551 * @crossplatform 8552 * @since 20 8553 */ 8554 setFilePointer(filePointer: number): void; 8555 8556 /** 8557 * Closes this RandomAccessFile instance. This API returns the result synchronously. 8558 * 8559 * @throws { BusinessError } 13900004 - Interrupted system call 8560 * @throws { BusinessError } 13900005 - I/O error 8561 * @throws { BusinessError } 13900008 - Bad file descriptor 8562 * @throws { BusinessError } 13900025 - No space left on device 8563 * @throws { BusinessError } 13900041 - Quota exceeded 8564 * @throws { BusinessError } 13900042 - Unknown error 8565 * @syscap SystemCapability.FileManagement.File.FileIO 8566 * @since 10 8567 */ 8568 /** 8569 * Closes this RandomAccessFile instance. This API returns the result synchronously. 8570 * 8571 * @throws { BusinessError } 13900004 - Interrupted system call 8572 * @throws { BusinessError } 13900005 - I/O error 8573 * @throws { BusinessError } 13900008 - Bad file descriptor 8574 * @throws { BusinessError } 13900025 - No space left on device 8575 * @throws { BusinessError } 13900041 - Quota exceeded 8576 * @throws { BusinessError } 13900042 - Unknown error 8577 * @syscap SystemCapability.FileManagement.File.FileIO 8578 * @crossplatform 8579 * @since 20 8580 */ 8581 close(): void; 8582 8583 /** 8584 * Write randomAccessFile. 8585 * 8586 * @param { ArrayBuffer | string } buffer - buffer. 8587 * @param { object } [options] - options. 8588 * @returns { Promise<number> } Returns the number of bytes written to the file in promise mode. 8589 * @throws { BusinessError } 13900001 - Operation not permitted 8590 * @throws { BusinessError } 13900004 - Interrupted system call 8591 * @throws { BusinessError } 13900005 - I/O error 8592 * @throws { BusinessError } 13900008 - Bad file descriptor 8593 * @throws { BusinessError } 13900010 - Try again 8594 * @throws { BusinessError } 13900013 - Bad address 8595 * @throws { BusinessError } 13900020 - Invalid argument 8596 * @throws { BusinessError } 13900024 - File too large 8597 * @throws { BusinessError } 13900025 - No space left on device 8598 * @throws { BusinessError } 13900034 - Operation would block 8599 * @throws { BusinessError } 13900041 - Quota exceeded 8600 * @throws { BusinessError } 13900042 - Unknown error 8601 * @syscap SystemCapability.FileManagement.File.FileIO 8602 * @since 10 8603 */ 8604 /** 8605 * Writes data into a file. This API uses a promise to return the result. 8606 * 8607 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 8608 * @param { WriteOptions } [options] - The options are as follows: 8609 * <br>length (number): length of the data to write. The default value is the buffer length. 8610 * <br>offset (number): start position to write the data (it is determined by filePointer plus offset). 8611 * <br>This parameter is optional. By default, data is written from the filePointer. 8612 * <br>encoding (string): format of the data to be encoded when the data is a string. 8613 * <br>The default value is 'utf-8', which is the only value supported. 8614 * @returns { Promise<number> } Returns the number of bytes written to the file in promise mode. 8615 * @throws { BusinessError } 13900001 - Operation not permitted 8616 * @throws { BusinessError } 13900004 - Interrupted system call 8617 * @throws { BusinessError } 13900005 - I/O error 8618 * @throws { BusinessError } 13900008 - Bad file descriptor 8619 * @throws { BusinessError } 13900010 - Try again 8620 * @throws { BusinessError } 13900013 - Bad address 8621 * @throws { BusinessError } 13900020 - Invalid argument 8622 * @throws { BusinessError } 13900024 - File too large 8623 * @throws { BusinessError } 13900025 - No space left on device 8624 * @throws { BusinessError } 13900034 - Operation would block 8625 * @throws { BusinessError } 13900041 - Quota exceeded 8626 * @throws { BusinessError } 13900042 - Unknown error 8627 * @syscap SystemCapability.FileManagement.File.FileIO 8628 * @since 11 8629 */ 8630 /** 8631 * Writes data into a file. This API uses a promise to return the result. 8632 * 8633 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 8634 * @param { WriteOptions } [options] - The options are as follows: 8635 * <br>length (number): length of the data to write. The default value is the buffer length. 8636 * <br>offset (number): start position to write the data (it is determined by filePointer plus offset). 8637 * <br>This parameter is optional. By default, data is written from the filePointer. 8638 * <br>encoding (string): format of the data to be encoded when the data is a string. 8639 * <br>The default value is 'utf-8', which is the only value supported. 8640 * @returns { Promise<number> } Returns the number of bytes written to the file in promise mode. 8641 * @throws { BusinessError } 13900001 - Operation not permitted 8642 * @throws { BusinessError } 13900004 - Interrupted system call 8643 * @throws { BusinessError } 13900005 - I/O error 8644 * @throws { BusinessError } 13900008 - Bad file descriptor 8645 * @throws { BusinessError } 13900010 - Try again 8646 * @throws { BusinessError } 13900013 - Bad address 8647 * @throws { BusinessError } 13900020 - Invalid argument 8648 * @throws { BusinessError } 13900024 - File too large 8649 * @throws { BusinessError } 13900025 - No space left on device 8650 * @throws { BusinessError } 13900034 - Operation would block 8651 * @throws { BusinessError } 13900041 - Quota exceeded 8652 * @throws { BusinessError } 13900042 - Unknown error 8653 * @syscap SystemCapability.FileManagement.File.FileIO 8654 * @crossplatform 8655 * @since 20 8656 */ 8657 write( 8658 buffer: ArrayBuffer | string, 8659 options?: WriteOptions 8660 ): Promise<number>; 8661 8662 /** 8663 * Writes data to a file. This API uses an asynchronous callback to return the result. 8664 * 8665 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 8666 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8667 * @throws { BusinessError } 13900001 - Operation not permitted 8668 * @throws { BusinessError } 13900004 - Interrupted system call 8669 * @throws { BusinessError } 13900005 - I/O error 8670 * @throws { BusinessError } 13900008 - Bad file descriptor 8671 * @throws { BusinessError } 13900010 - Try again 8672 * @throws { BusinessError } 13900013 - Bad address 8673 * @throws { BusinessError } 13900020 - Invalid argument 8674 * @throws { BusinessError } 13900024 - File too large 8675 * @throws { BusinessError } 13900025 - No space left on device 8676 * @throws { BusinessError } 13900034 - Operation would block 8677 * @throws { BusinessError } 13900041 - Quota exceeded 8678 * @throws { BusinessError } 13900042 - Unknown error 8679 * @syscap SystemCapability.FileManagement.File.FileIO 8680 * @since 10 8681 */ 8682 /** 8683 * Writes data to a file. This API uses an asynchronous callback to return the result. 8684 * 8685 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 8686 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8687 * @throws { BusinessError } 13900001 - Operation not permitted 8688 * @throws { BusinessError } 13900004 - Interrupted system call 8689 * @throws { BusinessError } 13900005 - I/O error 8690 * @throws { BusinessError } 13900008 - Bad file descriptor 8691 * @throws { BusinessError } 13900010 - Try again 8692 * @throws { BusinessError } 13900013 - Bad address 8693 * @throws { BusinessError } 13900020 - Invalid argument 8694 * @throws { BusinessError } 13900024 - File too large 8695 * @throws { BusinessError } 13900025 - No space left on device 8696 * @throws { BusinessError } 13900034 - Operation would block 8697 * @throws { BusinessError } 13900041 - Quota exceeded 8698 * @throws { BusinessError } 13900042 - Unknown error 8699 * @syscap SystemCapability.FileManagement.File.FileIO 8700 * @crossplatform 8701 * @since 20 8702 */ 8703 write(buffer: ArrayBuffer | string, callback: AsyncCallback<number>): void; 8704 8705 /** 8706 * Write randomAccessFile. 8707 * 8708 * @param { ArrayBuffer | string } buffer - buffer. 8709 * @param { object } [options] - options. 8710 * @param { AsyncCallback<number> } callback - The callback is used to return the number of bytes written to the file. 8711 * @throws { BusinessError } 13900001 - Operation not permitted 8712 * @throws { BusinessError } 13900004 - Interrupted system call 8713 * @throws { BusinessError } 13900005 - I/O error 8714 * @throws { BusinessError } 13900008 - Bad file descriptor 8715 * @throws { BusinessError } 13900010 - Try again 8716 * @throws { BusinessError } 13900013 - Bad address 8717 * @throws { BusinessError } 13900020 - Invalid argument 8718 * @throws { BusinessError } 13900024 - File too large 8719 * @throws { BusinessError } 13900025 - No space left on device 8720 * @throws { BusinessError } 13900034 - Operation would block 8721 * @throws { BusinessError } 13900041 - Quota exceeded 8722 * @throws { BusinessError } 13900042 - Unknown error 8723 * @syscap SystemCapability.FileManagement.File.FileIO 8724 * @since 10 8725 */ 8726 /** 8727 * Writes data to a file. This API uses an asynchronous callback to return the result. 8728 * 8729 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 8730 * @param { WriteOptions } [options] - The options are as follows: 8731 * <br>length (number): length of the data to write. The default value is the buffer length. 8732 * <br>offset (number): start position to write the data (it is determined by filePointer plus offset). 8733 * <br>This parameter is optional. By default, data is written from the filePointer. 8734 * <br>encoding (string): format of the data to be encoded when the data is a string. 8735 * <br>The default value is 'utf-8', which is the only value supported. 8736 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8737 * @throws { BusinessError } 13900001 - Operation not permitted 8738 * @throws { BusinessError } 13900004 - Interrupted system call 8739 * @throws { BusinessError } 13900005 - I/O error 8740 * @throws { BusinessError } 13900008 - Bad file descriptor 8741 * @throws { BusinessError } 13900010 - Try again 8742 * @throws { BusinessError } 13900013 - Bad address 8743 * @throws { BusinessError } 13900020 - Invalid argument 8744 * @throws { BusinessError } 13900024 - File too large 8745 * @throws { BusinessError } 13900025 - No space left on device 8746 * @throws { BusinessError } 13900034 - Operation would block 8747 * @throws { BusinessError } 13900041 - Quota exceeded 8748 * @throws { BusinessError } 13900042 - Unknown error 8749 * @syscap SystemCapability.FileManagement.File.FileIO 8750 * @since 11 8751 */ 8752 /** 8753 * Writes data to a file. This API uses an asynchronous callback to return the result. 8754 * 8755 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 8756 * @param { WriteOptions } [options] - The options are as follows: 8757 * <br>length (number): length of the data to write. The default value is the buffer length. 8758 * <br>offset (number): start position to write the data (it is determined by filePointer plus offset). 8759 * <br>This parameter is optional. By default, data is written from the filePointer. 8760 * <br>encoding (string): format of the data to be encoded when the data is a string. 8761 * <br>The default value is 'utf-8', which is the only value supported. 8762 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8763 * @throws { BusinessError } 13900001 - Operation not permitted 8764 * @throws { BusinessError } 13900004 - Interrupted system call 8765 * @throws { BusinessError } 13900005 - I/O error 8766 * @throws { BusinessError } 13900008 - Bad file descriptor 8767 * @throws { BusinessError } 13900010 - Try again 8768 * @throws { BusinessError } 13900013 - Bad address 8769 * @throws { BusinessError } 13900020 - Invalid argument 8770 * @throws { BusinessError } 13900024 - File too large 8771 * @throws { BusinessError } 13900025 - No space left on device 8772 * @throws { BusinessError } 13900034 - Operation would block 8773 * @throws { BusinessError } 13900041 - Quota exceeded 8774 * @throws { BusinessError } 13900042 - Unknown error 8775 * @syscap SystemCapability.FileManagement.File.FileIO 8776 * @crossplatform 8777 * @since 20 8778 */ 8779 write( 8780 buffer: ArrayBuffer | string, 8781 options: WriteOptions, 8782 callback: AsyncCallback<number> 8783 ): void; 8784 8785 /** 8786 * Write randomAccessFile with sync interface. 8787 * 8788 * @param { ArrayBuffer | string } buffer - buffer. 8789 * @param { object } [options] - options. 8790 * @returns { number } Returns the number of bytes written to the file. 8791 * @throws { BusinessError } 13900001 - Operation not permitted 8792 * @throws { BusinessError } 13900004 - Interrupted system call 8793 * @throws { BusinessError } 13900005 - I/O error 8794 * @throws { BusinessError } 13900008 - Bad file descriptor 8795 * @throws { BusinessError } 13900010 - Try again 8796 * @throws { BusinessError } 13900013 - Bad address 8797 * @throws { BusinessError } 13900020 - Invalid argument 8798 * @throws { BusinessError } 13900024 - File too large 8799 * @throws { BusinessError } 13900025 - No space left on device 8800 * @throws { BusinessError } 13900034 - Operation would block 8801 * @throws { BusinessError } 13900041 - Quota exceeded 8802 * @throws { BusinessError } 13900042 - Unknown error 8803 * @syscap SystemCapability.FileManagement.File.FileIO 8804 * @since 10 8805 */ 8806 /** 8807 * Writes data to a file. This API returns the result synchronously. 8808 * 8809 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 8810 * @param { WriteOptions } [options] - The options are as follows: 8811 * <br>length (number): length of the data to write. The default value is the buffer length. 8812 * <br>offset (number): start position to write the data (it is determined by filePointer plus offset). 8813 * <br>This parameter is optional. By default, data is written from the filePointer. 8814 * <br>encoding (string): format of the data to be encoded when the data is a string. 8815 * <br>The default value is 'utf-8', which is the only value supported. 8816 * @returns { number } Length of the data written in the file. 8817 * @throws { BusinessError } 13900001 - Operation not permitted 8818 * @throws { BusinessError } 13900004 - Interrupted system call 8819 * @throws { BusinessError } 13900005 - I/O error 8820 * @throws { BusinessError } 13900008 - Bad file descriptor 8821 * @throws { BusinessError } 13900010 - Try again 8822 * @throws { BusinessError } 13900013 - Bad address 8823 * @throws { BusinessError } 13900020 - Invalid argument 8824 * @throws { BusinessError } 13900024 - File too large 8825 * @throws { BusinessError } 13900025 - No space left on device 8826 * @throws { BusinessError } 13900034 - Operation would block 8827 * @throws { BusinessError } 13900041 - Quota exceeded 8828 * @throws { BusinessError } 13900042 - Unknown error 8829 * @syscap SystemCapability.FileManagement.File.FileIO 8830 * @since 11 8831 */ 8832 /** 8833 * Writes data to a file. This API returns the result synchronously. 8834 * 8835 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 8836 * @param { WriteOptions } [options] - The options are as follows: 8837 * <br>length (number): length of the data to write. The default value is the buffer length. 8838 * <br>offset (number): start position to write the data (it is determined by filePointer plus offset). 8839 * <br>This parameter is optional. By default, data is written from the filePointer. 8840 * <br>encoding (string): format of the data to be encoded when the data is a string. 8841 * <br>The default value is 'utf-8', which is the only value supported. 8842 * @returns { number } Length of the data written in the file. 8843 * @throws { BusinessError } 13900001 - Operation not permitted 8844 * @throws { BusinessError } 13900004 - Interrupted system call 8845 * @throws { BusinessError } 13900005 - I/O error 8846 * @throws { BusinessError } 13900008 - Bad file descriptor 8847 * @throws { BusinessError } 13900010 - Try again 8848 * @throws { BusinessError } 13900013 - Bad address 8849 * @throws { BusinessError } 13900020 - Invalid argument 8850 * @throws { BusinessError } 13900024 - File too large 8851 * @throws { BusinessError } 13900025 - No space left on device 8852 * @throws { BusinessError } 13900034 - Operation would block 8853 * @throws { BusinessError } 13900041 - Quota exceeded 8854 * @throws { BusinessError } 13900042 - Unknown error 8855 * @syscap SystemCapability.FileManagement.File.FileIO 8856 * @crossplatform 8857 * @since 20 8858 */ 8859 writeSync( 8860 buffer: ArrayBuffer | string, 8861 options?: WriteOptions 8862 ): number; 8863 8864 /** 8865 * Read randomAccessFile. 8866 * 8867 * @param { ArrayBuffer } buffer - buffer. 8868 * @param { object } [options] - options. 8869 * @returns { Promise<number> } Returns the number of file bytes read to buffer in promise mode. 8870 * @throws { BusinessError } 13900004 - Interrupted system call 8871 * @throws { BusinessError } 13900005 - I/O error 8872 * @throws { BusinessError } 13900008 - Bad file descriptor 8873 * @throws { BusinessError } 13900010 - Try again 8874 * @throws { BusinessError } 13900013 - Bad address 8875 * @throws { BusinessError } 13900019 - Is a directory 8876 * @throws { BusinessError } 13900020 - Invalid argument 8877 * @throws { BusinessError } 13900034 - Operation would block 8878 * @throws { BusinessError } 13900042 - Unknown error 8879 * @syscap SystemCapability.FileManagement.File.FileIO 8880 * @since 10 8881 */ 8882 /** 8883 * Read randomAccessFile. 8884 * 8885 * @param { ArrayBuffer } buffer - buffer. 8886 * @param { ReadOptions } [options] - options. 8887 * @returns { Promise<number> } Returns the number of file bytes read to buffer in promise mode. 8888 * @throws { BusinessError } 13900004 - Interrupted system call 8889 * @throws { BusinessError } 13900005 - I/O error 8890 * @throws { BusinessError } 13900008 - Bad file descriptor 8891 * @throws { BusinessError } 13900010 - Try again 8892 * @throws { BusinessError } 13900013 - Bad address 8893 * @throws { BusinessError } 13900019 - Is a directory 8894 * @throws { BusinessError } 13900020 - Invalid argument 8895 * @throws { BusinessError } 13900034 - Operation would block 8896 * @throws { BusinessError } 13900042 - Unknown error 8897 * @syscap SystemCapability.FileManagement.File.FileIO 8898 * @since 11 8899 */ 8900 /** 8901 * Reads data from a file. This API uses a promise to return the result. 8902 * 8903 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 8904 * @param { ReadOptions } [options] - The options are as follows: 8905 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 8906 * <br>offset (number): start position to read the data (it is determined by filePointer plus offset). 8907 * <br>This parameter is optional. By default, data is read from the filePointer. 8908 * @returns { Promise<number> } Promise used to return the data read. 8909 * @throws { BusinessError } 13900004 - Interrupted system call 8910 * @throws { BusinessError } 13900005 - I/O error 8911 * @throws { BusinessError } 13900008 - Bad file descriptor 8912 * @throws { BusinessError } 13900010 - Try again 8913 * @throws { BusinessError } 13900013 - Bad address 8914 * @throws { BusinessError } 13900019 - Is a directory 8915 * @throws { BusinessError } 13900020 - Invalid argument 8916 * @throws { BusinessError } 13900034 - Operation would block 8917 * @throws { BusinessError } 13900042 - Unknown error 8918 * @throws { BusinessError } 13900044 - Network is unreachable 8919 * @syscap SystemCapability.FileManagement.File.FileIO 8920 * @since 12 8921 */ 8922 /** 8923 * Reads data from a file. This API uses a promise to return the result. 8924 * 8925 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 8926 * @param { ReadOptions } [options] - The options are as follows: 8927 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 8928 * <br>offset (number): start position to read the data (it is determined by filePointer plus offset). 8929 * <br>This parameter is optional. By default, data is read from the filePointer. 8930 * @returns { Promise<number> } Promise used to return the data read. 8931 * @throws { BusinessError } 13900004 - Interrupted system call 8932 * @throws { BusinessError } 13900005 - I/O error 8933 * @throws { BusinessError } 13900008 - Bad file descriptor 8934 * @throws { BusinessError } 13900010 - Try again 8935 * @throws { BusinessError } 13900013 - Bad address 8936 * @throws { BusinessError } 13900019 - Is a directory 8937 * @throws { BusinessError } 13900020 - Invalid argument 8938 * @throws { BusinessError } 13900034 - Operation would block 8939 * @throws { BusinessError } 13900042 - Unknown error 8940 * @throws { BusinessError } 13900044 - Network is unreachable 8941 * @syscap SystemCapability.FileManagement.File.FileIO 8942 * @crossplatform 8943 * @since 20 8944 */ 8945 read( 8946 buffer: ArrayBuffer, 8947 options?: ReadOptions 8948 ): Promise<number>; 8949 8950 /** 8951 * Reads data from a file. This API uses an asynchronous callback to return the result. 8952 * 8953 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 8954 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8955 * @throws { BusinessError } 13900004 - Interrupted system call 8956 * @throws { BusinessError } 13900005 - I/O error 8957 * @throws { BusinessError } 13900008 - Bad file descriptor 8958 * @throws { BusinessError } 13900010 - Try again 8959 * @throws { BusinessError } 13900013 - Bad address 8960 * @throws { BusinessError } 13900019 - Is a directory 8961 * @throws { BusinessError } 13900020 - Invalid argument 8962 * @throws { BusinessError } 13900034 - Operation would block 8963 * @throws { BusinessError } 13900042 - Unknown error 8964 * @syscap SystemCapability.FileManagement.File.FileIO 8965 * @since 10 8966 */ 8967 /** 8968 * Reads data from a file. This API uses an asynchronous callback to return the result. 8969 * 8970 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 8971 * @param { AsyncCallback<number> } callback - Callback used to return the result. 8972 * @throws { BusinessError } 13900004 - Interrupted system call 8973 * @throws { BusinessError } 13900005 - I/O error 8974 * @throws { BusinessError } 13900008 - Bad file descriptor 8975 * @throws { BusinessError } 13900010 - Try again 8976 * @throws { BusinessError } 13900013 - Bad address 8977 * @throws { BusinessError } 13900019 - Is a directory 8978 * @throws { BusinessError } 13900020 - Invalid argument 8979 * @throws { BusinessError } 13900034 - Operation would block 8980 * @throws { BusinessError } 13900042 - Unknown error 8981 * @syscap SystemCapability.FileManagement.File.FileIO 8982 * @crossplatform 8983 * @since 20 8984 */ 8985 read(buffer: ArrayBuffer, callback: AsyncCallback<number>): void; 8986 8987 /** 8988 * Read randomAccessFile. 8989 * 8990 * @param { ArrayBuffer } buffer - buffer. 8991 * @param { object } [options] - options. 8992 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer. 8993 * @throws { BusinessError } 13900004 - Interrupted system call 8994 * @throws { BusinessError } 13900005 - I/O error 8995 * @throws { BusinessError } 13900008 - Bad file descriptor 8996 * @throws { BusinessError } 13900010 - Try again 8997 * @throws { BusinessError } 13900013 - Bad address 8998 * @throws { BusinessError } 13900019 - Is a directory 8999 * @throws { BusinessError } 13900020 - Invalid argument 9000 * @throws { BusinessError } 13900034 - Operation would block 9001 * @throws { BusinessError } 13900042 - Unknown error 9002 * @syscap SystemCapability.FileManagement.File.FileIO 9003 * @since 10 9004 */ 9005 /** 9006 * Reads data from a file. This API uses an asynchronous callback to return the result. 9007 * 9008 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 9009 * @param { ReadOptions } [options] - The options are as follows: 9010 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 9011 * <br>offset (number): start position to read the data (it is determined by filePointer plus offset). 9012 * <br>This parameter is optional. By default, data is read from the filePointer. 9013 * @param { AsyncCallback<number> } callback - Callback used to return the result. 9014 * @throws { BusinessError } 13900004 - Interrupted system call 9015 * @throws { BusinessError } 13900005 - I/O error 9016 * @throws { BusinessError } 13900008 - Bad file descriptor 9017 * @throws { BusinessError } 13900010 - Try again 9018 * @throws { BusinessError } 13900013 - Bad address 9019 * @throws { BusinessError } 13900019 - Is a directory 9020 * @throws { BusinessError } 13900020 - Invalid argument 9021 * @throws { BusinessError } 13900034 - Operation would block 9022 * @throws { BusinessError } 13900042 - Unknown error 9023 * @syscap SystemCapability.FileManagement.File.FileIO 9024 * @since 11 9025 */ 9026 /** 9027 * Reads data from a file. This API uses an asynchronous callback to return the result. 9028 * 9029 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 9030 * @param { ReadOptions } [options] - The options are as follows: 9031 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 9032 * <br>offset (number): start position to read the data (it is determined by filePointer plus offset). 9033 * <br>This parameter is optional. By default, data is read from the filePointer. 9034 * @param { AsyncCallback<number> } callback - Callback used to return the result. 9035 * @throws { BusinessError } 13900004 - Interrupted system call 9036 * @throws { BusinessError } 13900005 - I/O error 9037 * @throws { BusinessError } 13900008 - Bad file descriptor 9038 * @throws { BusinessError } 13900010 - Try again 9039 * @throws { BusinessError } 13900013 - Bad address 9040 * @throws { BusinessError } 13900019 - Is a directory 9041 * @throws { BusinessError } 13900020 - Invalid argument 9042 * @throws { BusinessError } 13900034 - Operation would block 9043 * @throws { BusinessError } 13900042 - Unknown error 9044 * @syscap SystemCapability.FileManagement.File.FileIO 9045 * @crossplatform 9046 * @since 20 9047 */ 9048 read( 9049 buffer: ArrayBuffer, 9050 options: ReadOptions, 9051 callback: AsyncCallback<number> 9052 ): void; 9053 9054 /** 9055 * Read randomAccessFile with sync interface. 9056 * 9057 * @param { ArrayBuffer } buffer - buffer. 9058 * @param { object } [options] - options. 9059 * @returns { number } Returns the number of file bytes read to buffer. 9060 * @throws { BusinessError } 13900004 - Interrupted system call 9061 * @throws { BusinessError } 13900005 - I/O error 9062 * @throws { BusinessError } 13900008 - Bad file descriptor 9063 * @throws { BusinessError } 13900010 - Try again 9064 * @throws { BusinessError } 13900013 - Bad address 9065 * @throws { BusinessError } 13900019 - Is a directory 9066 * @throws { BusinessError } 13900020 - Invalid argument 9067 * @throws { BusinessError } 13900034 - Operation would block 9068 * @throws { BusinessError } 13900042 - Unknown error 9069 * @syscap SystemCapability.FileManagement.File.FileIO 9070 * @since 10 9071 */ 9072 /** 9073 * Read randomAccessFile with sync interface. 9074 * 9075 * @param { ArrayBuffer } buffer - buffer. 9076 * @param { ReadOptions } [options] - options. 9077 * @returns { number } Returns the number of file bytes read to buffer. 9078 * @throws { BusinessError } 13900004 - Interrupted system call 9079 * @throws { BusinessError } 13900005 - I/O error 9080 * @throws { BusinessError } 13900008 - Bad file descriptor 9081 * @throws { BusinessError } 13900010 - Try again 9082 * @throws { BusinessError } 13900013 - Bad address 9083 * @throws { BusinessError } 13900019 - Is a directory 9084 * @throws { BusinessError } 13900020 - Invalid argument 9085 * @throws { BusinessError } 13900034 - Operation would block 9086 * @throws { BusinessError } 13900042 - Unknown error 9087 * @syscap SystemCapability.FileManagement.File.FileIO 9088 * @since 11 9089 */ 9090 /** 9091 * Reads data from a file. This API returns the result synchronously. 9092 * 9093 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 9094 * @param { ReadOptions } [options] - The options are as follows: 9095 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 9096 * <br>offset (number): start position to read the data (it is determined by filePointer plus offset). 9097 * <br>This parameter is optional. By default, data is read from the filePointer. 9098 * @returns { number } Returns the number of file bytes read to buffer. 9099 * @throws { BusinessError } 13900004 - Interrupted system call 9100 * @throws { BusinessError } 13900005 - I/O error 9101 * @throws { BusinessError } 13900008 - Bad file descriptor 9102 * @throws { BusinessError } 13900010 - Try again 9103 * @throws { BusinessError } 13900013 - Bad address 9104 * @throws { BusinessError } 13900019 - Is a directory 9105 * @throws { BusinessError } 13900020 - Invalid argument 9106 * @throws { BusinessError } 13900034 - Operation would block 9107 * @throws { BusinessError } 13900042 - Unknown error 9108 * @throws { BusinessError } 13900044 - Network is unreachable 9109 * @syscap SystemCapability.FileManagement.File.FileIO 9110 * @since 12 9111 */ 9112 /** 9113 * Reads data from a file. This API returns the result synchronously. 9114 * 9115 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 9116 * @param { ReadOptions } [options] - The options are as follows: 9117 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 9118 * <br>offset (number): start position to read the data (it is determined by filePointer plus offset). 9119 * <br>This parameter is optional. By default, data is read from the filePointer. 9120 * @returns { number } Returns the number of file bytes read to buffer. 9121 * @throws { BusinessError } 13900004 - Interrupted system call 9122 * @throws { BusinessError } 13900005 - I/O error 9123 * @throws { BusinessError } 13900008 - Bad file descriptor 9124 * @throws { BusinessError } 13900010 - Try again 9125 * @throws { BusinessError } 13900013 - Bad address 9126 * @throws { BusinessError } 13900019 - Is a directory 9127 * @throws { BusinessError } 13900020 - Invalid argument 9128 * @throws { BusinessError } 13900034 - Operation would block 9129 * @throws { BusinessError } 13900042 - Unknown error 9130 * @throws { BusinessError } 13900044 - Network is unreachable 9131 * @syscap SystemCapability.FileManagement.File.FileIO 9132 * @crossplatform 9133 * @since 20 9134 */ 9135 readSync( 9136 buffer: ArrayBuffer, 9137 options?: ReadOptions 9138 ): number; 9139 9140 /** 9141 * Obtains a ReadStream instance of this RandomAccessFile. 9142 * 9143 * @returns { ReadStream } ReadStream instance obtained. 9144 * @throws { BusinessError } 401 - Parameter error 9145 * @throws { BusinessError } 13900008 - Bad file descriptor 9146 * @throws { BusinessError } 13900011 - Out of memory 9147 * @throws { BusinessError } 13900012 - Permission denied 9148 * @throws { BusinessError } 13900020 - Invalid argument 9149 * @throws { BusinessError } 13900042 - Unknown error 9150 * @syscap SystemCapability.FileManagement.File.FileIO 9151 * @since 12 9152 */ 9153 getReadStream(): ReadStream; 9154 9155 /** 9156 * Obtains a WriteStream instance of this RandomAccessFile. 9157 * 9158 * @returns { WriteStream } WriteStream instance obtained. 9159 * @throws { BusinessError } 401 - Parameter error 9160 * @throws { BusinessError } 13900008 - Bad file descriptor 9161 * @throws { BusinessError } 13900011 - Out of memory 9162 * @throws { BusinessError } 13900012 - Permission denied 9163 * @throws { BusinessError } 13900020 - Invalid argument 9164 * @throws { BusinessError } 13900042 - Unknown error 9165 * @syscap SystemCapability.FileManagement.File.FileIO 9166 * @since 12 9167 */ 9168 getWriteStream(): WriteStream; 9169} 9170 9171/** 9172 * Defines a readable stream. You need to use fs.createReadStream to create a ReadStream instance, 9173 * which is inherited from the stream base class. 9174 * The data obtained by ReadStream is a decoded string. Currently, only the UTF-8 format is supported. 9175 * 9176 * @extends stream.Readable 9177 * @syscap SystemCapability.FileManagement.File.FileIO 9178 * @since 12 9179 */ 9180/** 9181 * Defines a readable stream. You need to use fs.createReadStream to create a ReadStream instance, 9182 * which is inherited from the stream base class. 9183 * The data obtained by ReadStream is a decoded string. Currently, only the UTF-8 format is supported. 9184 * 9185 * @extends stream.Readable 9186 * @syscap SystemCapability.FileManagement.File.FileIO 9187 * @crossplatform 9188 * @since 20 9189 */ 9190declare class ReadStream extends stream.Readable { 9191 /** 9192 * The ReadStream constructor. 9193 * 9194 * @syscap SystemCapability.FileManagement.File.FileIO 9195 * @since 12 9196 */ 9197 /** 9198 * The ReadStream constructor. 9199 * 9200 * @syscap SystemCapability.FileManagement.File.FileIO 9201 * @crossplatform 9202 * @since 20 9203 */ 9204 constructor(); 9205 9206 /** 9207 * Number of bytes read by the readable stream. 9208 * 9209 * @type { number } 9210 * @readonly 9211 * @throws { BusinessError } 13900042 - Unknown error 9212 * @syscap SystemCapability.FileManagement.File.FileIO 9213 * @since 12 9214 */ 9215 /** 9216 * Number of bytes read by the readable stream. 9217 * 9218 * @type { number } 9219 * @readonly 9220 * @throws { BusinessError } 13900042 - Unknown error 9221 * @syscap SystemCapability.FileManagement.File.FileIO 9222 * @crossplatform 9223 * @since 20 9224 */ 9225 readonly bytesRead: number; 9226 9227 /** 9228 * Path of the file corresponding to the readable stream. 9229 * 9230 * @type { string } 9231 * @readonly 9232 * @throws { BusinessError } 13900042 - Unknown error 9233 * @syscap SystemCapability.FileManagement.File.FileIO 9234 * @since 12 9235 */ 9236 /** 9237 * Path of the file corresponding to the readable stream. 9238 * 9239 * @type { string } 9240 * @readonly 9241 * @throws { BusinessError } 13900042 - Unknown error 9242 * @syscap SystemCapability.FileManagement.File.FileIO 9243 * @crossplatform 9244 * @since 20 9245 */ 9246 readonly path: string; 9247 9248 /** 9249 * Adjusts the position of the readable stream offset pointer. 9250 * 9251 * @param { number } offset - Number of bytes to move the offset. 9252 * @param { WhenceType } [whence = WhenceType.SEEK_SET] - Where to start the offset. The default value is SEEK_SET, 9253 * <br>which indicates the beginning of the file. 9254 * @returns { number } Returns the offset relative to starting position of stream. 9255 * @throws { BusinessError } 401 - Parameter error 9256 * @throws { BusinessError } 13900020 - Invalid argument 9257 * @throws { BusinessError } 13900026 - Illegal seek 9258 * @throws { BusinessError } 13900042 - Unknown error 9259 * @syscap SystemCapability.FileManagement.File.FileIO 9260 * @since 12 9261 */ 9262 /** 9263 * Adjusts the position of the readable stream offset pointer. 9264 * 9265 * @param { number } offset - Number of bytes to move the offset. 9266 * @param { WhenceType } [whence = WhenceType.SEEK_SET] - Where to start the offset. The default value is SEEK_SET, 9267 * <br>which indicates the beginning of the file. 9268 * @returns { number } Returns the offset relative to starting position of stream. 9269 * @throws { BusinessError } 401 - Parameter error 9270 * @throws { BusinessError } 13900020 - Invalid argument 9271 * @throws { BusinessError } 13900026 - Illegal seek 9272 * @throws { BusinessError } 13900042 - Unknown error 9273 * @syscap SystemCapability.FileManagement.File.FileIO 9274 * @crossplatform 9275 * @since 20 9276 */ 9277 seek(offset: number, whence?: WhenceType): number; 9278 9279 /** 9280 * Closes this readable stream. 9281 * 9282 * @throws { BusinessError } 13900004 - Interrupted system call 9283 * @throws { BusinessError } 13900005 - I/O error 9284 * @throws { BusinessError } 13900008 - Bad file descriptor 9285 * @throws { BusinessError } 13900025 - No space left on device 9286 * @throws { BusinessError } 13900041 - Quota exceeded 9287 * @throws { BusinessError } 13900042 - Unknown error 9288 * @syscap SystemCapability.FileManagement.File.FileIO 9289 * @since 12 9290 */ 9291 /** 9292 * Closes this readable stream. 9293 * 9294 * @throws { BusinessError } 13900004 - Interrupted system call 9295 * @throws { BusinessError } 13900005 - I/O error 9296 * @throws { BusinessError } 13900008 - Bad file descriptor 9297 * @throws { BusinessError } 13900025 - No space left on device 9298 * @throws { BusinessError } 13900041 - Quota exceeded 9299 * @throws { BusinessError } 13900042 - Unknown error 9300 * @syscap SystemCapability.FileManagement.File.FileIO 9301 * @crossplatform 9302 * @since 20 9303 */ 9304 close(): void; 9305} 9306 9307/** 9308 * Defines a writeable stream. You need to use fs.createWriteStream to create a WriteStream instance, 9309 * which is inherited from the stream base class. 9310 * 9311 * @extends stream.Writable 9312 * @syscap SystemCapability.FileManagement.File.FileIO 9313 * @since 12 9314 */ 9315/** 9316 * Defines a writeable stream. You need to use fs.createWriteStream to create a WriteStream instance, 9317 * which is inherited from the stream base class. 9318 * 9319 * @extends stream.Writable 9320 * @syscap SystemCapability.FileManagement.File.FileIO 9321 * @crossplatform 9322 * @since 20 9323 */ 9324declare class WriteStream extends stream.Writable { 9325 /** 9326 * The WriteStream constructor. 9327 * 9328 * @syscap SystemCapability.FileManagement.File.FileIO 9329 * @since 12 9330 */ 9331 /** 9332 * The WriteStream constructor. 9333 * 9334 * @syscap SystemCapability.FileManagement.File.FileIO 9335 * @crossplatform 9336 * @since 20 9337 */ 9338 constructor(); 9339 9340 /** 9341 * Number of bytes written to the writable stream. 9342 * 9343 * @type { number } 9344 * @readonly 9345 * @throws { BusinessError } 13900042 - Unknown error 9346 * @syscap SystemCapability.FileManagement.File.FileIO 9347 * @since 12 9348 */ 9349 /** 9350 * Number of bytes written to the writable stream. 9351 * 9352 * @type { number } 9353 * @readonly 9354 * @throws { BusinessError } 13900042 - Unknown error 9355 * @syscap SystemCapability.FileManagement.File.FileIO 9356 * @crossplatform 9357 * @since 20 9358 */ 9359 readonly bytesWritten: number; 9360 9361 /** 9362 * Path of the file corresponding to the writeable stream. 9363 * 9364 * @type { string } 9365 * @readonly 9366 * @throws { BusinessError } 13900042 - Unknown error 9367 * @syscap SystemCapability.FileManagement.File.FileIO 9368 * @since 12 9369 */ 9370 /** 9371 * Path of the file corresponding to the writeable stream. 9372 * 9373 * @type { string } 9374 * @readonly 9375 * @throws { BusinessError } 13900042 - Unknown error 9376 * @syscap SystemCapability.FileManagement.File.FileIO 9377 * @crossplatform 9378 * @since 20 9379 */ 9380 readonly path: string; 9381 9382 /** 9383 * Adjusts the position of the writeable stream offset pointer. 9384 * 9385 * @param { number } offset - Number of bytes to move the offset. 9386 * @param { WhenceType } [whence = WhenceType.SEEK_SET] - Where to start the offset. The default value is SEEK_SET, which indicates the beginning of the file. 9387 * @returns { number } Position of the current offset pointer (offset relative to the file header, in bytes). 9388 * @throws { BusinessError } 401 - Parameter error 9389 * @throws { BusinessError } 13900020 - Invalid argument 9390 * @throws { BusinessError } 13900026 - Illegal seek 9391 * @throws { BusinessError } 13900042 - Unknown error 9392 * @syscap SystemCapability.FileManagement.File.FileIO 9393 * @since 12 9394 */ 9395 /** 9396 * Adjusts the position of the writeable stream offset pointer. 9397 * 9398 * @param { number } offset - Number of bytes to move the offset. 9399 * @param { WhenceType } [whence = WhenceType.SEEK_SET] - Where to start the offset. The default value is SEEK_SET, which indicates the beginning of the file. 9400 * @returns { number } Position of the current offset pointer (offset relative to the file header, in bytes). 9401 * @throws { BusinessError } 401 - Parameter error 9402 * @throws { BusinessError } 13900020 - Invalid argument 9403 * @throws { BusinessError } 13900026 - Illegal seek 9404 * @throws { BusinessError } 13900042 - Unknown error 9405 * @syscap SystemCapability.FileManagement.File.FileIO 9406 * @crossplatform 9407 * @since 20 9408 */ 9409 seek(offset: number, whence?: WhenceType): number; 9410 9411 /** 9412 * Closes this writeable stream. 9413 * 9414 * @throws { BusinessError } 13900004 - Interrupted system call 9415 * @throws { BusinessError } 13900005 - I/O error 9416 * @throws { BusinessError } 13900008 - Bad file descriptor 9417 * @throws { BusinessError } 13900025 - No space left on device 9418 * @throws { BusinessError } 13900041 - Quota exceeded 9419 * @throws { BusinessError } 13900042 - Unknown error 9420 * @syscap SystemCapability.FileManagement.File.FileIO 9421 * @since 12 9422 */ 9423 /** 9424 * Closes this writeable stream. 9425 * 9426 * @throws { BusinessError } 13900004 - Interrupted system call 9427 * @throws { BusinessError } 13900005 - I/O error 9428 * @throws { BusinessError } 13900008 - Bad file descriptor 9429 * @throws { BusinessError } 13900025 - No space left on device 9430 * @throws { BusinessError } 13900041 - Quota exceeded 9431 * @throws { BusinessError } 13900042 - Unknown error 9432 * @syscap SystemCapability.FileManagement.File.FileIO 9433 * @crossplatform 9434 * @since 20 9435 */ 9436 close(): void; 9437} 9438 9439/** 9440 * AtomicFile is a class used to perform atomic read and write operations on files. 9441 * A temporary file is written and renamed to the original file location, which ensures file integrity. 9442 * If the write operation fails, the temporary file is deleted without modifying the original file content. 9443 * You can call finishWrite() or failWrite() to write or roll back file content. 9444 * 9445 * @syscap SystemCapability.FileManagement.File.FileIO 9446 * @since 15 9447 */ 9448/** 9449 * AtomicFile is a class used to perform atomic read and write operations on files. 9450 * A temporary file is written and renamed to the original file location, which ensures file integrity. 9451 * If the write operation fails, the temporary file is deleted without modifying the original file content. 9452 * You can call finishWrite() or failWrite() to write or roll back file content. 9453 * 9454 * @syscap SystemCapability.FileManagement.File.FileIO 9455 * @crossplatform 9456 * @since 20 9457 */ 9458export class AtomicFile { 9459 /** 9460 * The AtomicFile constructor. 9461 * 9462 * @param { string } path - Application sandbox path of the file. 9463 * @throws { BusinessError } 401 Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 9464 * @syscap SystemCapability.FileManagement.File.FileIO 9465 * @since 15 9466 */ 9467 /** 9468 * The AtomicFile constructor. 9469 * 9470 * @param { string } path - Application sandbox path of the file. 9471 * @throws { BusinessError } 401 Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 9472 * @syscap SystemCapability.FileManagement.File.FileIO 9473 * @crossplatform 9474 * @since 20 9475 */ 9476 constructor(path: string); 9477 9478 /** 9479 * Obtains the file object through the AtomicFile object. The FD needs to be closed by calling close(). 9480 * 9481 * @returns { File } Returns the file object. 9482 * @throws { BusinessError } 13900002 No such file or directory 9483 * @throws { BusinessError } 13900005 IO error 9484 * @throws { BusinessError } 13900012 Permission denied 9485 * @throws { BusinessError } 13900042 Internal error 9486 * @syscap SystemCapability.FileManagement.File.FileIO 9487 * @since 15 9488 */ 9489 /** 9490 * Obtains the file object through the AtomicFile object. The FD needs to be closed by calling close(). 9491 * 9492 * @returns { File } Returns the file object. 9493 * @throws { BusinessError } 13900002 No such file or directory 9494 * @throws { BusinessError } 13900005 IO error 9495 * @throws { BusinessError } 13900012 Permission denied 9496 * @throws { BusinessError } 13900042 Internal error 9497 * @syscap SystemCapability.FileManagement.File.FileIO 9498 * @crossplatform 9499 * @since 20 9500 */ 9501 getBaseFile(): File; 9502 9503 /** 9504 * Creates a ReadStream instance. 9505 * 9506 * @returns { ReadStream } ReadStream instance obtained. 9507 * @throws { BusinessError } 13900001 Operation not permitted 9508 * @throws { BusinessError } 13900002 No such file or directory 9509 * @throws { BusinessError } 13900012 Permission denied 9510 * @throws { BusinessError } 13900042 Internal error 9511 * @syscap SystemCapability.FileManagement.File.FileIO 9512 * @since 15 9513 */ 9514 /** 9515 * Creates a ReadStream instance. 9516 * 9517 * @returns { ReadStream } ReadStream instance obtained. 9518 * @throws { BusinessError } 13900001 Operation not permitted 9519 * @throws { BusinessError } 13900002 No such file or directory 9520 * @throws { BusinessError } 13900012 Permission denied 9521 * @throws { BusinessError } 13900042 Internal error 9522 * @syscap SystemCapability.FileManagement.File.FileIO 9523 * @crossplatform 9524 * @since 20 9525 */ 9526 openRead(): ReadStream; 9527 9528 /** 9529 * Reads all content of a file. 9530 * 9531 * @returns { ArrayBuffer } Full content of a file. 9532 * @throws { BusinessError } 13900005 I/O error 9533 * @throws { BusinessError } 13900042 Internal error 9534 * @syscap SystemCapability.FileManagement.File.FileIO 9535 * @since 15 9536 */ 9537 /** 9538 * Reads all content of a file. 9539 * 9540 * @returns { ArrayBuffer } Full content of a file. 9541 * @throws { BusinessError } 13900005 I/O error 9542 * @throws { BusinessError } 13900042 Internal error 9543 * @syscap SystemCapability.FileManagement.File.FileIO 9544 * @crossplatform 9545 * @since 20 9546 */ 9547 readFully(): ArrayBuffer; 9548 9549 /** 9550 * Starts to write new file data in the WriteStream object returned. If the file does not exist, create a file. 9551 * Call finishWrite() if the write operation is successful; call failWrite() if the write operation fails. 9552 * 9553 * @returns { WriteStream } Returns the file write stream. 9554 * @throws { BusinessError } 13900001 Operation not permitted 9555 * @throws { BusinessError } 13900002 No such file or directory 9556 * @throws { BusinessError } 13900012 Permission denied 9557 * @throws { BusinessError } 13900027 Read-only file system 9558 * @throws { BusinessError } 13900042 Internal error 9559 * @syscap SystemCapability.FileManagement.File.FileIO 9560 * @since 15 9561 */ 9562 /** 9563 * Starts to write new file data in the WriteStream object returned. If the file does not exist, create a file. 9564 * Call finishWrite() if the write operation is successful; call failWrite() if the write operation fails. 9565 * 9566 * @returns { WriteStream } Returns the file write stream. 9567 * @throws { BusinessError } 13900001 Operation not permitted 9568 * @throws { BusinessError } 13900002 No such file or directory 9569 * @throws { BusinessError } 13900012 Permission denied 9570 * @throws { BusinessError } 13900027 Read-only file system 9571 * @throws { BusinessError } 13900042 Internal error 9572 * @syscap SystemCapability.FileManagement.File.FileIO 9573 * @crossplatform 9574 * @since 20 9575 */ 9576 startWrite(): WriteStream; 9577 9578 /** 9579 * Finishes writing file data when the write operation is complete. 9580 * 9581 * @throws { BusinessError } 13900042 Internal error 9582 * @syscap SystemCapability.FileManagement.File.FileIO 9583 * @since 15 9584 */ 9585 /** 9586 * Finishes writing file data when the write operation is complete. 9587 * 9588 * @throws { BusinessError } 13900042 Internal error 9589 * @syscap SystemCapability.FileManagement.File.FileIO 9590 * @crossplatform 9591 * @since 20 9592 */ 9593 finishWrite(): void; 9594 9595 /** 9596 * Rolls back the file after the file fails to be written. 9597 * 9598 * @throws { BusinessError } 13900042 Internal error 9599 * @syscap SystemCapability.FileManagement.File.FileIO 9600 * @since 15 9601 */ 9602 /** 9603 * Rolls back the file after the file fails to be written. 9604 * 9605 * @throws { BusinessError } 13900042 Internal error 9606 * @syscap SystemCapability.FileManagement.File.FileIO 9607 * @crossplatform 9608 * @since 20 9609 */ 9610 failWrite(): void; 9611 9612 /** 9613 * Deletes the AtomicFile class, including the original files and temporary files. 9614 * 9615 * @throws { BusinessError } 13900001 Operation not permitted 9616 * @throws { BusinessError } 13900002 No such file or directory 9617 * @throws { BusinessError } 13900012 Permission denied 9618 * @throws { BusinessError } 13900027 Read-only file system 9619 * @throws { BusinessError } 13900042 Internal error 9620 * @syscap SystemCapability.FileManagement.File.FileIO 9621 * @since 15 9622 */ 9623 /** 9624 * Deletes the AtomicFile class, including the original files and temporary files. 9625 * 9626 * @throws { BusinessError } 13900001 Operation not permitted 9627 * @throws { BusinessError } 13900002 No such file or directory 9628 * @throws { BusinessError } 13900012 Permission denied 9629 * @throws { BusinessError } 13900027 Read-only file system 9630 * @throws { BusinessError } 13900042 Internal error 9631 * @syscap SystemCapability.FileManagement.File.FileIO 9632 * @crossplatform 9633 * @since 20 9634 */ 9635 delete(): void; 9636} 9637 9638/** 9639 * Stat object. 9640 * 9641 * @interface Stat 9642 * @syscap SystemCapability.FileManagement.File.FileIO 9643 * @since 9 9644 */ 9645/** 9646 * Stat object. 9647 * 9648 * @interface Stat 9649 * @syscap SystemCapability.FileManagement.File.FileIO 9650 * @crossplatform 9651 * @since 10 9652 */ 9653/** 9654 * Represents detailed file information. Before calling any API of the Stat() class, 9655 * use stat() to create a Stat instance. 9656 * 9657 * @interface Stat 9658 * @syscap SystemCapability.FileManagement.File.FileIO 9659 * @crossplatform 9660 * @atomicservice 9661 * @since 11 9662 */ 9663declare interface Stat { 9664 /** 9665 * @type { bigint } 9666 * @readonly 9667 * @throws { BusinessError } 13900005 - I/O error 9668 * @throws { BusinessError } 13900042 - Unknown error 9669 * @syscap SystemCapability.FileManagement.File.FileIO 9670 * @since 9 9671 */ 9672 /** 9673 * File identifier, which varies with files on the same device. 9674 * 9675 * @type { bigint } 9676 * @readonly 9677 * @throws { BusinessError } 13900005 - I/O error 9678 * @throws { BusinessError } 13900042 - Unknown error 9679 * @syscap SystemCapability.FileManagement.File.FileIO 9680 * @crossplatform 9681 * @since 10 9682 */ 9683 readonly ino: bigint; 9684 /** 9685 * @type { number } 9686 * @readonly 9687 * @throws { BusinessError } 13900005 - I/O error 9688 * @throws { BusinessError } 13900042 - Unknown error 9689 * @syscap SystemCapability.FileManagement.File.FileIO 9690 * @since 9 9691 */ 9692 /** 9693 * @type { number } 9694 * @readonly 9695 * @throws { BusinessError } 13900005 - I/O error 9696 * @throws { BusinessError } 13900042 - Unknown error 9697 * @syscap SystemCapability.FileManagement.File.FileIO 9698 * @crossplatform 9699 * @since 10 9700 */ 9701 /** 9702 * File permissions. The meaning of each bit is as follows: 9703 * The following values are in octal format. The return values are in decimal format. You need to convert the values. 9704 * 0o400: The user has the read permission on a regular file or a directory entry. 9705 * 0o200: The user has the permission to write a regular file or create and delete a directory entry. 9706 * 0o100: The user has the permission to execute a regular file or search for the specified path in a directory. 9707 * 0o040: The user group has the read permission on a regular file or a directory entry. 9708 * 0o020: The user group has the permission to write a regular file or create and delete a directory entry. 9709 * 0o010: The user group has the permission to execute a regular file or search for the specified path in a directory. 9710 * 0o004: Other users have the permission to read a regular file or read a directory entry. 9711 * 0o002: Other users have the permission to write a regular file or create and delete a directory entry. 9712 * 0o001: Other users have the permission to execute a regular file or search for the specified path in a directory. 9713 * 9714 * @type { number } 9715 * @readonly 9716 * @throws { BusinessError } 13900005 - I/O error 9717 * @throws { BusinessError } 13900042 - Unknown error 9718 * @syscap SystemCapability.FileManagement.File.FileIO 9719 * @crossplatform 9720 * @atomicservice 9721 * @since 11 9722 */ 9723 readonly mode: number; 9724 /** 9725 * @type { number } 9726 * @readonly 9727 * @throws { BusinessError } 13900005 - I/O error 9728 * @throws { BusinessError } 13900042 - Unknown error 9729 * @throws { BusinessError } 13900005 - I/O error 9730 * @throws { BusinessError } 13900042 - Unknown error 9731 * @syscap SystemCapability.FileManagement.File.FileIO 9732 * @since 9 9733 */ 9734 /** 9735 * ID of the file owner. 9736 * 9737 * @type { number } 9738 * @readonly 9739 * @throws { BusinessError } 13900005 - I/O error 9740 * @throws { BusinessError } 13900042 - Unknown error 9741 * @throws { BusinessError } 13900005 - I/O error 9742 * @throws { BusinessError } 13900042 - Unknown error 9743 * @syscap SystemCapability.FileManagement.File.FileIO 9744 * @crossplatform 9745 * @since 10 9746 */ 9747 readonly uid: number; 9748 /** 9749 * @type { number } 9750 * @readonly 9751 * @throws { BusinessError } 13900005 - I/O error 9752 * @throws { BusinessError } 13900042 - Unknown error 9753 * @syscap SystemCapability.FileManagement.File.FileIO 9754 * @since 9 9755 */ 9756 /** 9757 * ID of the user group of the file. 9758 * 9759 * @type { number } 9760 * @readonly 9761 * @throws { BusinessError } 13900005 - I/O error 9762 * @throws { BusinessError } 13900042 - Unknown error 9763 * @syscap SystemCapability.FileManagement.File.FileIO 9764 * @crossplatform 9765 * @since 10 9766 */ 9767 readonly gid: number; 9768 /** 9769 * @type { number } 9770 * @readonly 9771 * @throws { BusinessError } 13900005 - I/O error 9772 * @throws { BusinessError } 13900042 - Unknown error 9773 * @syscap SystemCapability.FileManagement.File.FileIO 9774 * @since 9 9775 */ 9776 /** 9777 * @type { number } 9778 * @readonly 9779 * @throws { BusinessError } 13900005 - I/O error 9780 * @throws { BusinessError } 13900042 - Unknown error 9781 * @syscap SystemCapability.FileManagement.File.FileIO 9782 * @crossplatform 9783 * @since 10 9784 */ 9785 /** 9786 * File size, in bytes. This parameter is valid only for regular files. 9787 * 9788 * @type { number } 9789 * @readonly 9790 * @throws { BusinessError } 13900005 - I/O error 9791 * @throws { BusinessError } 13900042 - Unknown error 9792 * @syscap SystemCapability.FileManagement.File.FileIO 9793 * @crossplatform 9794 * @atomicservice 9795 * @since 11 9796 */ 9797 readonly size: number; 9798 /** 9799 * @type { number } 9800 * @readonly 9801 * @throws { BusinessError } 13900005 - I/O error 9802 * @throws { BusinessError } 13900042 - Unknown error 9803 * @syscap SystemCapability.FileManagement.File.FileIO 9804 * @since 9 9805 */ 9806 /** 9807 * @type { number } 9808 * @readonly 9809 * @throws { BusinessError } 13900005 - I/O error 9810 * @throws { BusinessError } 13900042 - Unknown error 9811 * @syscap SystemCapability.FileManagement.File.FileIO 9812 * @crossplatform 9813 * @since 10 9814 */ 9815 /** 9816 * Time when the file was last accessed. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970. 9817 * NOTE: Currently, user data partitions are mounted in noatime mode by default, and atime update is disabled. 9818 * 9819 * @type { number } 9820 * @readonly 9821 * @throws { BusinessError } 13900005 - I/O error 9822 * @throws { BusinessError } 13900042 - Unknown error 9823 * @syscap SystemCapability.FileManagement.File.FileIO 9824 * @crossplatform 9825 * @atomicservice 9826 * @since 11 9827 */ 9828 readonly atime: number; 9829 /** 9830 * @type { number } 9831 * @readonly 9832 * @throws { BusinessError } 13900005 - I/O error 9833 * @throws { BusinessError } 13900042 - Unknown error 9834 * @syscap SystemCapability.FileManagement.File.FileIO 9835 * @since 9 9836 */ 9837 /** 9838 * @type { number } 9839 * @readonly 9840 * @throws { BusinessError } 13900005 - I/O error 9841 * @throws { BusinessError } 13900042 - Unknown error 9842 * @syscap SystemCapability.FileManagement.File.FileIO 9843 * @crossplatform 9844 * @since 10 9845 */ 9846 /** 9847 * Time when the file content was last modified. The value is the number of seconds elapsed 9848 * since 00:00:00 on January 1, 1970. 9849 * 9850 * @type { number } 9851 * @readonly 9852 * @throws { BusinessError } 13900005 - I/O error 9853 * @throws { BusinessError } 13900042 - Unknown error 9854 * @syscap SystemCapability.FileManagement.File.FileIO 9855 * @crossplatform 9856 * @atomicservice 9857 * @since 11 9858 */ 9859 readonly mtime: number; 9860 /** 9861 * @type { number } 9862 * @readonly 9863 * @throws { BusinessError } 13900005 - I/O error 9864 * @throws { BusinessError } 13900042 - Unknown error 9865 * @syscap SystemCapability.FileManagement.File.FileIO 9866 * @since 9 9867 */ 9868 /** 9869 * Time when the file metadata was last modified. The value is the number of seconds elapsed 9870 * since 00:00:00 on January 1, 1970. 9871 * 9872 * @type { number } 9873 * @readonly 9874 * @throws { BusinessError } 13900005 - I/O error 9875 * @throws { BusinessError } 13900042 - Unknown error 9876 * @syscap SystemCapability.FileManagement.File.FileIO 9877 * @crossplatform 9878 * @since 10 9879 */ 9880 readonly ctime: number; 9881 9882 /** 9883 * Time of the last access to the file. The value is the number of nanoseconds elapsed 9884 * since 00:00:00 on January 1, 1970. 9885 * NOTE: Currently, user data partitions are mounted in noatime mode by default, and atime update is disabled. 9886 * 9887 * @type { bigint } 9888 * @readonly 9889 * @throws { BusinessError } 13900042 - Internal error 9890 * @syscap SystemCapability.FileManagement.File.FileIO 9891 * @since 15 9892 */ 9893 readonly atimeNs?:bigint; 9894 9895 /** 9896 * Time of the last modification to the file. The value is the number of 9897 * nanoseconds elapsed since 00:00:00 on January 1, 1970. 9898 * 9899 * @type { bigint } 9900 * @readonly 9901 * @throws { BusinessError } 13900042 - Internal error 9902 * @syscap SystemCapability.FileManagement.File.FileIO 9903 * @since 15 9904 */ 9905 readonly mtimeNs?:bigint; 9906 9907 /** 9908 * Time of the last status change of the file. The value is the number of nanoseconds elapsed 9909 * since 00:00:00 on January 1, 1970. 9910 * 9911 * @type { bigint } 9912 * @readonly 9913 * @throws { BusinessError } 13900042 - Internal error 9914 * @syscap SystemCapability.FileManagement.File.FileIO 9915 * @since 15 9916 */ 9917 readonly ctimeNs?:bigint; 9918 9919 /** 9920 * File location, which indicates whether the file is stored in a local device or in the cloud. 9921 * 9922 * @type { LocationType } 9923 * @readonly 9924 * @throws { BusinessError } 13900042 - Unknown error 9925 * @syscap SystemCapability.FileManagement.File.FileIO 9926 * @since 11 9927 */ 9928 readonly location: LocationType; 9929 9930 /** 9931 * Whether path/fd is block device. 9932 * 9933 * @returns { boolean } Returns whether the path/fd point to a block device or not. 9934 * @throws { BusinessError } 13900005 - I/O error 9935 * @throws { BusinessError } 13900042 - Unknown error 9936 * @syscap SystemCapability.FileManagement.File.FileIO 9937 * @since 9 9938 */ 9939 /** 9940 * Checks whether this file is a block special file. A block special file supports access by block only, and it is cached when accessed. 9941 * 9942 * @returns { boolean } Returns whether the path/fd point to a block device or not. 9943 * @throws { BusinessError } 13900005 - I/O error 9944 * @throws { BusinessError } 13900042 - Unknown error 9945 * @syscap SystemCapability.FileManagement.File.FileIO 9946 * @crossplatform 9947 * @since 10 9948 */ 9949 isBlockDevice(): boolean; 9950 /** 9951 * Whether path/fd is character device. 9952 * 9953 * @returns { boolean } Returns whether the path/fd point to a character device or not. 9954 * @throws { BusinessError } 13900005 - I/O error 9955 * @throws { BusinessError } 13900042 - Unknown error 9956 * @syscap SystemCapability.FileManagement.File.FileIO 9957 * @since 9 9958 */ 9959 /** 9960 * Checks whether this file is a character special file. A character special device supports random access, and it is not cached when accessed. 9961 * 9962 * @returns { boolean } Returns whether the path/fd point to a character device or not. 9963 * @throws { BusinessError } 13900005 - I/O error 9964 * @throws { BusinessError } 13900042 - Unknown error 9965 * @syscap SystemCapability.FileManagement.File.FileIO 9966 * @crossplatform 9967 * @since 10 9968 */ 9969 isCharacterDevice(): boolean; 9970 /** 9971 * Whether path/fd is directory. 9972 * 9973 * @returns { boolean } Returns whether the path/fd point to a directory or not. 9974 * @throws { BusinessError } 13900005 - I/O error 9975 * @throws { BusinessError } 13900042 - Unknown error 9976 * @syscap SystemCapability.FileManagement.File.FileIO 9977 * @since 9 9978 */ 9979 /** 9980 * Whether path/fd is directory. 9981 * 9982 * @returns { boolean } Returns whether the path/fd point to a directory or not. 9983 * @throws { BusinessError } 13900005 - I/O error 9984 * @throws { BusinessError } 13900042 - Unknown error 9985 * @syscap SystemCapability.FileManagement.File.FileIO 9986 * @crossplatform 9987 * @since 10 9988 */ 9989 /** 9990 * Checks whether this file is a directory. 9991 * 9992 * @returns { boolean } Returns whether the path/fd point to a directory or not. 9993 * @throws { BusinessError } 13900005 - I/O error 9994 * @throws { BusinessError } 13900042 - Unknown error 9995 * @syscap SystemCapability.FileManagement.File.FileIO 9996 * @crossplatform 9997 * @atomicservice 9998 * @since 11 9999 */ 10000 isDirectory(): boolean; 10001 /** 10002 * Whether path/fd is fifo. 10003 * 10004 * @returns { boolean } Returns whether the path/fd point to a fifo file or not. 10005 * @throws { BusinessError } 13900005 - I/O error 10006 * @throws { BusinessError } 13900042 - Unknown error 10007 * @syscap SystemCapability.FileManagement.File.FileIO 10008 * @since 9 10009 */ 10010 /** 10011 * Checks whether this file is a named pipe (or FIFO). Named pipes are used for inter-process communication. 10012 * 10013 * @returns { boolean } Returns whether the path/fd point to a fifo file or not. 10014 * @throws { BusinessError } 13900005 - I/O error 10015 * @throws { BusinessError } 13900042 - Unknown error 10016 * @syscap SystemCapability.FileManagement.File.FileIO 10017 * @crossplatform 10018 * @since 10 10019 */ 10020 isFIFO(): boolean; 10021 /** 10022 * Whether path/fd is file. 10023 * 10024 * @returns { boolean } Returns whether the path/fd point to a normal file or not. 10025 * @throws { BusinessError } 13900005 - I/O error 10026 * @throws { BusinessError } 13900042 - Unknown error 10027 * @syscap SystemCapability.FileManagement.File.FileIO 10028 * @since 9 10029 */ 10030 /** 10031 * Whether path/fd is file. 10032 * 10033 * @returns { boolean } Returns whether the path/fd point to a normal file or not. 10034 * @throws { BusinessError } 13900005 - I/O error 10035 * @throws { BusinessError } 13900042 - Unknown error 10036 * @syscap SystemCapability.FileManagement.File.FileIO 10037 * @crossplatform 10038 * @since 10 10039 */ 10040 /** 10041 * Checks whether this file is a regular file. 10042 * 10043 * @returns { boolean } Returns whether the path/fd point to a normal file or not. 10044 * @throws { BusinessError } 13900005 - I/O error 10045 * @throws { BusinessError } 13900042 - Unknown error 10046 * @syscap SystemCapability.FileManagement.File.FileIO 10047 * @crossplatform 10048 * @atomicservice 10049 * @since 11 10050 */ 10051 isFile(): boolean; 10052 /** 10053 * Whether path/fd is socket. 10054 * 10055 * @returns { boolean } Returns whether the path/fd point to a socket file or not. 10056 * @throws { BusinessError } 13900005 - I/O error 10057 * @throws { BusinessError } 13900042 - Unknown error 10058 * @syscap SystemCapability.FileManagement.File.FileIO 10059 * @since 9 10060 */ 10061 /** 10062 * Checks whether this file is a socket. 10063 * 10064 * @returns { boolean } Returns whether the path/fd point to a socket file or not. 10065 * @throws { BusinessError } 13900005 - I/O error 10066 * @throws { BusinessError } 13900042 - Unknown error 10067 * @syscap SystemCapability.FileManagement.File.FileIO 10068 * @crossplatform 10069 * @since 10 10070 */ 10071 isSocket(): boolean; 10072 /** 10073 * Whether path/fd is symbolic link. 10074 * 10075 * @returns { boolean } Returns whether the path/fd point to a symbolic link or not. 10076 * @throws { BusinessError } 13900005 - I/O error 10077 * @throws { BusinessError } 13900042 - Unknown error 10078 * @syscap SystemCapability.FileManagement.File.FileIO 10079 * @since 9 10080 */ 10081 /** 10082 * Checks whether this file is a symbolic link. 10083 * 10084 * @returns { boolean } Returns whether the path/fd point to a symbolic link or not. 10085 * @throws { BusinessError } 13900005 - I/O error 10086 * @throws { BusinessError } 13900042 - Unknown error 10087 * @syscap SystemCapability.FileManagement.File.FileIO 10088 * @crossplatform 10089 * @since 10 10090 */ 10091 isSymbolicLink(): boolean; 10092} 10093 10094/** 10095 * Provides API for stream operations. Before calling any API of Stream, 10096 * you need to create a Stream instance by using fs.createStream or fs.fdopenStream. 10097 * 10098 * @interface Stream 10099 * @syscap SystemCapability.FileManagement.File.FileIO 10100 * @since 9 10101 */ 10102/** 10103 * Provides API for stream operations. Before calling any API of Stream, 10104 * you need to create a Stream instance by using fs.createStream or fs.fdopenStream. 10105 * 10106 * @interface Stream 10107 * @syscap SystemCapability.FileManagement.File.FileIO 10108 * @crossplatform 10109 * @atomicservice 10110 * @since 20 10111 */ 10112declare interface Stream { 10113 /** 10114 * Close stream. 10115 * 10116 * @returns { Promise<void> } The promise returned by the function. 10117 * @throws { BusinessError } 13900004 - Interrupted system call 10118 * @throws { BusinessError } 13900005 - I/O error 10119 * @throws { BusinessError } 13900008 - Bad file descriptor 10120 * @throws { BusinessError } 13900025 - No space left on device 10121 * @throws { BusinessError } 13900041 - Quota exceeded 10122 * @throws { BusinessError } 13900042 - Unknown error 10123 * @syscap SystemCapability.FileManagement.File.FileIO 10124 * @since 9 10125 */ 10126 /** 10127 * Close stream. 10128 * 10129 * @returns { Promise<void> } The promise returned by the function. 10130 * @throws { BusinessError } 13900004 - Interrupted system call 10131 * @throws { BusinessError } 13900005 - I/O error 10132 * @throws { BusinessError } 13900008 - Bad file descriptor 10133 * @throws { BusinessError } 13900025 - No space left on device 10134 * @throws { BusinessError } 13900041 - Quota exceeded 10135 * @throws { BusinessError } 13900042 - Unknown error 10136 * @syscap SystemCapability.FileManagement.File.FileIO 10137 * @crossplatform 10138 * @atomicservice 10139 * @since 20 10140 */ 10141 close(): Promise<void>; 10142 10143 /** 10144 * Close stream. 10145 * 10146 * @param { AsyncCallback<void> } callback - Return the callback function. 10147 * @throws { BusinessError } 13900004 - Interrupted system call 10148 * @throws { BusinessError } 13900005 - I/O error 10149 * @throws { BusinessError } 13900008 - Bad file descriptor 10150 * @throws { BusinessError } 13900025 - No space left on device 10151 * @throws { BusinessError } 13900041 - Quota exceeded 10152 * @throws { BusinessError } 13900042 - Unknown error 10153 * @syscap SystemCapability.FileManagement.File.FileIO 10154 * @since 9 10155 */ 10156 /** 10157 * Close stream. 10158 * 10159 * @param { AsyncCallback<void> } callback - Return the callback function. 10160 * @throws { BusinessError } 13900004 - Interrupted system call 10161 * @throws { BusinessError } 13900005 - I/O error 10162 * @throws { BusinessError } 13900008 - Bad file descriptor 10163 * @throws { BusinessError } 13900025 - No space left on device 10164 * @throws { BusinessError } 13900041 - Quota exceeded 10165 * @throws { BusinessError } 13900042 - Unknown error 10166 * @syscap SystemCapability.FileManagement.File.FileIO 10167 * @crossplatform 10168 * @atomicservice 10169 * @since 20 10170 */ 10171 close(callback: AsyncCallback<void>): void; 10172 10173 /** 10174 * Close stream with sync interface. 10175 * 10176 * @throws { BusinessError } 13900004 - Interrupted system call 10177 * @throws { BusinessError } 13900005 - I/O error 10178 * @throws { BusinessError } 13900008 - Bad file descriptor 10179 * @throws { BusinessError } 13900025 - No space left on device 10180 * @throws { BusinessError } 13900041 - Quota exceeded 10181 * @throws { BusinessError } 13900042 - Unknown error 10182 * @syscap SystemCapability.FileManagement.File.FileIO 10183 * @since 9 10184 */ 10185 /** 10186 * Close stream with sync interface. 10187 * 10188 * @throws { BusinessError } 13900004 - Interrupted system call 10189 * @throws { BusinessError } 13900005 - I/O error 10190 * @throws { BusinessError } 13900008 - Bad file descriptor 10191 * @throws { BusinessError } 13900025 - No space left on device 10192 * @throws { BusinessError } 13900041 - Quota exceeded 10193 * @throws { BusinessError } 13900042 - Unknown error 10194 * @syscap SystemCapability.FileManagement.File.FileIO 10195 * @crossplatform 10196 * @atomicservice 10197 * @since 20 10198 */ 10199 closeSync(): void; 10200 10201 /** 10202 * Flushes this stream. This API uses a promise to return the result. 10203 * 10204 * @returns { Promise<void> } The promise returned by the function. 10205 * @throws { BusinessError } 13900001 - Operation not permitted 10206 * @throws { BusinessError } 13900004 - Interrupted system call 10207 * @throws { BusinessError } 13900005 - I/O error 10208 * @throws { BusinessError } 13900008 - Bad file descriptor 10209 * @throws { BusinessError } 13900010 - Try again 10210 * @throws { BusinessError } 13900013 - Bad address 10211 * @throws { BusinessError } 13900020 - Invalid argument 10212 * @throws { BusinessError } 13900024 - File too large 10213 * @throws { BusinessError } 13900025 - No space left on device 10214 * @throws { BusinessError } 13900034 - Operation would block 10215 * @throws { BusinessError } 13900041 - Quota exceeded 10216 * @throws { BusinessError } 13900042 - Unknown error 10217 * @syscap SystemCapability.FileManagement.File.FileIO 10218 * @since 9 10219 */ 10220 /** 10221 * Flushes this stream. This API uses a promise to return the result. 10222 * 10223 * @returns { Promise<void> } The promise returned by the function. 10224 * @throws { BusinessError } 13900001 - Operation not permitted 10225 * @throws { BusinessError } 13900004 - Interrupted system call 10226 * @throws { BusinessError } 13900005 - I/O error 10227 * @throws { BusinessError } 13900008 - Bad file descriptor 10228 * @throws { BusinessError } 13900010 - Try again 10229 * @throws { BusinessError } 13900013 - Bad address 10230 * @throws { BusinessError } 13900020 - Invalid argument 10231 * @throws { BusinessError } 13900024 - File too large 10232 * @throws { BusinessError } 13900025 - No space left on device 10233 * @throws { BusinessError } 13900034 - Operation would block 10234 * @throws { BusinessError } 13900041 - Quota exceeded 10235 * @throws { BusinessError } 13900042 - Unknown error 10236 * @syscap SystemCapability.FileManagement.File.FileIO 10237 * @crossplatform 10238 * @atomicservice 10239 * @since 20 10240 */ 10241 flush(): Promise<void>; 10242 10243 /** 10244 * Flush stream. 10245 * 10246 * @param { AsyncCallback<void> } callback - Callback used to return the result. 10247 * @throws { BusinessError } 13900001 - Operation not permitted 10248 * @throws { BusinessError } 13900004 - Interrupted system call 10249 * @throws { BusinessError } 13900005 - I/O error 10250 * @throws { BusinessError } 13900008 - Bad file descriptor 10251 * @throws { BusinessError } 13900010 - Try again 10252 * @throws { BusinessError } 13900013 - Bad address 10253 * @throws { BusinessError } 13900020 - Invalid argument 10254 * @throws { BusinessError } 13900024 - File too large 10255 * @throws { BusinessError } 13900025 - No space left on device 10256 * @throws { BusinessError } 13900034 - Operation would block 10257 * @throws { BusinessError } 13900041 - Quota exceeded 10258 * @throws { BusinessError } 13900042 - Unknown error 10259 * @syscap SystemCapability.FileManagement.File.FileIO 10260 * @since 9 10261 */ 10262 /** 10263 * Flushes this stream. This API uses an asynchronous callback to return the result. 10264 * 10265 * @param { AsyncCallback<void> } callback - Callback used to return the result. 10266 * @throws { BusinessError } 13900001 - Operation not permitted 10267 * @throws { BusinessError } 13900004 - Interrupted system call 10268 * @throws { BusinessError } 13900005 - I/O error 10269 * @throws { BusinessError } 13900008 - Bad file descriptor 10270 * @throws { BusinessError } 13900010 - Try again 10271 * @throws { BusinessError } 13900013 - Bad address 10272 * @throws { BusinessError } 13900020 - Invalid argument 10273 * @throws { BusinessError } 13900024 - File too large 10274 * @throws { BusinessError } 13900025 - No space left on device 10275 * @throws { BusinessError } 13900034 - Operation would block 10276 * @throws { BusinessError } 13900041 - Quota exceeded 10277 * @throws { BusinessError } 13900042 - Unknown error 10278 * @syscap SystemCapability.FileManagement.File.FileIO 10279 * @crossplatform 10280 * @atomicservice 10281 * @since 20 10282 */ 10283 flush(callback: AsyncCallback<void>): void; 10284 10285 /** 10286 * Flushes this stream. This API returns the result synchronously. 10287 * 10288 * @throws { BusinessError } 13900001 - Operation not permitted 10289 * @throws { BusinessError } 13900004 - Interrupted system call 10290 * @throws { BusinessError } 13900005 - I/O error 10291 * @throws { BusinessError } 13900008 - Bad file descriptor 10292 * @throws { BusinessError } 13900010 - Try again 10293 * @throws { BusinessError } 13900013 - Bad address 10294 * @throws { BusinessError } 13900020 - Invalid argument 10295 * @throws { BusinessError } 13900024 - File too large 10296 * @throws { BusinessError } 13900025 - No space left on device 10297 * @throws { BusinessError } 13900034 - Operation would block 10298 * @throws { BusinessError } 13900041 - Quota exceeded 10299 * @throws { BusinessError } 13900042 - Unknown error 10300 * @syscap SystemCapability.FileManagement.File.FileIO 10301 * @since 9 10302 */ 10303 /** 10304 * Flushes this stream. This API returns the result synchronously. 10305 * 10306 * @throws { BusinessError } 13900001 - Operation not permitted 10307 * @throws { BusinessError } 13900004 - Interrupted system call 10308 * @throws { BusinessError } 13900005 - I/O error 10309 * @throws { BusinessError } 13900008 - Bad file descriptor 10310 * @throws { BusinessError } 13900010 - Try again 10311 * @throws { BusinessError } 13900013 - Bad address 10312 * @throws { BusinessError } 13900020 - Invalid argument 10313 * @throws { BusinessError } 13900024 - File too large 10314 * @throws { BusinessError } 13900025 - No space left on device 10315 * @throws { BusinessError } 13900034 - Operation would block 10316 * @throws { BusinessError } 13900041 - Quota exceeded 10317 * @throws { BusinessError } 13900042 - Unknown error 10318 * @syscap SystemCapability.FileManagement.File.FileIO 10319 * @crossplatform 10320 * @atomicservice 10321 * @since 20 10322 */ 10323 flushSync(): void; 10324 10325 /** 10326 * Write stream. 10327 * 10328 * @param { ArrayBuffer | string } buffer - buffer. 10329 * @param { object } [options] - options. 10330 * @returns { Promise<number> } Returns the number of file bytes written to file in promise mode. 10331 * @throws { BusinessError } 13900001 - Operation not permitted 10332 * @throws { BusinessError } 13900004 - Interrupted system call 10333 * @throws { BusinessError } 13900005 - I/O error 10334 * @throws { BusinessError } 13900008 - Bad file descriptor 10335 * @throws { BusinessError } 13900010 - Try again 10336 * @throws { BusinessError } 13900013 - Bad address 10337 * @throws { BusinessError } 13900020 - Invalid argument 10338 * @throws { BusinessError } 13900024 - File too large 10339 * @throws { BusinessError } 13900025 - No space left on device 10340 * @throws { BusinessError } 13900034 - Operation would block 10341 * @throws { BusinessError } 13900041 - Quota exceeded 10342 * @throws { BusinessError } 13900042 - Unknown error 10343 * @syscap SystemCapability.FileManagement.File.FileIO 10344 * @since 9 10345 */ 10346 /** 10347 * Writes data to this stream. This API uses a promise to return the result. 10348 * 10349 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 10350 * @param { WriteOptions } [options] - The options are as follows: 10351 * <br>length (number): length of the data to write. The default value is the buffer length. 10352 * <br>offset (number): start position to write the data in the file. This parameter is optional. 10353 * <br>By default, data is written from the current position. 10354 * <br>encoding (string): format of the data to be encoded when the data is a string. 10355 * <br>The default value is 'utf-8', which is the only value supported. 10356 * @returns { Promise<number> } Promise used to return the length of the data written. 10357 * @throws { BusinessError } 13900001 - Operation not permitted 10358 * @throws { BusinessError } 13900004 - Interrupted system call 10359 * @throws { BusinessError } 13900005 - I/O error 10360 * @throws { BusinessError } 13900008 - Bad file descriptor 10361 * @throws { BusinessError } 13900010 - Try again 10362 * @throws { BusinessError } 13900013 - Bad address 10363 * @throws { BusinessError } 13900020 - Invalid argument 10364 * @throws { BusinessError } 13900024 - File too large 10365 * @throws { BusinessError } 13900025 - No space left on device 10366 * @throws { BusinessError } 13900034 - Operation would block 10367 * @throws { BusinessError } 13900041 - Quota exceeded 10368 * @throws { BusinessError } 13900042 - Unknown error 10369 * @syscap SystemCapability.FileManagement.File.FileIO 10370 * @since 11 10371 */ 10372 /** 10373 * Writes data to this stream. This API uses a promise to return the result. 10374 * 10375 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 10376 * @param { WriteOptions } [options] - The options are as follows: 10377 * <br>length (number): length of the data to write. The default value is the buffer length. 10378 * <br>offset (number): start position to write the data in the file. This parameter is optional. 10379 * <br>By default, data is written from the current position. 10380 * <br>encoding (string): format of the data to be encoded when the data is a string. 10381 * <br>The default value is 'utf-8', which is the only value supported. 10382 * @returns { Promise<number> } Promise used to return the length of the data written. 10383 * @throws { BusinessError } 13900001 - Operation not permitted 10384 * @throws { BusinessError } 13900004 - Interrupted system call 10385 * @throws { BusinessError } 13900005 - I/O error 10386 * @throws { BusinessError } 13900008 - Bad file descriptor 10387 * @throws { BusinessError } 13900010 - Try again 10388 * @throws { BusinessError } 13900013 - Bad address 10389 * @throws { BusinessError } 13900020 - Invalid argument 10390 * @throws { BusinessError } 13900024 - File too large 10391 * @throws { BusinessError } 13900025 - No space left on device 10392 * @throws { BusinessError } 13900034 - Operation would block 10393 * @throws { BusinessError } 13900041 - Quota exceeded 10394 * @throws { BusinessError } 13900042 - Unknown error 10395 * @syscap SystemCapability.FileManagement.File.FileIO 10396 * @crossplatform 10397 * @atomicservice 10398 * @since 20 10399 */ 10400 write( 10401 buffer: ArrayBuffer | string, 10402 options?: WriteOptions 10403 ): Promise<number>; 10404 10405 /** 10406 * Writes data to this stream. This API uses an asynchronous callback to return the result. 10407 * 10408 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 10409 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes written to file. 10410 * @throws { BusinessError } 13900001 - Operation not permitted 10411 * @throws { BusinessError } 13900004 - Interrupted system call 10412 * @throws { BusinessError } 13900005 - I/O error 10413 * @throws { BusinessError } 13900008 - Bad file descriptor 10414 * @throws { BusinessError } 13900010 - Try again 10415 * @throws { BusinessError } 13900013 - Bad address 10416 * @throws { BusinessError } 13900020 - Invalid argument 10417 * @throws { BusinessError } 13900024 - File too large 10418 * @throws { BusinessError } 13900025 - No space left on device 10419 * @throws { BusinessError } 13900034 - Operation would block 10420 * @throws { BusinessError } 13900041 - Quota exceeded 10421 * @throws { BusinessError } 13900042 - Unknown error 10422 * @syscap SystemCapability.FileManagement.File.FileIO 10423 * @since 9 10424 */ 10425 /** 10426 /** 10427 * Writes data to this stream. This API uses an asynchronous callback to return the result. 10428 * 10429 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 10430 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes written to file. 10431 * @throws { BusinessError } 13900001 - Operation not permitted 10432 * @throws { BusinessError } 13900004 - Interrupted system call 10433 * @throws { BusinessError } 13900005 - I/O error 10434 * @throws { BusinessError } 13900008 - Bad file descriptor 10435 * @throws { BusinessError } 13900010 - Try again 10436 * @throws { BusinessError } 13900013 - Bad address 10437 * @throws { BusinessError } 13900020 - Invalid argument 10438 * @throws { BusinessError } 13900024 - File too large 10439 * @throws { BusinessError } 13900025 - No space left on device 10440 * @throws { BusinessError } 13900034 - Operation would block 10441 * @throws { BusinessError } 13900041 - Quota exceeded 10442 * @throws { BusinessError } 13900042 - Unknown error 10443 * @syscap SystemCapability.FileManagement.File.FileIO 10444 * @crossplatform 10445 * @atomicservice 10446 * @since 20 10447 */ 10448 write(buffer: ArrayBuffer | string, callback: AsyncCallback<number>): void; 10449 10450 /** 10451 * Write stream. 10452 * 10453 * @param { ArrayBuffer | string } buffer - buffer. 10454 * @param { object } [options] - options. 10455 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes written to file. 10456 * @throws { BusinessError } 13900001 - Operation not permitted 10457 * @throws { BusinessError } 13900004 - Interrupted system call 10458 * @throws { BusinessError } 13900005 - I/O error 10459 * @throws { BusinessError } 13900008 - Bad file descriptor 10460 * @throws { BusinessError } 13900010 - Try again 10461 * @throws { BusinessError } 13900013 - Bad address 10462 * @throws { BusinessError } 13900020 - Invalid argument 10463 * @throws { BusinessError } 13900024 - File too large 10464 * @throws { BusinessError } 13900025 - No space left on device 10465 * @throws { BusinessError } 13900034 - Operation would block 10466 * @throws { BusinessError } 13900041 - Quota exceeded 10467 * @throws { BusinessError } 13900042 - Unknown error 10468 * @syscap SystemCapability.FileManagement.File.FileIO 10469 * @since 9 10470 */ 10471 /** 10472 * Writes data to this stream. This API uses an asynchronous callback to return the result. 10473 * 10474 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 10475 * @param { WriteOptions } [options] - The options are as follows: 10476 * <br>length (number): length of the data to write. The default value is the buffer length. 10477 * <br>offset (number): start position to write the data in the file. This parameter is optional. 10478 * <br>By default, data is written from the current position. 10479 * <br>encoding (string): format of the data to be encoded when the data is a string. 10480 * <br>The default value is 'utf-8', which is the only value supported. 10481 * @param { AsyncCallback<number> } callback - Callback used to return the result. 10482 * @throws { BusinessError } 13900001 - Operation not permitted 10483 * @throws { BusinessError } 13900004 - Interrupted system call 10484 * @throws { BusinessError } 13900005 - I/O error 10485 * @throws { BusinessError } 13900008 - Bad file descriptor 10486 * @throws { BusinessError } 13900010 - Try again 10487 * @throws { BusinessError } 13900013 - Bad address 10488 * @throws { BusinessError } 13900020 - Invalid argument 10489 * @throws { BusinessError } 13900024 - File too large 10490 * @throws { BusinessError } 13900025 - No space left on device 10491 * @throws { BusinessError } 13900034 - Operation would block 10492 * @throws { BusinessError } 13900041 - Quota exceeded 10493 * @throws { BusinessError } 13900042 - Unknown error 10494 * @syscap SystemCapability.FileManagement.File.FileIO 10495 * @since 11 10496 */ 10497 /** 10498 * Writes data to this stream. This API uses an asynchronous callback to return the result. 10499 * 10500 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 10501 * @param { WriteOptions } [options] - The options are as follows: 10502 * <br>length (number): length of the data to write. The default value is the buffer length. 10503 * <br>offset (number): start position to write the data in the file. This parameter is optional. 10504 * <br>By default, data is written from the current position. 10505 * <br>encoding (string): format of the data to be encoded when the data is a string. 10506 * <br>The default value is 'utf-8', which is the only value supported. 10507 * @param { AsyncCallback<number> } callback - Callback used to return the result. 10508 * @throws { BusinessError } 13900001 - Operation not permitted 10509 * @throws { BusinessError } 13900004 - Interrupted system call 10510 * @throws { BusinessError } 13900005 - I/O error 10511 * @throws { BusinessError } 13900008 - Bad file descriptor 10512 * @throws { BusinessError } 13900010 - Try again 10513 * @throws { BusinessError } 13900013 - Bad address 10514 * @throws { BusinessError } 13900020 - Invalid argument 10515 * @throws { BusinessError } 13900024 - File too large 10516 * @throws { BusinessError } 13900025 - No space left on device 10517 * @throws { BusinessError } 13900034 - Operation would block 10518 * @throws { BusinessError } 13900041 - Quota exceeded 10519 * @throws { BusinessError } 13900042 - Unknown error 10520 * @syscap SystemCapability.FileManagement.File.FileIO 10521 * @crossplatform 10522 * @atomicservice 10523 * @since 20 10524 */ 10525 write( 10526 buffer: ArrayBuffer | string, 10527 options: WriteOptions, 10528 callback: AsyncCallback<number> 10529 ): void; 10530 10531 /** 10532 * Write stream with sync interface. 10533 * 10534 * @param { ArrayBuffer | string } buffer - buffer. 10535 * @param { object } [options] - options. 10536 * @returns { number } Returns the number of file bytes written to file. 10537 * @throws { BusinessError } 13900001 - Operation not permitted 10538 * @throws { BusinessError } 13900004 - Interrupted system call 10539 * @throws { BusinessError } 13900005 - I/O error 10540 * @throws { BusinessError } 13900008 - Bad file descriptor 10541 * @throws { BusinessError } 13900010 - Try again 10542 * @throws { BusinessError } 13900013 - Bad address 10543 * @throws { BusinessError } 13900020 - Invalid argument 10544 * @throws { BusinessError } 13900024 - File too large 10545 * @throws { BusinessError } 13900025 - No space left on device 10546 * @throws { BusinessError } 13900034 - Operation would block 10547 * @throws { BusinessError } 13900041 - Quota exceeded 10548 * @throws { BusinessError } 13900042 - Unknown error 10549 * @syscap SystemCapability.FileManagement.File.FileIO 10550 * @since 9 10551 */ 10552 /** 10553 * Writes data to this stream. This API returns the result synchronously. 10554 * 10555 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 10556 * @param { WriteOptions } [options] - The options are as follows: 10557 * <br>length (number): length of the data to write. The default value is the buffer length. 10558 * <br>offset (number): start position to write the data in the file. This parameter is optional. 10559 * <br>By default, data is written from the current position. 10560 * <br>encoding (string): format of the data to be encoded when the data is a string. 10561 * <br>The default value is 'utf-8', which is the only value supported. 10562 * @returns { number } Length of the data written in the file. 10563 * @throws { BusinessError } 13900001 - Operation not permitted 10564 * @throws { BusinessError } 13900004 - Interrupted system call 10565 * @throws { BusinessError } 13900005 - I/O error 10566 * @throws { BusinessError } 13900008 - Bad file descriptor 10567 * @throws { BusinessError } 13900010 - Try again 10568 * @throws { BusinessError } 13900013 - Bad address 10569 * @throws { BusinessError } 13900020 - Invalid argument 10570 * @throws { BusinessError } 13900024 - File too large 10571 * @throws { BusinessError } 13900025 - No space left on device 10572 * @throws { BusinessError } 13900034 - Operation would block 10573 * @throws { BusinessError } 13900041 - Quota exceeded 10574 * @throws { BusinessError } 13900042 - Unknown error 10575 * @syscap SystemCapability.FileManagement.File.FileIO 10576 * @since 11 10577 */ 10578 /** 10579 * Writes data to this stream. This API returns the result synchronously. 10580 * 10581 * @param { ArrayBuffer | string } buffer - Data to write. It can be a string or data from a buffer. 10582 * @param { WriteOptions } [options] - The options are as follows: 10583 * <br>length (number): length of the data to write. The default value is the buffer length. 10584 * <br>offset (number): start position to write the data in the file. This parameter is optional. 10585 * <br>By default, data is written from the current position. 10586 * <br>encoding (string): format of the data to be encoded when the data is a string. 10587 * <br>The default value is 'utf-8', which is the only value supported. 10588 * @returns { number } Length of the data written in the file. 10589 * @throws { BusinessError } 13900001 - Operation not permitted 10590 * @throws { BusinessError } 13900004 - Interrupted system call 10591 * @throws { BusinessError } 13900005 - I/O error 10592 * @throws { BusinessError } 13900008 - Bad file descriptor 10593 * @throws { BusinessError } 13900010 - Try again 10594 * @throws { BusinessError } 13900013 - Bad address 10595 * @throws { BusinessError } 13900020 - Invalid argument 10596 * @throws { BusinessError } 13900024 - File too large 10597 * @throws { BusinessError } 13900025 - No space left on device 10598 * @throws { BusinessError } 13900034 - Operation would block 10599 * @throws { BusinessError } 13900041 - Quota exceeded 10600 * @throws { BusinessError } 13900042 - Unknown error 10601 * @syscap SystemCapability.FileManagement.File.FileIO 10602 * @crossplatform 10603 * @atomicservice 10604 * @since 20 10605 */ 10606 writeSync( 10607 buffer: ArrayBuffer | string, 10608 options?: WriteOptions 10609 ): number; 10610 10611 /** 10612 * Read stream. 10613 * 10614 * @param { ArrayBuffer } buffer - buffer. 10615 * @param { object } [options] - options. 10616 * @returns { Promise<number> } Returns the number of file bytes read to buffer in promise mode. 10617 * @throws { BusinessError } 13900004 - Interrupted system call 10618 * @throws { BusinessError } 13900005 - I/O error 10619 * @throws { BusinessError } 13900008 - Bad file descriptor 10620 * @throws { BusinessError } 13900010 - Try again 10621 * @throws { BusinessError } 13900013 - Bad address 10622 * @throws { BusinessError } 13900019 - Is a directory 10623 * @throws { BusinessError } 13900020 - Invalid argument 10624 * @throws { BusinessError } 13900034 - Operation would block 10625 * @throws { BusinessError } 13900042 - Unknown error 10626 * @syscap SystemCapability.FileManagement.File.FileIO 10627 * @since 9 10628 */ 10629 /** 10630 * Read stream. 10631 * 10632 * @param { ArrayBuffer } buffer - buffer. 10633 * @param { ReadOptions } [options] - options. 10634 * @returns { Promise<number> } Returns the number of file bytes read to buffer in promise mode. 10635 * @throws { BusinessError } 13900004 - Interrupted system call 10636 * @throws { BusinessError } 13900005 - I/O error 10637 * @throws { BusinessError } 13900008 - Bad file descriptor 10638 * @throws { BusinessError } 13900010 - Try again 10639 * @throws { BusinessError } 13900013 - Bad address 10640 * @throws { BusinessError } 13900019 - Is a directory 10641 * @throws { BusinessError } 13900020 - Invalid argument 10642 * @throws { BusinessError } 13900034 - Operation would block 10643 * @throws { BusinessError } 13900042 - Unknown error 10644 * @syscap SystemCapability.FileManagement.File.FileIO 10645 * @since 11 10646 */ 10647 /** 10648 * Reads data from the stream. This API uses a promise to return the result. 10649 * 10650 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 10651 * @param { ReadOptions } [options] - The options are as follows: 10652 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 10653 * <br>offset (number): start position to read the data. This parameter is optional. By default, 10654 * <br>data is read from the current position. 10655 * @returns { Promise<number> } Promise used to return the data read. 10656 * @throws { BusinessError } 13900004 - Interrupted system call 10657 * @throws { BusinessError } 13900005 - I/O error 10658 * @throws { BusinessError } 13900008 - Bad file descriptor 10659 * @throws { BusinessError } 13900010 - Try again 10660 * @throws { BusinessError } 13900013 - Bad address 10661 * @throws { BusinessError } 13900019 - Is a directory 10662 * @throws { BusinessError } 13900020 - Invalid argument 10663 * @throws { BusinessError } 13900034 - Operation would block 10664 * @throws { BusinessError } 13900042 - Unknown error 10665 * @throws { BusinessError } 13900044 - Network is unreachable 10666 * @syscap SystemCapability.FileManagement.File.FileIO 10667 * @since 12 10668 */ 10669 /** 10670 * Reads data from the stream. This API uses a promise to return the result. 10671 * 10672 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 10673 * @param { ReadOptions } [options] - The options are as follows: 10674 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 10675 * <br>offset (number): start position to read the data. This parameter is optional. By default, 10676 * <br>data is read from the current position. 10677 * @returns { Promise<number> } Promise used to return the data read. 10678 * @throws { BusinessError } 13900004 - Interrupted system call 10679 * @throws { BusinessError } 13900005 - I/O error 10680 * @throws { BusinessError } 13900008 - Bad file descriptor 10681 * @throws { BusinessError } 13900010 - Try again 10682 * @throws { BusinessError } 13900013 - Bad address 10683 * @throws { BusinessError } 13900019 - Is a directory 10684 * @throws { BusinessError } 13900020 - Invalid argument 10685 * @throws { BusinessError } 13900034 - Operation would block 10686 * @throws { BusinessError } 13900042 - Unknown error 10687 * @throws { BusinessError } 13900044 - Network is unreachable 10688 * @syscap SystemCapability.FileManagement.File.FileIO 10689 * @crossplatform 10690 * @atomicservice 10691 * @since 20 10692 */ 10693 read( 10694 buffer: ArrayBuffer, 10695 options?: ReadOptions 10696 ): Promise<number>; 10697 10698 /** 10699 * Reads data from this stream. This API uses an asynchronous callback to return the result. 10700 * 10701 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 10702 * @param { AsyncCallback<number> } callback - Callback used to return the result. 10703 * @throws { BusinessError } 13900004 - Interrupted system call 10704 * @throws { BusinessError } 13900005 - I/O error 10705 * @throws { BusinessError } 13900008 - Bad file descriptor 10706 * @throws { BusinessError } 13900010 - Try again 10707 * @throws { BusinessError } 13900013 - Bad address 10708 * @throws { BusinessError } 13900019 - Is a directory 10709 * @throws { BusinessError } 13900020 - Invalid argument 10710 * @throws { BusinessError } 13900034 - Operation would block 10711 * @throws { BusinessError } 13900042 - Unknown error 10712 * @syscap SystemCapability.FileManagement.File.FileIO 10713 * @since 9 10714 */ 10715 /** 10716 * Reads data from this stream. This API uses an asynchronous callback to return the result. 10717 * 10718 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 10719 * @param { AsyncCallback<number> } callback - Callback used to return the result. 10720 * @throws { BusinessError } 13900004 - Interrupted system call 10721 * @throws { BusinessError } 13900005 - I/O error 10722 * @throws { BusinessError } 13900008 - Bad file descriptor 10723 * @throws { BusinessError } 13900010 - Try again 10724 * @throws { BusinessError } 13900013 - Bad address 10725 * @throws { BusinessError } 13900019 - Is a directory 10726 * @throws { BusinessError } 13900020 - Invalid argument 10727 * @throws { BusinessError } 13900034 - Operation would block 10728 * @throws { BusinessError } 13900042 - Unknown error 10729 * @syscap SystemCapability.FileManagement.File.FileIO 10730 * @crossplatform 10731 * @atomicservice 10732 * @since 20 10733 */ 10734 read(buffer: ArrayBuffer, callback: AsyncCallback<number>): void; 10735 10736 /** 10737 * Read stream. 10738 * 10739 * @param { ArrayBuffer } buffer - buffer. 10740 * @param { object } [options] - options. 10741 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer. 10742 * @throws { BusinessError } 13900004 - Interrupted system call 10743 * @throws { BusinessError } 13900005 - I/O error 10744 * @throws { BusinessError } 13900008 - Bad file descriptor 10745 * @throws { BusinessError } 13900010 - Try again 10746 * @throws { BusinessError } 13900013 - Bad address 10747 * @throws { BusinessError } 13900019 - Is a directory 10748 * @throws { BusinessError } 13900020 - Invalid argument 10749 * @throws { BusinessError } 13900034 - Operation would block 10750 * @throws { BusinessError } 13900042 - Unknown error 10751 * @syscap SystemCapability.FileManagement.File.FileIO 10752 * @since 9 10753 */ 10754 /** 10755 * Reads data from this stream. This API uses an asynchronous callback to return the result. 10756 * 10757 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 10758 * @param { ReadOptions } [options] - The options are as follows: 10759 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 10760 * <br>offset (number): start position to read the data. This parameter is optional. By default, 10761 * <br>data is read from the current position. 10762 * @param { AsyncCallback<number> } callback - Callback used to return the result. 10763 * @throws { BusinessError } 13900004 - Interrupted system call 10764 * @throws { BusinessError } 13900005 - I/O error 10765 * @throws { BusinessError } 13900008 - Bad file descriptor 10766 * @throws { BusinessError } 13900010 - Try again 10767 * @throws { BusinessError } 13900013 - Bad address 10768 * @throws { BusinessError } 13900019 - Is a directory 10769 * @throws { BusinessError } 13900020 - Invalid argument 10770 * @throws { BusinessError } 13900034 - Operation would block 10771 * @throws { BusinessError } 13900042 - Unknown error 10772 * @syscap SystemCapability.FileManagement.File.FileIO 10773 * @since 11 10774 */ 10775 /** 10776 * Reads data from this stream. This API uses an asynchronous callback to return the result. 10777 * 10778 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 10779 * @param { ReadOptions } [options] - The options are as follows: 10780 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 10781 * <br>offset (number): start position to read the data. This parameter is optional. By default, 10782 * <br>data is read from the current position. 10783 * @param { AsyncCallback<number> } callback - Callback used to return the result. 10784 * @throws { BusinessError } 13900004 - Interrupted system call 10785 * @throws { BusinessError } 13900005 - I/O error 10786 * @throws { BusinessError } 13900008 - Bad file descriptor 10787 * @throws { BusinessError } 13900010 - Try again 10788 * @throws { BusinessError } 13900013 - Bad address 10789 * @throws { BusinessError } 13900019 - Is a directory 10790 * @throws { BusinessError } 13900020 - Invalid argument 10791 * @throws { BusinessError } 13900034 - Operation would block 10792 * @throws { BusinessError } 13900042 - Unknown error 10793 * @syscap SystemCapability.FileManagement.File.FileIO 10794 * @crossplatform 10795 * @atomicservice 10796 * @since 20 10797 */ 10798 read( 10799 buffer: ArrayBuffer, 10800 options: ReadOptions, 10801 callback: AsyncCallback<number> 10802 ): void; 10803 10804 /** 10805 * Read stream with sync interface. 10806 * 10807 * @param { ArrayBuffer } buffer - buffer. 10808 * @param { object } [options] - options. 10809 * @returns { number } Returns the number of file bytes read to file. 10810 * @throws { BusinessError } 13900004 - Interrupted system call 10811 * @throws { BusinessError } 13900005 - I/O error 10812 * @throws { BusinessError } 13900008 - Bad file descriptor 10813 * @throws { BusinessError } 13900010 - Try again 10814 * @throws { BusinessError } 13900013 - Bad address 10815 * @throws { BusinessError } 13900019 - Is a directory 10816 * @throws { BusinessError } 13900020 - Invalid argument 10817 * @throws { BusinessError } 13900034 - Operation would block 10818 * @throws { BusinessError } 13900042 - Unknown error 10819 * @syscap SystemCapability.FileManagement.File.FileIO 10820 * @since 9 10821 */ 10822 /** 10823 * Read stream with sync interface. 10824 * 10825 * @param { ArrayBuffer } buffer - buffer. 10826 * @param { ReadOptions } [options] - options. 10827 * @returns { number } Returns the number of file bytes read to file. 10828 * @throws { BusinessError } 13900004 - Interrupted system call 10829 * @throws { BusinessError } 13900005 - I/O error 10830 * @throws { BusinessError } 13900008 - Bad file descriptor 10831 * @throws { BusinessError } 13900010 - Try again 10832 * @throws { BusinessError } 13900013 - Bad address 10833 * @throws { BusinessError } 13900019 - Is a directory 10834 * @throws { BusinessError } 13900020 - Invalid argument 10835 * @throws { BusinessError } 13900034 - Operation would block 10836 * @throws { BusinessError } 13900042 - Unknown error 10837 * @syscap SystemCapability.FileManagement.File.FileIO 10838 * @since 11 10839 */ 10840 /** 10841 * Reads data from this stream. This API returns the result synchronously. 10842 * 10843 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 10844 * @param { ReadOptions } [options] - The options are as follows: 10845 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 10846 * <br>offset (number): start position to read the data. This parameter is optional. By default, 10847 * <br>data is read from the current position. 10848 * @returns { number } Length of the data read. 10849 * @throws { BusinessError } 13900004 - Interrupted system call 10850 * @throws { BusinessError } 13900005 - I/O error 10851 * @throws { BusinessError } 13900008 - Bad file descriptor 10852 * @throws { BusinessError } 13900010 - Try again 10853 * @throws { BusinessError } 13900013 - Bad address 10854 * @throws { BusinessError } 13900019 - Is a directory 10855 * @throws { BusinessError } 13900020 - Invalid argument 10856 * @throws { BusinessError } 13900034 - Operation would block 10857 * @throws { BusinessError } 13900042 - Unknown error 10858 * @throws { BusinessError } 13900044 - Network is unreachable 10859 * @syscap SystemCapability.FileManagement.File.FileIO 10860 * @since 12 10861 */ 10862 /** 10863 * Reads data from this stream. This API returns the result synchronously. 10864 * 10865 * @param { ArrayBuffer } buffer - Buffer used to store the file read. 10866 * @param { ReadOptions } [options] - The options are as follows: 10867 * <br>length (number): length of the data to read. This parameter is optional. The default value is the buffer length. 10868 * <br>offset (number): start position to read the data. This parameter is optional. By default, 10869 * <br>data is read from the current position. 10870 * @returns { number } Length of the data read. 10871 * @throws { BusinessError } 13900004 - Interrupted system call 10872 * @throws { BusinessError } 13900005 - I/O error 10873 * @throws { BusinessError } 13900008 - Bad file descriptor 10874 * @throws { BusinessError } 13900010 - Try again 10875 * @throws { BusinessError } 13900013 - Bad address 10876 * @throws { BusinessError } 13900019 - Is a directory 10877 * @throws { BusinessError } 13900020 - Invalid argument 10878 * @throws { BusinessError } 13900034 - Operation would block 10879 * @throws { BusinessError } 13900042 - Unknown error 10880 * @throws { BusinessError } 13900044 - Network is unreachable 10881 * @syscap SystemCapability.FileManagement.File.FileIO 10882 * @crossplatform 10883 * @atomicservice 10884 * @since 20 10885 */ 10886 readSync( 10887 buffer: ArrayBuffer, 10888 options?: ReadOptions 10889 ): number; 10890} 10891 10892/** 10893 * Provides APIs for observing events. 10894 * 10895 * @interface WatchEventListener 10896 * @syscap SystemCapability.FileManagement.File.FileIO 10897 * @since 10 10898 */ 10899/** 10900 * Provides APIs for observing events. 10901 * 10902 * @interface WatchEventListener 10903 * @syscap SystemCapability.FileManagement.File.FileIO 10904 * @crossplatform 10905 * @since 20 10906 */ 10907export interface WatchEventListener { 10908 /** 10909 * Specifies the callback function to be invoked. 10910 * 10911 * @param { WatchEvent } event - Event for the callback to invoke. 10912 * @syscap SystemCapability.FileManagement.File.FileIO 10913 * @since 10 10914 */ 10915 /** 10916 * Specifies the callback function to be invoked. 10917 * 10918 * @param { WatchEvent } event - Event for the callback to invoke. 10919 * @syscap SystemCapability.FileManagement.File.FileIO 10920 * @crossplatform 10921 * @since 20 10922 */ 10923 (event: WatchEvent): void; 10924} 10925 10926/** 10927 * Defines the event to observe. 10928 * 10929 * @interface WatchEvent 10930 * @syscap SystemCapability.FileManagement.File.FileIO 10931 * @since 10 10932 */ 10933/** 10934 * Defines the event to observe. 10935 * 10936 * @interface WatchEvent 10937 * @syscap SystemCapability.FileManagement.File.FileIO 10938 * @crossplatform 10939 * @since 20 10940 */ 10941export interface WatchEvent { 10942 /** 10943 * Sandbox path of the file to observe. The sandbox path contains the file name. 10944 * 10945 * @type { string } 10946 * @readonly 10947 * @syscap SystemCapability.FileManagement.File.FileIO 10948 * @since 10 10949 */ 10950 /** 10951 * Sandbox path of the file to observe. The sandbox path contains the file name. 10952 * 10953 * @type { string } 10954 * @readonly 10955 * @syscap SystemCapability.FileManagement.File.FileIO 10956 * @crossplatform 10957 * @since 20 10958 */ 10959 readonly fileName: string; 10960 10961 /** 10962 * Events to observe. Multiple events can be separated by a bitwise OR operator (|). 10963 * 0x1: IN_ACCESS: A file is accessed. 10964 * 0x2: IN_MODIFY: The file content is modified. 10965 * 0x4: IN_ATTRIB: The file metadata is modified. 10966 * 0x8: IN_CLOSE_WRITE: A file is opened, written with data, and then closed. 10967 * 0x10: IN_CLOSE_NOWRITE: A file or directory is opened and then closed without data written. 10968 * 0x20: IN_OPEN: A file or directory is opened. 10969 * 0x40: IN_MOVED_FROM: A file in the observed directory is moved. 10970 * 0x80: IN_MOVED_TO: A file is moved to the observed directory. 10971 * 0x100: IN_CREATE: A file or directory is created in the observed directory. 10972 * 0x200: IN_DELETE: A file or directory is deleted from the observed directory. 10973 * 0x400: IN_DELETE_SELF: The observed directory is deleted. After the directory is deleted, the listening stops. 10974 * 0x800: IN_MOVE_SELF: The observed file or directory is moved. After the file or directory is moved, the listening continues. 10975 * 0xfff: IN_ALL_EVENTS: All events. 10976 * 10977 * @type { number } 10978 * @readonly 10979 * @syscap SystemCapability.FileManagement.File.FileIO 10980 * @since 10 10981 */ 10982 /** 10983 * Events to observe. Multiple events can be separated by a bitwise OR operator (|). 10984 * 0x1: IN_ACCESS: A file is accessed. 10985 * 0x2: IN_MODIFY: The file content is modified. 10986 * 0x4: IN_ATTRIB: The file metadata is modified. 10987 * 0x8: IN_CLOSE_WRITE: A file is opened, written with data, and then closed. 10988 * 0x10: IN_CLOSE_NOWRITE: A file or directory is opened and then closed without data written. 10989 * 0x20: IN_OPEN: A file or directory is opened. 10990 * 0x40: IN_MOVED_FROM: A file in the observed directory is moved. 10991 * 0x80: IN_MOVED_TO: A file is moved to the observed directory. 10992 * 0x100: IN_CREATE: A file or directory is created in the observed directory. 10993 * 0x200: IN_DELETE: A file or directory is deleted from the observed directory. 10994 * 0x400: IN_DELETE_SELF: The observed directory is deleted. After the directory is deleted, the listening stops. 10995 * 0x800: IN_MOVE_SELF: The observed file or directory is moved. After the file or directory is moved, the listening continues. 10996 * 0xfff: IN_ALL_EVENTS: All events. 10997 * 10998 * @type { number } 10999 * @readonly 11000 * @syscap SystemCapability.FileManagement.File.FileIO 11001 * @crossplatform 11002 * @since 20 11003 */ 11004 readonly event: number; 11005 11006 /** 11007 * Cookie bound with the event. Currently, only the IN_MOVED_FROM and IN_MOVED_TO events are supported. 11008 * The IN_MOVED_FROM and IN_MOVED_TO events of the same file have the same cookie value. 11009 * 11010 * @type { number } 11011 * @readonly 11012 * @syscap SystemCapability.FileManagement.File.FileIO 11013 * @since 10 11014 */ 11015 /** 11016 * Cookie bound with the event. Currently, only the IN_MOVED_FROM and IN_MOVED_TO events are supported. 11017 * The IN_MOVED_FROM and IN_MOVED_TO events of the same file have the same cookie value. 11018 * 11019 * @type { number } 11020 * @readonly 11021 * @syscap SystemCapability.FileManagement.File.FileIO 11022 * @crossplatform 11023 * @since 20 11024 */ 11025 readonly cookie: number; 11026} 11027 11028/** 11029 * Provides APIs for observing the changes of files or directories. 11030 * Before using the APIs of Watcher, call createWatcher() to create a Watcher object. 11031 * 11032 * @interface Watcher 11033 * @syscap SystemCapability.FileManagement.File.FileIO 11034 * @since 10 11035 */ 11036/** 11037 * Provides APIs for observing the changes of files or directories. 11038 * Before using the APIs of Watcher, call createWatcher() to create a Watcher object. 11039 * 11040 * @interface Watcher 11041 * @syscap SystemCapability.FileManagement.File.FileIO 11042 * @crossplatform 11043 * @since 20 11044 */ 11045export interface Watcher { 11046 /** 11047 * Starts listening. 11048 * 11049 * @throws { BusinessError } 13900002 - No such file or directory 11050 * @throws { BusinessError } 13900008 - Bad file descriptor 11051 * @throws { BusinessError } 13900011 - Out of memory 11052 * @throws { BusinessError } 13900012 - Permission denied 11053 * @throws { BusinessError } 13900013 - Bad address 11054 * @throws { BusinessError } 13900015 - File exists 11055 * @throws { BusinessError } 13900018 - Not a directory 11056 * @throws { BusinessError } 13900020 - Invalid argument 11057 * @throws { BusinessError } 13900021 - File table overflow 11058 * @throws { BusinessError } 13900022 - Too many open files 11059 * @throws { BusinessError } 13900025 - No space left on device 11060 * @throws { BusinessError } 13900030 - File name too long 11061 * @throws { BusinessError } 13900042 - Unknown error 11062 * @syscap SystemCapability.FileManagement.File.FileIO 11063 * @since 10 11064 */ 11065 /** 11066 * Starts listening. 11067 * 11068 * @throws { BusinessError } 13900002 - No such file or directory 11069 * @throws { BusinessError } 13900008 - Bad file descriptor 11070 * @throws { BusinessError } 13900011 - Out of memory 11071 * @throws { BusinessError } 13900012 - Permission denied 11072 * @throws { BusinessError } 13900013 - Bad address 11073 * @throws { BusinessError } 13900015 - File exists 11074 * @throws { BusinessError } 13900018 - Not a directory 11075 * @throws { BusinessError } 13900020 - Invalid argument 11076 * @throws { BusinessError } 13900021 - File table overflow 11077 * @throws { BusinessError } 13900022 - Too many open files 11078 * @throws { BusinessError } 13900025 - No space left on device 11079 * @throws { BusinessError } 13900030 - File name too long 11080 * @throws { BusinessError } 13900042 - Unknown error 11081 * @syscap SystemCapability.FileManagement.File.FileIO 11082 * @crossplatform 11083 * @since 20 11084 */ 11085 start(): void; 11086 11087 /** 11088 * Stops listening and removes the Watcher object. 11089 * 11090 * @throws { BusinessError } 13900002 - No such file or directory 11091 * @throws { BusinessError } 13900008 - Bad file descriptor 11092 * @throws { BusinessError } 13900011 - Out of memory 11093 * @throws { BusinessError } 13900012 - Permission denied 11094 * @throws { BusinessError } 13900013 - Bad address 11095 * @throws { BusinessError } 13900015 - File exists 11096 * @throws { BusinessError } 13900018 - Not a directory 11097 * @throws { BusinessError } 13900020 - Invalid argument 11098 * @throws { BusinessError } 13900021 - File table overflow 11099 * @throws { BusinessError } 13900022 - Too many open files 11100 * @throws { BusinessError } 13900025 - No space left on device 11101 * @throws { BusinessError } 13900030 - File name too long 11102 * @throws { BusinessError } 13900042 - Unknown error 11103 * @syscap SystemCapability.FileManagement.File.FileIO 11104 * @since 10 11105 */ 11106 /** 11107 * Stops listening and removes the Watcher object. 11108 * 11109 * @throws { BusinessError } 13900002 - No such file or directory 11110 * @throws { BusinessError } 13900008 - Bad file descriptor 11111 * @throws { BusinessError } 13900011 - Out of memory 11112 * @throws { BusinessError } 13900012 - Permission denied 11113 * @throws { BusinessError } 13900013 - Bad address 11114 * @throws { BusinessError } 13900015 - File exists 11115 * @throws { BusinessError } 13900018 - Not a directory 11116 * @throws { BusinessError } 13900020 - Invalid argument 11117 * @throws { BusinessError } 13900021 - File table overflow 11118 * @throws { BusinessError } 13900022 - Too many open files 11119 * @throws { BusinessError } 13900025 - No space left on device 11120 * @throws { BusinessError } 13900030 - File name too long 11121 * @throws { BusinessError } 13900042 - Unknown error 11122 * @syscap SystemCapability.FileManagement.File.FileIO 11123 * @crossplatform 11124 * @since 20 11125 */ 11126 stop(): void; 11127} 11128 11129/** 11130 * Represents the information obtained by the ReaderIterator object. 11131 * 11132 * @interface ReaderIteratorResult 11133 * @syscap SystemCapability.FileManagement.File.FileIO 11134 * @since 11 11135 */ 11136/** 11137 * Represents the information obtained by the ReaderIterator object. 11138 * 11139 * @interface ReaderIteratorResult 11140 * @syscap SystemCapability.FileManagement.File.FileIO 11141 * @crossplatform 11142 * @since 20 11143 */ 11144export interface ReaderIteratorResult { 11145 /** 11146 * Whether the iteration is complete. 11147 * The value true means the iteration is complete; the value false means the iteration is not complete. 11148 * 11149 * @type { boolean } 11150 * @syscap SystemCapability.FileManagement.File.FileIO 11151 * @since 11 11152 */ 11153 /** 11154 * Whether the iteration is complete. 11155 * The value true means the iteration is complete; the value false means the iteration is not complete. 11156 * 11157 * @type { boolean } 11158 * @syscap SystemCapability.FileManagement.File.FileIO 11159 * @crossplatform 11160 * @since 20 11161 */ 11162 done: boolean; 11163 11164 /** 11165 * File text content read line by line. 11166 * 11167 * @type { string } 11168 * @syscap SystemCapability.FileManagement.File.FileIO 11169 * @since 11 11170 */ 11171 /** 11172 * File text content read line by line. 11173 * 11174 * @type { string } 11175 * @syscap SystemCapability.FileManagement.File.FileIO 11176 * @crossplatform 11177 * @since 20 11178 */ 11179 value: string; 11180} 11181 11182/** 11183 * Provides a ReaderIterator object. Before calling APIs of ReaderIterator, 11184 * you need to use readLines() to create a ReaderIterator instance. 11185 * 11186 * @interface ReaderIterator 11187 * @syscap SystemCapability.FileManagement.File.FileIO 11188 * @since 11 11189 */ 11190/** 11191 * Provides a ReaderIterator object. Before calling APIs of ReaderIterator, 11192 * you need to use readLines() to create a ReaderIterator instance. 11193 * 11194 * @interface ReaderIterator 11195 * @syscap SystemCapability.FileManagement.File.FileIO 11196 * @crossplatform 11197 * @since 20 11198 */ 11199declare interface ReaderIterator { 11200 /** 11201 * Obtains the ReaderIterator result. 11202 * 11203 * @returns { ReaderIteratorResult } ReaderIteratorResult object obtained. 11204 * @throws { BusinessError } 13900005 - I/O error 11205 * @throws { BusinessError } 13900037 - No data available 11206 * @throws { BusinessError } 13900042 - Unknown error 11207 * @syscap SystemCapability.FileManagement.File.FileIO 11208 * @since 11 11209 */ 11210 /** 11211 * Obtains the ReaderIterator result. 11212 * 11213 * @returns { ReaderIteratorResult } ReaderIteratorResult object obtained. 11214 * @throws { BusinessError } 13900005 - I/O error 11215 * @throws { BusinessError } 13900037 - No data available 11216 * @throws { BusinessError } 13900042 - Unknown error 11217 * @syscap SystemCapability.FileManagement.File.FileIO 11218 * @crossplatform 11219 * @since 20 11220 */ 11221 next(): ReaderIteratorResult; 11222} 11223 11224/** 11225 * File filter type 11226 * 11227 * @syscap SystemCapability.FileManagement.File.FileIO 11228 * @crossplatform 11229 * @since 10 11230 */ 11231/** 11232 * Defines the file filtering configuration used by listFile(). 11233 * 11234 * @interface Filter 11235 * @syscap SystemCapability.FileManagement.File.FileIO 11236 * @crossplatform 11237 * @atomicservice 11238 * @since 11 11239 */ 11240export interface Filter { 11241 /** 11242 * The suffix of the file. 11243 * 11244 * @type { ?Array<string> } 11245 * @syscap SystemCapability.FileManagement.File.FileIO 11246 * @since 10 11247 */ 11248 /** 11249 * Locate files that fully match the specified file name extensions, which are of the OR relationship. 11250 * 11251 * @type { ?Array<string> } 11252 * @syscap SystemCapability.FileManagement.File.FileIO 11253 * @crossplatform 11254 * @atomicservice 11255 * @since 11 11256 */ 11257 suffix?: Array<string>; 11258 /** 11259 * The display name of the file. 11260 * 11261 * @type { ?Array<string> } 11262 * @syscap SystemCapability.FileManagement.File.FileIO 11263 * @since 10 11264 */ 11265 /** 11266 * Locate files that fuzzy match the specified file names, which are of the OR relationship. 11267 * Currently, only the wildcard * is supported. 11268 * 11269 * @type { ?Array<string> } 11270 * @syscap SystemCapability.FileManagement.File.FileIO 11271 * @crossplatform 11272 * @atomicservice 11273 * @since 11 11274 */ 11275 displayName?: Array<string>; 11276 /** 11277 * The mimetype of the file. 11278 * 11279 * @type { ?Array<string> } 11280 * @syscap SystemCapability.FileManagement.File.FileIO 11281 * @since 10 11282 */ 11283 /** 11284 * Locate files that fully match the specified MIME types, which are of the OR relationship. 11285 * 11286 * @type { ?Array<string> } 11287 * @syscap SystemCapability.FileManagement.File.FileIO 11288 * @crossplatform 11289 * @atomicservice 11290 * @since 11 11291 */ 11292 mimeType?: Array<string>; 11293 /** 11294 * The exceeding size of the file. 11295 * 11296 * @type { ?number } 11297 * @syscap SystemCapability.FileManagement.File.FileIO 11298 * @since 10 11299 */ 11300 /** 11301 * Locate files that are greater than or equal to the specified size. 11302 * 11303 * @type { ?number } 11304 * @syscap SystemCapability.FileManagement.File.FileIO 11305 * @crossplatform 11306 * @atomicservice 11307 * @since 11 11308 */ 11309 fileSizeOver?: number; 11310 /** 11311 * The last modification time of the file. 11312 * 11313 * @type { ?number } 11314 * @syscap SystemCapability.FileManagement.File.FileIO 11315 * @since 10 11316 */ 11317 /** 11318 * Locate files whose last modification time is the same or later than the specified time. 11319 * 11320 * @type { ?number } 11321 * @syscap SystemCapability.FileManagement.File.FileIO 11322 * @crossplatform 11323 * @atomicservice 11324 * @since 11 11325 */ 11326 lastModifiedAfter?: number; 11327 /** 11328 * Whether to exclude media files. 11329 * 11330 * @type { ?boolean } 11331 * @syscap SystemCapability.FileManagement.File.FileIO 11332 * @since 10 11333 */ 11334 /** 11335 * Whether to exclude the files already in Media. The value true means to exclude the files already in Media; 11336 * the value false means not to exclude the files already in Media. 11337 * 11338 * @type { ?boolean } 11339 * @syscap SystemCapability.FileManagement.File.FileIO 11340 * @crossplatform 11341 * @atomicservice 11342 * @since 11 11343 */ 11344 excludeMedia?: boolean; 11345} 11346 11347/** 11348 * Conflict Files type 11349 * 11350 * @syscap SystemCapability.FileManagement.File.FileIO 11351 * @since 10 11352 */ 11353/** 11354 * Defines conflicting file information used in copyDir() or moveDir(). 11355 * 11356 * @interface ConflictFiles 11357 * @syscap SystemCapability.FileManagement.File.FileIO 11358 * @since 11 11359 */ 11360/** 11361 * Defines conflicting file information used in copyDir() or moveDir(). 11362 * 11363 * @interface ConflictFiles 11364 * @syscap SystemCapability.FileManagement.File.FileIO 11365 * @crossplatform 11366 * @since 20 11367 */ 11368export interface ConflictFiles { 11369 /** 11370 * The path of the source file. 11371 * 11372 * @type { string } 11373 * @syscap SystemCapability.FileManagement.File.FileIO 11374 * @since 10 11375 */ 11376 /** 11377 * The path of the source file. 11378 * 11379 * @type { string } 11380 * @syscap SystemCapability.FileManagement.File.FileIO 11381 * @since 11 11382 */ 11383 /** 11384 * The path of the source file. 11385 * 11386 * @type { string } 11387 * @syscap SystemCapability.FileManagement.File.FileIO 11388 * @crossplatform 11389 * @since 20 11390 */ 11391 srcFile: string; 11392 11393 /** 11394 * The path of the source file. 11395 * 11396 * @type { string } 11397 * @syscap SystemCapability.FileManagement.File.FileIO 11398 * @since 10 11399 */ 11400 /** 11401 * The path of the destination file. 11402 * 11403 * @type { string } 11404 * @syscap SystemCapability.FileManagement.File.FileIO 11405 * @since 11 11406 */ 11407 /** 11408 * The path of the destination file. 11409 * 11410 * @type { string } 11411 * @syscap SystemCapability.FileManagement.File.FileIO 11412 * @crossplatform 11413 * @since 20 11414 */ 11415 destFile: string; 11416} 11417 11418/** 11419 * Defines the options used in readLines(). 11420 * 11421 * @interface Options 11422 * @syscap SystemCapability.FileManagement.File.FileIO 11423 * @since 11 11424 */ 11425/** 11426 * Defines the options used in readLines(). 11427 * 11428 * @interface Options 11429 * @syscap SystemCapability.FileManagement.File.FileIO 11430 * @crossplatform 11431 * @since 20 11432 */ 11433export interface Options { 11434 /** 11435 * File encoding format. It is optional. 11436 * 11437 * @type { ?string } 11438 * @syscap SystemCapability.FileManagement.File.FileIO 11439 * @since 11 11440 */ 11441 /** 11442 * File encoding format. It is optional. 11443 * 11444 * @type { ?string } 11445 * @syscap SystemCapability.FileManagement.File.FileIO 11446 * @crossplatform 11447 * @since 20 11448 */ 11449 encoding?: string; 11450} 11451 11452/** 11453 * Defines the options used in read(). 11454 * 11455 * @interface ReadOptions 11456 * @syscap SystemCapability.FileManagement.File.FileIO 11457 * @atomicservice 11458 * @since 11 11459 */ 11460/** 11461 * Defines the options used in read(). 11462 * 11463 * @interface ReadOptions 11464 * @syscap SystemCapability.FileManagement.File.FileIO 11465 * @crossplatform 11466 * @atomicservice 11467 * @since 20 11468 */ 11469export interface ReadOptions { 11470 /** 11471 * Length of the data to read, in bytes. This parameter is optional. The default value is the buffer length. 11472 * 11473 * @type { ?number } 11474 * @syscap SystemCapability.FileManagement.File.FileIO 11475 * @atomicservice 11476 * @since 11 11477 */ 11478 /** 11479 * Length of the data to read, in bytes. This parameter is optional. The default value is the buffer length. 11480 * 11481 * @type { ?number } 11482 * @syscap SystemCapability.FileManagement.File.FileIO 11483 * @crossplatform 11484 * @atomicservice 11485 * @since 20 11486 */ 11487 offset?: number; 11488 /** 11489 * Start position of the file to read (current filePointer plus offset), in bytes. This parameter is optional. 11490 * By default, data is read from the filePointer. 11491 * 11492 * @type { ?number } 11493 * @syscap SystemCapability.FileManagement.File.FileIO 11494 * @atomicservice 11495 * @since 11 11496 */ 11497 /** 11498 * Start position of the file to read (current filePointer plus offset), in bytes. This parameter is optional. 11499 * By default, data is read from the filePointer. 11500 * 11501 * @type { ?number } 11502 * @syscap SystemCapability.FileManagement.File.FileIO 11503 * @crossplatform 11504 * @atomicservice 11505 * @since 20 11506 */ 11507 length?: number; 11508} 11509 11510/** 11511 * Defines the options used in readText(). It inherits from ReadOptions. 11512 * 11513 * @extends ReadOptions 11514 * @interface ReadTextOptions 11515 * @syscap SystemCapability.FileManagement.File.FileIO 11516 * @atomicservice 11517 * @since 11 11518 */ 11519/** 11520 * Defines the options used in readText(). It inherits from ReadOptions. 11521 * 11522 * @extends ReadOptions 11523 * @interface ReadTextOptions 11524 * @syscap SystemCapability.FileManagement.File.FileIO 11525 * @crossplatform 11526 * @atomicservice 11527 * @since 20 11528 */ 11529export interface ReadTextOptions extends ReadOptions { 11530 /** 11531 * Format of the data to be encoded. This parameter is valid only when the data type is string. 11532 * The default value is 'utf-8', which is the only value supported. 11533 * 11534 * @type { ?string } 11535 * @syscap SystemCapability.FileManagement.File.FileIO 11536 * @atomicservice 11537 * @since 11 11538 */ 11539 /** 11540 * Format of the data to be encoded. This parameter is valid only when the data type is string. 11541 * The default value is 'utf-8', which is the only value supported. 11542 * 11543 * @type { ?string } 11544 * @syscap SystemCapability.FileManagement.File.FileIO 11545 * @crossplatform 11546 * @atomicservice 11547 * @since 20 11548 */ 11549 encoding?: string; 11550} 11551 11552/** 11553 * Defines the options use din write(). It inherits from Options. 11554 * 11555 * @extends Options 11556 * @interface WriteOptions 11557 * @syscap SystemCapability.FileManagement.File.FileIO 11558 * @atomicservice 11559 * @since 11 11560 */ 11561/** 11562 * Defines the options use din write(). It inherits from Options. 11563 * 11564 * @extends Options 11565 * @interface WriteOptions 11566 * @syscap SystemCapability.FileManagement.File.FileIO 11567 * @crossplatform 11568 * @atomicservice 11569 * @since 20 11570 */ 11571export interface WriteOptions extends Options { 11572 /** 11573 * Option for creating the writeable stream. You must specify one of the following options. 11574 * OpenMode.READ_ONLY(0o0): read-only, which is the default value. 11575 * OpenMode.WRITE_ONLY(0o1): write-only. 11576 * OpenMode.READ_WRITE(0o2): read/write. 11577 * You can also specify the following options, separated by a bitwise OR operator (|). 11578 * By default, no additional options are given. 11579 * OpenMode.CREATE(0o100): If the file does not exist, create it. 11580 * OpenMode.TRUNC(0o1000): If the file exists and is opened in write mode, truncate the file length to 0. 11581 * OpenMode.APPEND(0o2000): Open the file in append mode. New data will be added to the end of the file. 11582 * OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 11583 * or character special file, perform non-blocking operations on the opened file and in subsequent I/Os. 11584 * OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 11585 * OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 11586 * OpenMode.SYNC(0o4010000): Open the file in synchronous I/O mode. 11587 * 11588 * @type { ?number } 11589 * @syscap SystemCapability.FileManagement.File.FileIO 11590 * @atomicservice 11591 * @since 11 11592 */ 11593 /** 11594 * Option for creating the writeable stream. You must specify one of the following options. 11595 * OpenMode.READ_ONLY(0o0): read-only, which is the default value. 11596 * OpenMode.WRITE_ONLY(0o1): write-only. 11597 * OpenMode.READ_WRITE(0o2): read/write. 11598 * You can also specify the following options, separated by a bitwise OR operator (|). 11599 * By default, no additional options are given. 11600 * OpenMode.CREATE(0o100): If the file does not exist, create it. 11601 * OpenMode.TRUNC(0o1000): If the file exists and is opened in write mode, truncate the file length to 0. 11602 * OpenMode.APPEND(0o2000): Open the file in append mode. New data will be added to the end of the file. 11603 * OpenMode.NONBLOCK(0o4000): If path points to a named pipe (also known as a FIFO), block special file, 11604 * or character special file, perform non-blocking operations on the opened file and in subsequent I/Os. 11605 * OpenMode.DIR(0o200000): If path does not point to a directory, throw an exception. The write permission is not allowed. 11606 * OpenMode.NOFOLLOW(0o400000): If path points to a symbolic link, throw an exception. 11607 * OpenMode.SYNC(0o4010000): Open the file in synchronous I/O mode. 11608 * 11609 * @type { ?number } 11610 * @syscap SystemCapability.FileManagement.File.FileIO 11611 * @crossplatform 11612 * @atomicservice 11613 * @since 20 11614 */ 11615 offset?: number; 11616 /** 11617 * Length of the data to write, in bytes. This parameter is optional. The default value is the buffer length. 11618 * 11619 * @type { ?number } 11620 * @syscap SystemCapability.FileManagement.File.FileIO 11621 * @atomicservice 11622 * @since 11 11623 */ 11624 /** 11625 * Length of the data to write, in bytes. This parameter is optional. The default value is the buffer length. 11626 * 11627 * @type { ?number } 11628 * @syscap SystemCapability.FileManagement.File.FileIO 11629 * @crossplatform 11630 * @atomicservice 11631 * @since 20 11632 */ 11633 length?: number; 11634} 11635 11636/** 11637 * ListFileOptions type 11638 * 11639 * @interface ListFileOptions 11640 * @syscap SystemCapability.FileManagement.File.FileIO 11641 * @atomicservice 11642 * @since 11 11643 */ 11644export interface ListFileOptions { 11645 /** 11646 * Whether to list all files in the subdirectories recursively. This parameter is optional. 11647 * The default value is false. If recursion is false, the names of files and directories that meet the filtering 11648 * requirements in the current directory are returned. If recursion is true, relative paths (starting with /) 11649 * of all files that meet the specified conditions in the current directory are returned. 11650 * 11651 * @type { ?boolean } 11652 * @syscap SystemCapability.FileManagement.File.FileIO 11653 * @atomicservice 11654 * @since 11 11655 */ 11656 recursion?: boolean; 11657 11658 /** 11659 * Number of file names to list. This parameter is optional. The default value is 0, which means to list all files. 11660 * 11661 * @type { ?number } 11662 * @syscap SystemCapability.FileManagement.File.FileIO 11663 * @atomicservice 11664 * @since 11 11665 */ 11666 listNum?: number; 11667 11668 /** 11669 * File filtering configuration. This parameter is optional. It specifies the file filtering conditions. 11670 * 11671 * @type { ?Filter } 11672 * @syscap SystemCapability.FileManagement.File.FileIO 11673 * @atomicservice 11674 * @since 11 11675 */ 11676 filter?: Filter; 11677} 11678 11679/** 11680 * Defines the options used in createRandomAccessFile(). 11681 * 11682 * @interface RandomAccessFileOptions 11683 * @syscap SystemCapability.FileManagement.File.FileIO 11684 * @since 12 11685 */ 11686/** 11687 * Defines the options used in createRandomAccessFile(). 11688 * 11689 * @interface RandomAccessFileOptions 11690 * @syscap SystemCapability.FileManagement.File.FileIO 11691 * @crossplatform 11692 * @since 20 11693 */ 11694export interface RandomAccessFileOptions { 11695 /** 11696 * Start position to read the data, in bytes. This parameter is optional. By default, data is read from the current position. 11697 * 11698 * @type { ?number } 11699 * @syscap SystemCapability.FileManagement.File.FileIO 11700 * @since 12 11701 */ 11702 /** 11703 * Start position to read the data, in bytes. This parameter is optional. By default, data is read from the current position. 11704 * 11705 * @type { ?number } 11706 * @syscap SystemCapability.FileManagement.File.FileIO 11707 * @crossplatform 11708 * @since 20 11709 */ 11710 start?: number; 11711 11712 /** 11713 * End position to read the data, in bytes. This parameter is optional. The default value is the end of the file. 11714 * 11715 * @type { ?number } 11716 * @syscap SystemCapability.FileManagement.File.FileIO 11717 * @since 12 11718 */ 11719 /** 11720 * End position to read the data, in bytes. This parameter is optional. The default value is the end of the file. 11721 * 11722 * @type { ?number } 11723 * @syscap SystemCapability.FileManagement.File.FileIO 11724 * @crossplatform 11725 * @since 20 11726 */ 11727 end?: number; 11728} 11729 11730/** 11731 * Defines the options used in createReadStream(). 11732 * 11733 * @interface ReadStreamOptions 11734 * @syscap SystemCapability.FileManagement.File.FileIO 11735 * @since 12 11736 */ 11737/** 11738 * Defines the options used in createReadStream(). 11739 * 11740 * @interface ReadStreamOptions 11741 * @syscap SystemCapability.FileManagement.File.FileIO 11742 * @crossplatform 11743 * @since 20 11744 */ 11745export interface ReadStreamOptions { 11746 /** 11747 * Start position to read the data, in bytes. This parameter is optional. By default, 11748 * data is read from the current position. 11749 * 11750 * @type { ?number } 11751 * @syscap SystemCapability.FileManagement.File.FileIO 11752 * @since 12 11753 */ 11754 /** 11755 * Start position to read the data, in bytes. This parameter is optional. By default, 11756 * data is read from the current position. 11757 * 11758 * @type { ?number } 11759 * @syscap SystemCapability.FileManagement.File.FileIO 11760 * @crossplatform 11761 * @since 20 11762 */ 11763 start?: number; 11764 11765 /** 11766 * End position to read the data, in bytes. This parameter is optional. 11767 * The default value is the end of the file. 11768 * 11769 * @type { ?number } 11770 * @syscap SystemCapability.FileManagement.File.FileIO 11771 * @since 12 11772 */ 11773 /** 11774 * End position to read the data, in bytes. This parameter is optional. 11775 * The default value is the end of the file. 11776 * 11777 * @type { ?number } 11778 * @syscap SystemCapability.FileManagement.File.FileIO 11779 * @crossplatform 11780 * @since 20 11781 */ 11782 end?: number; 11783} 11784 11785/** 11786 * Defines the options used in createWriteStream(). 11787 * 11788 * @interface WriteStreamOptions 11789 * @syscap SystemCapability.FileManagement.File.FileIO 11790 * @since 12 11791 */ 11792/** 11793 * Defines the options used in createWriteStream(). 11794 * 11795 * @interface WriteStreamOptions 11796 * @syscap SystemCapability.FileManagement.File.FileIO 11797 * @crossplatform 11798 * @since 20 11799 */ 11800export interface WriteStreamOptions { 11801 /** 11802 * Option for creating the writeable stream. 11803 * 11804 * @type { ?number } 11805 * @syscap SystemCapability.FileManagement.File.FileIO 11806 * @since 12 11807 */ 11808 /** 11809 * Option for creating the writeable stream. 11810 * 11811 * @type { ?number } 11812 * @syscap SystemCapability.FileManagement.File.FileIO 11813 * @crossplatform 11814 * @since 20 11815 */ 11816 mode?: number; 11817 /** 11818 * Start position to write the data, in bytes. This parameter is optional. 11819 * By default, data is written from the beginning of the file. 11820 * 11821 * @type { ?number } 11822 * @syscap SystemCapability.FileManagement.File.FileIO 11823 * @since 12 11824 */ 11825 /** 11826 * Start position to write the data, in bytes. This parameter is optional. 11827 * By default, data is written from the beginning of the file. 11828 * 11829 * @type { ?number } 11830 * @syscap SystemCapability.FileManagement.File.FileIO 11831 * @crossplatform 11832 * @since 20 11833 */ 11834 start?: number; 11835} 11836 11837/** 11838 * The listeners of Distributed File System. 11839 * 11840 * @typedef DfsListeners 11841 * @syscap SystemCapability.FileManagement.File.FileIO 11842 * @since 12 11843 */ 11844export interface DfsListeners { 11845 /** 11846 * The Listener of Distributed File System status 11847 * 11848 * @param { string } networkId - The networkId of device. 11849 * @param { number } status - The status code of Distributed File System. 11850 * @syscap SystemCapability.FileManagement.File.FileIO 11851 * @since 12 11852 */ 11853 onStatus(networkId: string, status: number): void; 11854} 11855 11856/** 11857 * Enumerates the types of the relative offset position used in lseek(). 11858 * 11859 * @enum { number } whence type 11860 * @syscap SystemCapability.FileManagement.File.FileIO 11861 * @since 11 11862 */ 11863/** 11864 * Enumerates the types of the relative offset position used in lseek(). 11865 * 11866 * @enum { number } whence type 11867 * @syscap SystemCapability.FileManagement.File.FileIO 11868 * @crossplatform 11869 * @since 20 11870 */ 11871declare enum WhenceType { 11872 /** 11873 * Starting position of the file offset. 11874 * 11875 * @syscap SystemCapability.FileManagement.File.FileIO 11876 * @since 11 11877 */ 11878 /** 11879 * Starting position of the file offset. 11880 * 11881 * @syscap SystemCapability.FileManagement.File.FileIO 11882 * @crossplatform 11883 * @since 20 11884 */ 11885 SEEK_SET = 0, 11886 11887 /** 11888 * Current position of the file offset. 11889 * 11890 * @syscap SystemCapability.FileManagement.File.FileIO 11891 * @since 11 11892 */ 11893 /** 11894 * Current position of the file offset. 11895 * 11896 * @syscap SystemCapability.FileManagement.File.FileIO 11897 * @crossplatform 11898 * @since 20 11899 */ 11900 SEEK_CUR = 1, 11901 11902 /** 11903 * Ending position of the file offset. 11904 * 11905 * @syscap SystemCapability.FileManagement.File.FileIO 11906 * @since 11 11907 */ 11908 /** 11909 * Ending position of the file offset. 11910 * 11911 * @syscap SystemCapability.FileManagement.File.FileIO 11912 * @crossplatform 11913 * @since 20 11914 */ 11915 SEEK_END = 2 11916} 11917 11918/** 11919 * Enumeration of different types of file location. 11920 * 11921 * @enum { number } location type 11922 * @syscap SystemCapability.FileManagement.File.FileIO 11923 * @since 11 11924 */ 11925declare enum LocationType { 11926 /** 11927 * The file is stored in a local device. 11928 * 11929 * @syscap SystemCapability.FileManagement.File.FileIO 11930 * @since 11 11931 */ 11932 LOCAL = 1 << 0, 11933 11934 /** 11935 * The file is stored in the cloud. 11936 * 11937 * @syscap SystemCapability.FileManagement.File.FileIO 11938 * @since 11 11939 */ 11940 CLOUD = 1 << 1 11941} 11942 11943/** 11944 * Enumerates the access modes to verify. If this parameter is left blank, the system checks whether the file exists. 11945 * 11946 * @enum { number } access mode type 11947 * @syscap SystemCapability.FileManagement.File.FileIO 11948 * @atomicservice 11949 * @since 12 11950 */ 11951/** 11952 * Enumerates the access modes to verify. If this parameter is left blank, the system checks whether the file exists. 11953 * 11954 * @enum { number } access mode type 11955 * @syscap SystemCapability.FileManagement.File.FileIO 11956 * @crossplatform 11957 * @atomicservice 11958 * @since 20 11959 */ 11960declare enum AccessModeType { 11961 /** 11962 * Whether the file exists. 11963 * 11964 * @syscap SystemCapability.FileManagement.File.FileIO 11965 * @atomicservice 11966 * @since 12 11967 */ 11968 /** 11969 * Whether the file exists. 11970 * 11971 * @syscap SystemCapability.FileManagement.File.FileIO 11972 * @crossplatform 11973 * @atomicservice 11974 * @since 20 11975 */ 11976 EXIST = 0, 11977 11978 /** 11979 * Verify the write permission on the file. 11980 * 11981 * @syscap SystemCapability.FileManagement.File.FileIO 11982 * @atomicservice 11983 * @since 12 11984 */ 11985 /** 11986 * Verify the write permission on the file. 11987 * 11988 * @syscap SystemCapability.FileManagement.File.FileIO 11989 * @crossplatform 11990 * @atomicservice 11991 * @since 20 11992 */ 11993 WRITE = 2, 11994 11995 /** 11996 * Verify the read permission on the file. 11997 * 11998 * @syscap SystemCapability.FileManagement.File.FileIO 11999 * @atomicservice 12000 * @since 12 12001 */ 12002 /** 12003 * Verify the read permission on the file. 12004 * 12005 * @syscap SystemCapability.FileManagement.File.FileIO 12006 * @crossplatform 12007 * @atomicservice 12008 * @since 20 12009 */ 12010 READ = 4, 12011 12012 /** 12013 * Verify the read/write permission on the file. 12014 * 12015 * @syscap SystemCapability.FileManagement.File.FileIO 12016 * @atomicservice 12017 * @since 12 12018 */ 12019 /** 12020 * Verify the read/write permission on the file. 12021 * 12022 * @syscap SystemCapability.FileManagement.File.FileIO 12023 * @crossplatform 12024 * @atomicservice 12025 * @since 20 12026 */ 12027 READ_WRITE = 6 12028} 12029 12030/** 12031 * Enumerates the locations of the file to verify. 12032 * 12033 * @enum { number } access flag type 12034 * @syscap SystemCapability.FileManagement.File.FileIO 12035 * @since 12 12036 */ 12037declare enum AccessFlagType { 12038 /** 12039 * The file is stored locally. 12040 * 12041 * @syscap SystemCapability.FileManagement.File.FileIO 12042 * @since 12 12043 */ 12044 LOCAL = 0 12045} 12046