1/* 2 * Copyright (c) 2021 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 */ 15import { AsyncCallback } from './basic' 16 17export default fileIO; 18 19/** 20 * fileio 21 * @syscap SystemCapability.FileManagement.File.FileIO 22 * @since 6 23 * @import import fileio from '@ohos.fileio'; 24 * @permission N/A 25 */ 26declare namespace fileIO { 27 export { access }; 28 export { accessSync }; 29 export { chmod }; 30 export { chmodSync }; 31 export { chown }; 32 export { chownSync }; 33 export { close }; 34 export { closeSync }; 35 export { copyFile }; 36 export { copyFileSync }; 37 export { createStream }; 38 export { createStreamSync }; 39 export { createWatcher }; 40 export { fchmod }; 41 export { fchmodSync }; 42 export { fchown }; 43 export { fchownSync }; 44 export { fdatasync }; 45 export { fdatasyncSync }; 46 export { fdopenStream }; 47 export { fdopenStreamSync }; 48 export { fstat }; 49 export { fstatSync }; 50 export { fsync }; 51 export { fsyncSync }; 52 export { ftruncate }; 53 export { ftruncateSync }; 54 export { hash }; 55 export { lchown }; 56 export { lchownSync }; 57 export { lstat }; 58 export { lstatSync }; 59 export { mkdir }; 60 export { mkdirSync }; 61 export { mkdtemp }; 62 export { mkdtempSync }; 63 export { open }; 64 export { openSync }; 65 export { opendir }; 66 export { opendirSync }; 67 export { read }; 68 export { readSync }; 69 export { readText }; 70 export { readTextSync }; 71 export { rename }; 72 export { renameSync }; 73 export { rmdir }; 74 export { rmdirSync }; 75 export { stat }; 76 export { statSync }; 77 export { symlink }; 78 export { symlinkSync }; 79 export { truncate }; 80 export { truncateSync }; 81 export { unlink }; 82 export { unlinkSync }; 83 export { write }; 84 export { writeSync }; 85 export { Dir }; 86 export { Dirent }; 87 export { ReadOut }; 88 export { Stat }; 89 export { Stream }; 90 export { Watcher }; 91} 92 93/** 94 * access. 95 * 96 * @note N/A 97 * @syscap SystemCapability.FileManagement.File.FileIO 98 * @since 6 99 * @permission N/A 100 * @function access 101 * @param {string} path - path. 102 * @param {number} [mode = 0] - mode. 103 * @param {AsyncCallback<void>} [callback] - callback. 104 * @returns {void | Promise<void>} no callback return Promise otherwise return void 105 * @throws {TypedError} Parameter check failed 106 */ 107declare function access(path: string, mode?: number): Promise<void>; 108declare function access(path: string, callback: AsyncCallback<void>): void; 109declare function access(path: string, mode: number, callback: AsyncCallback<void>): void; 110/** 111 * accessSync. 112 * 113 * @note N/A 114 * @syscap SystemCapability.FileManagement.File.FileIO 115 * @since 6 116 * @permission N/A 117 * @function accessSync 118 * @param {string} path - path. 119 * @param {number} [mode = 0] - mode. 120 * @returns {void} access success 121 * @throws {TypedError | Error} access fail 122 */ 123declare function accessSync(path: string, mode?: number): void; 124/** 125 * close. 126 * 127 * @note N/A 128 * @syscap SystemCapability.FileManagement.File.FileIO 129 * @since 7 130 * @permission N/A 131 * @function close 132 * @param {number} fd - fd. 133 * @param {AsyncCallback<void>} [callback] - callback. 134 * @returns {void | Promise<void>} no callback return Promise otherwise return void 135 * @throws {TypedError} Parameter check failed 136 */ 137declare function close(fd: number): Promise<void>; 138declare function close(fd: number, callback: AsyncCallback<void>): void; 139/** 140 * closeSync. 141 * 142 * @note N/A 143 * @syscap SystemCapability.FileManagement.File.FileIO 144 * @since 6 145 * @permission N/A 146 * @function closeSync 147 * @param {number} fd - fd. 148 * @returns {void} close success 149 * @throws {TypedError | Error} close fail 150 */ 151declare function closeSync(fd: number): void; 152/** 153 * copyFile. 154 * 155 * @note N/A 156 * @syscap SystemCapability.FileManagement.File.FileIO 157 * @since 6 158 * @permission N/A 159 * @function copyFile 160 * @param {string | number} src - src. 161 * @param {string | number} dest - dest. 162 * @param {number} [mode = 0] - mode. 163 * @param {AsyncCallback<void>} [callback] - callback. 164 * @returns {void | Promise<void>} no callback return Promise otherwise return void 165 * @throws {TypedError} Parameter check failed 166 */ 167declare function copyFile(src: string | number, dest: string | number, mode?: number): Promise<void>; 168declare function copyFile(src: string | number, dest: string | number, callback: AsyncCallback<void>): void; 169declare function copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback<void>): void; 170/** 171 * copyFileSync. 172 * 173 * @note N/A 174 * @syscap SystemCapability.FileManagement.File.FileIO 175 * @since 6 176 * @permission N/A 177 * @function copyFileSync 178 * @param {string | number} src - src. 179 * @param {string | number} dest - dest. 180 * @param {number} [mode = 0] - mode. 181 * @returns {void} copyFile success 182 * @throws {TypedError | Error} copyFile fail 183 */ 184declare function copyFileSync(src: string | number, dest: string | number, mode?: number): void; 185/** 186 * createStream. 187 * 188 * @note N/A 189 * @syscap SystemCapability.FileManagement.File.FileIO 190 * @since 7 191 * @permission N/A 192 * @function createStream 193 * @param {string} path - path. 194 * @param {string} mode - mode. 195 * @param {AsyncCallback<Stream>} [callback] - callback. 196 * @returns {void | Promise<Stream>} no callback return Promise otherwise return Stream 197 * @throws {TypedError} Parameter check failed 198 */ 199declare function createStream(path: string, mode: string): Promise<Stream>; 200declare function createStream(path: string, mode: string, callback: AsyncCallback<Stream>): void; 201/** 202 * createStreamSync. 203 * 204 * @note N/A 205 * @syscap SystemCapability.FileManagement.File.FileIO 206 * @since 7 207 * @permission N/A 208 * @function createStreamSync 209 * @param {string} path - path. 210 * @param {string} mode - mode. 211 * @returns {Stream} createStream 212 * @throws {TypedError} Parameter check failed 213 */ 214declare function createStreamSync(path: string, mode: string): Stream; 215/** 216 * chown. 217 * 218 * @note N/A 219 * @syscap SystemCapability.FileManagement.File.FileIO 220 * @since 7 221 * @permission N/A 222 * @function appendFile 223 * @param {string} path - path. 224 * @param {number} uid - mode. 225 * @param {number} gid - mode. 226 * @param {AsyncCallback<void>} [callback] - callback. 227 * @returns {void | Promise<void>} no callback return Promise otherwise return void 228 * @throws {TypedError} Parameter check failed 229 */ 230declare function chown(path: string, uid: number, gid: number): Promise<void>; 231declare function chown(path: string, uid: number, gid: number, callback: AsyncCallback<void>): void; 232/** 233 * chownSync. 234 * 235 * @note N/A 236 * @syscap SystemCapability.FileManagement.File.FileIO 237 * @since 7 238 * @permission N/A 239 * @function appendFile 240 * @param {string} path - path. 241 * @param {number} uid - mode. 242 * @param {number} gid - mode. 243 * @returns {void} chown success 244 * @throws {TypedError | Error} chown fail 245 */ 246declare function chownSync(path: string, uid: number, gid: number): void; 247/** 248 * chmod. 249 * 250 * @note N/A 251 * @syscap SystemCapability.FileManagement.File.FileIO 252 * @since 7 253 * @permission N/A 254 * @function chmod 255 * @param {string} path - path. 256 * @param {number} mode - mode. 257 * @param {AsyncCallback<void>} [callback] - callback. 258 * @returns {void | Promise<void>} no callback return Promise otherwise return void 259 * @throws {TypedError} Parameter check failed 260 */ 261declare function chmod(path: string, mode: number): Promise<void>; 262declare function chmod(path: string, mode: number, callback: AsyncCallback<void>): void; 263/** 264 * chmodSync. 265 * 266 * @note N/A 267 * @syscap SystemCapability.FileManagement.File.FileIO 268 * @since 7 269 * @permission N/A 270 * @function chmodSync 271 * @param {string} path - path. 272 * @param {number} mode - mode. 273 * @returns {void} chmod success 274 * @throws {TypedError | Error} chmod fail 275 */ 276declare function chmodSync(path: string, mode: number): void; 277/** 278 * ftruncate. 279 * 280 * @note N/A 281 * @syscap SystemCapability.FileManagement.File.FileIO 282 * @since 7 283 * @permission N/A 284 * @function ftruncate 285 * @param {number} fd - fd. 286 * @param {number} [len = 0] - len. 287 * @param {AsyncCallback<void>} [callback] - callback. 288 * @returns {void | Promise<void>} no callback return Promise otherwise return void 289 * @throws {TypedError} Parameter check failed 290 */ 291declare function ftruncate(fd: number, len?: number): Promise<void>; 292declare function ftruncate(fd: number, callback: AsyncCallback<void>): void; 293declare function ftruncate(fd: number, len: number, callback: AsyncCallback<void>): void; 294/** 295 * ftruncateSync. 296 * 297 * @note N/A 298 * @syscap SystemCapability.FileManagement.File.FileIO 299 * @since 7 300 * @permission N/A 301 * @function ftruncateSync 302 * @param {number} fd - fd. 303 * @param {number} [len = 0] - len. 304 * @returns {void} ftruncate success 305 * @throws {TypedError | Error} ftruncate fail 306 */ 307declare function ftruncateSync(fd: number, len?: number): void; 308/** 309 * fsync. 310 * 311 * @note N/A 312 * @syscap SystemCapability.FileManagement.File.FileIO 313 * @since 7 314 * @permission N/A 315 * @function fsync 316 * @param {number} fd - fd. 317 * @param {AsyncCallback<void>} [callback] - callback. 318 * @returns {void | Promise<void>} no callback return Promise otherwise return void 319 * @throws {TypedError} Parameter check failed 320 */ 321declare function fsync(fd: number): Promise<void>; 322declare function fsync(fd: number, callback: AsyncCallback<void>): void; 323/** 324 * fsyncSync. 325 * 326 * @note N/A 327 * @syscap SystemCapability.FileManagement.File.FileIO 328 * @since 7 329 * @permission N/A 330 * @function fsyncSync 331 * @param {number} fd - fd. 332 * @returns {void} fsync success 333 * @throws {TypedError | Error} fsync fail 334 */ 335declare function fsyncSync(fd: number): void; 336/** 337 * fstat. 338 * 339 * @note N/A 340 * @syscap SystemCapability.FileManagement.File.FileIO 341 * @since 7 342 * @permission N/A 343 * @function fstat 344 * @param {number} fd - fd. 345 * @returns {Stat} 346 * @throws {TypedError | Error} fstat fail 347 */ 348declare function fstat(fd: number): Promise<Stat>; 349declare function fstat(fd: number, callback: AsyncCallback<Stat>): void; 350/** 351 * fstatSync. 352 * 353 * @note N/A 354 * @syscap SystemCapability.FileManagement.File.FileIO 355 * @since 7 356 * @permission N/A 357 * @function fstatSync 358 * @param {number} fd - fd. 359 * @returns {Stat} 360 * @throws {TypedError | Error} fstat fail 361 */ 362declare function fstatSync(fd: number): Stat; 363/** 364 * fdatasync. 365 * 366 * @note N/A 367 * @syscap SystemCapability.FileManagement.File.FileIO 368 * @since 7 369 * @permission N/A 370 * @function fdatasync 371 * @param {number} fd - fd. 372 * @param {AsyncCallback<void>} [callback] - callback. 373 * @returns {void | Promise<void>} no callback return Promise otherwise return void 374 * @throws {TypedError} Parameter check failed 375 */ 376declare function fdatasync(fd: number): Promise<void>; 377declare function fdatasync(fd: number, callback: AsyncCallback<void>): void; 378/** 379 * fdatasyncSync. 380 * 381 * @note N/A 382 * @syscap SystemCapability.FileManagement.File.FileIO 383 * @since 7 384 * @permission N/A 385 * @function fdatasyncSync 386 * @param {number} fd - fd. 387 * @returns {void} fdatasync success 388 * @throws {TypedError | Error} fdatasync fail 389 */ 390declare function fdatasyncSync(fd: number): void; 391/** 392 * fchown. 393 * 394 * @note N/A 395 * @syscap SystemCapability.FileManagement.File.FileIO 396 * @since 7 397 * @permission N/A 398 * @function fchown 399 * @param {number} fd - fd. 400 * @param {number} uid - uid. 401 * @param {number} gid - gid. 402 * @param {AsyncCallback<void>} [callback] - callback. 403 * @returns {void | Promise<void>} no callback return Promise otherwise return void 404 * @throws {TypedError} Parameter check failed 405 */ 406declare function fchown(fd: number, uid: number, gid: number): Promise<void>; 407declare function fchown(fd: number, uid: number, gid: number, callback: AsyncCallback<void>): void; 408/** 409 * fchownSync. 410 * 411 * @note N/A 412 * @syscap SystemCapability.FileManagement.File.FileIO 413 * @since 7 414 * @permission N/A 415 * @function fchownSync 416 * @param {number} fd - fd. 417 * @param {number} uid - uid. 418 * @param {number} gid - gid. 419 * @returns {void} fchown success 420 * @throws {TypedError | Error} fchown fail 421 */ 422declare function fchownSync(fd: number, uid: number, gid: number): void; 423/** 424 * fchmod. 425 * 426 * @note N/A 427 * @syscap SystemCapability.FileManagement.File.FileIO 428 * @since 7 429 * @permission N/A 430 * @function fchmod 431 * @param {number} fd - fd. 432 * @param {number} mode - mode. 433 * @param {AsyncCallback<void>} [callback] - callback. 434 * @returns {void | Promise<void>} no callback return Promise otherwise return void 435 * @throws {TypedError} Parameter check failed 436 */ 437declare function fchmod(fd: number, mode: number): Promise<void>; 438declare function fchmod(fd: number, mode: number, callback: AsyncCallback<void>): void; 439/** 440 * fchmodSync. 441 * 442 * @note N/A 443 * @syscap SystemCapability.FileManagement.File.FileIO 444 * @since 7 445 * @permission N/A 446 * @function fchmodSync 447 * @param {number} fd - fd. 448 * @param {number} mode - mode. 449 * @returns {void} fchmod success 450 * @throws {TypedError | Error} fchmod fail 451 */ 452declare function fchmodSync(fd: number, mode: number): void; 453/** 454 * fdopenStream. 455 * @note N/A 456 * @syscap SystemCapability.FileManagement.File.FileIO 457 * @since 7 458 * @permission N/A 459 * @function fdopenStream 460 * @param {number} fd - fd. 461 * @param {string} mode - mode. 462 * @param {AsyncCallback<Stream>} [callback] - callback. 463 * @returns {void | Promise<Stream>} no callback return Promise otherwise return void 464 * @throws {TypedError} Parameter check failed 465 */ 466declare function fdopenStream(fd: number, mode: string): Promise<Stream>; 467declare function fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): void; 468/** 469 * fdopenStreamSync. 470 * @note N/A 471 * @syscap SystemCapability.FileManagement.File.FileIO 472 * @since 7 473 * @permission N/A 474 * @function fdopenStreamSync 475 * @param {number} fd - fd. 476 * @param {string} mode - mode. 477 * @returns {Stream} open stream from fd 478 * @throws {TypedError | Error} open fail 479 */ 480declare function fdopenStreamSync(fd: number, mode: string): Stream; 481 /** 482 * hash. 483 * @static 484 * @note N/A 485 * @syscap SystemCapability.FileManagement.File.FileIO 486 * @since 6 487 * @permission N/A 488 * @function hash 489 * @param {string} path - path. 490 * @param {string} algorithm - algorithm md5 sha1 sha256. 491 * @param {AsyncCallback<string>} [callback] - callback. 492 * @returns {void | Promise<string>} no callback return Promise otherwise return void 493 * @throws {TypedError} Parameter check failed 494 */ 495declare function hash(path: string, algorithm: string): Promise<string>; 496declare function hash(path: string, algorithm: string, callback: AsyncCallback<string>): void; 497/** 498 * lchown. 499 * 500 * @note N/A 501 * @syscap SystemCapability.FileManagement.File.FileIO 502 * @since 7 503 * @permission N/A 504 * @function lchown 505 * @param {string} path - path. 506 * @param {number} uid - uid. 507 * @param {number} gid - gid. 508 * @param {AsyncCallback<void>} [callback] - callback. 509 * @returns {void | Promise<void>} no callback return Promise otherwise return void 510 * @throws {TypedError} Parameter check failed 511 */ 512declare function lchown(path: string, uid: number, gid: number): Promise<void>; 513declare function lchown(path: string, uid: number, gid: number, callback: AsyncCallback<void>): void; 514/** 515 * lchownSync. 516 * 517 * @note N/A 518 * @syscap SystemCapability.FileManagement.File.FileIO 519 * @since 7 520 * @permission N/A 521 * @function lchownSync 522 * @param {string} path - path. 523 * @param {number} uid - uid. 524 * @param {number} gid - gid. 525 * @returns {void} lchown success 526 * @throws {TypedError | Error} lchown fail 527 */ 528declare function lchownSync(path: string, uid: number, gid: number): void; 529/** 530 * lstat. 531 * 532 * @note N/A 533 * @syscap SystemCapability.FileManagement.File.FileIO 534 * @since 7 535 * @permission N/A 536 * @function lstat 537 * @param {string} path - path. 538 * @param {AsyncCallback<Stat>} [callback] - callback. 539 * @returns {void | Promise<Stat>} no callback return Promise otherwise return void 540 * @throws {TypedError} Parameter check failed 541 */ 542declare function lstat(path: string): Promise<Stat>; 543declare function lstat(path: string, callback: AsyncCallback<Stat>): void; 544/** 545 * lstatSync. 546 * 547 * @note N/A 548 * @syscap SystemCapability.FileManagement.File.FileIO 549 * @since 7 550 * @permission N/A 551 * @function lstatSync 552 * @param {string} path - path. 553 * @returns {Stat} lstat success 554 * @throws {TypedError | Error} lstat fail 555 */ 556declare function lstatSync(path: string): Stat; 557/** 558 * mkdir. 559 * 560 * @note N/A 561 * @syscap SystemCapability.FileManagement.File.FileIO 562 * @since 6 563 * @permission N/A 564 * @function mkdir 565 * @param {string} path - path. 566 * @param {number} [mode = 0o775] - path. 567 * @param {AsyncCallback<void>} [callback] - callback. 568 * @returns {void | Promise<void>} no callback return Promise otherwise return void 569 * @throws {TypedError} Parameter check failed 570 */ 571declare function mkdir(path: string, mode?: number): Promise<void>; 572declare function mkdir(path: string, callback: AsyncCallback<void>): void; 573declare function mkdir(path: string, mode: number, callback: AsyncCallback<void>): void; 574/** 575 * mkdirSync. 576 * 577 * @note N/A 578 * @syscap SystemCapability.FileManagement.File.FileIO 579 * @since 6 580 * @permission N/A 581 * @function mkdirSync 582 * @param {string} path - path. 583 * @param {number} [mode = 0o775] - path. 584 * @returns {void} mkdir success 585 * @throws {TypedError | Error} mkdir fail 586 */ 587declare function mkdirSync(path: string, mode?: number): void; 588/** 589 * mkdtemp. 590 * 591 * @note N/A 592 * @syscap SystemCapability.FileManagement.File.FileIO 593 * @since 7 594 * @permission N/A 595 * @function mkdtemp 596 * @param {string} prefix - dir prefix. 597 * @param {AsyncCallback<string>} [callback] - callback. 598 * @returns {void | Promise<string>} no callback return Promise otherwise return void 599 * @throws {TypedError} Parameter check failed 600 */ 601declare function mkdtemp(prefix: string): Promise<string>; 602declare function mkdtemp(prefix: string, callback: AsyncCallback<string>): void; 603/** 604 * mkdtempSync. 605 * 606 * @note N/A 607 * @syscap SystemCapability.FileManagement.File.FileIO 608 * @since 7 609 * @permission N/A 610 * @function mkdtempSync 611 * @param {string} prefix - dir prefix. 612 * @returns {string} directory name 613 * @throws {TypedError | Error} mkdtemp fail 614 */ 615declare function mkdtempSync(prefix: string): string; 616/** 617 * open. 618 * 619 * @note N/A 620 * @syscap SystemCapability.FileManagement.File.FileIO 621 * @since 7 622 * @permission N/A 623 * @function open 624 * @param {string} path - path. 625 * @param {number} [flags = 0] - flags. 626 * @param {number} [mode = 0o666] - mode. 627 * @param {AsyncCallback<number>} [callback] - callback. 628 * @returns {void | Promise<number>} no callback return Promise otherwise return void 629 * @throws {TypedError} Parameter check failed 630 */ 631declare function open(path: string, flags?: number, mode?: number): Promise<number>; 632declare function open(path: string, callback: AsyncCallback<number>): void; 633declare function open(path: string, flags: number, callback: AsyncCallback<number>): void; 634declare function open(path: string, flags: number, mode: number, callback: AsyncCallback<number>): void; 635/** 636 * openSync. 637 * 638 * @note N/A 639 * @syscap SystemCapability.FileManagement.File.FileIO 640 * @since 6 641 * @permission N/A 642 * @function openSync 643 * @param {string} path - path. 644 * @param {number} [flags = 0] - flags. 645 * @param {number} [mode = 0o666] - mode. 646 * @returns {number} open fd 647 * @throws {TypedError | Error} open fail 648 */ 649declare function openSync(path: string, flags?: number, mode?: number): number; 650/** 651 * opendir. 652 * 653 * @note N/A 654 * @syscap SystemCapability.FileManagement.File.FileIO 655 * @since 6 656 * @permission N/A 657 * @function opendir 658 * @param {string} path - directory name. 659 * @param {AsyncCallback<Dir>} [callback] - callback. 660 * @returns {void | Promise<Dir>} no callback return Promise otherwise return void 661 * @throws {TypedError} Parameter check failed 662 */ 663declare function opendir(path: string): Promise<Dir>; 664declare function opendir(path: string, callback: AsyncCallback<Dir>): void; 665/** 666 * opendirSync. 667 * 668 * @param {string} path - directory name. 669 * @returns {Dir} opendir Dir Object 670 * @throws {TypedError | Error} opendir fail 671 */ 672declare function opendirSync(path: string): Dir; 673/** 674 * readText. 675 * 676 * @note N/A 677 * @syscap SystemCapability.FileManagement.File.FileIO 678 * @since 7 679 * @permission N/A 680 * @function readText 681 * @param {string} filePath - file path. 682 * @param {Object} [options] - options. 683 * @param {number} [options.offset = 0] - offset in bytes. 684 * @param {number} [options.length = -1] - length in bytes. 685 * @param {number} [options.encoding = 'utf-8'] - encoding. 686 * @param {AsyncCallback<string>} [callback] - callback. 687 * @returns {void | Promise<string>} no callback return Promise otherwise return void 688 * @throws {TypedError} Parameter check failed 689 */ 690declare function readText(filePath: string, options?: { 691 position?: number; 692 length?: number; 693 encoding?: string; 694}): Promise<string>; 695declare function readText(filePath: string, options: { 696 position?: number; 697 length?: number; 698 encoding?: string; 699}, callback: AsyncCallback<string>): void; 700 701/** 702 * readTextSync. 703 * 704 * @note N/A 705 * @syscap SystemCapability.FileManagement.File.FileIO 706 * @since 7 707 * @permission N/A 708 * @function readTextSync 709 * @param {string} filePath - file path. 710 * @param {Object} [options] - options. 711 * @param {number} [options.offset = 0] - offset in bytes. 712 * @param {number} [options.length = -1] - length in bytes. 713 * @param {number} [options.encoding = 'utf-8'] - encoding. 714 * @returns {string} readout result 715 * @throws {TypedError} Parameter check failed 716 */ 717declare function readTextSync(filePath: string, options?: { 718 position?: number; 719 length?: number; 720 encoding?: string; 721}): string; 722 723/** 724 * read. 725 * 726 * @note N/A 727 * @syscap SystemCapability.FileManagement.File.FileIO 728 * @since 6 729 * @permission N/A 730 * @function read 731 * @param {number} fd - file descriptor. 732 * @param {ArrayBuffer} buffer - file descriptor. 733 * @param {Object} [options] - options. 734 * @param {number} [options.offset = 0] - offset. 735 * @param {number} [options.length = -1] - length. 736 * @param {number} [options.position = -1] - position. 737 * @param {AsyncCallback<ReadOut>} [callback] - callback. 738 * @returns {void | Promise<ReadOut>} no callback return Promise otherwise return void 739 * @throws {TypedError} Parameter check failed 740 */ 741declare function read(fd: number, buffer: ArrayBuffer, options?: { 742 offset?: number; 743 length?: number; 744 position?: number; 745}): Promise<ReadOut> 746declare function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback<ReadOut>): void; 747declare function read(fd: number, buffer: ArrayBuffer, options: { 748 offset?: number; 749 length?: number; 750 position?: number; 751}, callback: AsyncCallback<ReadOut>): void; 752/** 753 * readSync. 754 * 755 * @note N/A 756 * @syscap SystemCapability.FileManagement.File.FileIO 757 * @since 6 758 * @permission N/A 759 * @function readSync 760 * @param {number} fd - file descriptor. 761 * @param {ArrayBuffer} buffer - file descriptor. 762 * @param {Object} [options] - options. 763 * @param {number} [options.offset = 0] - offset. 764 * @param {number} [options.length = -1] - length. 765 * @param {number} [options.position = -1] - position. 766 * @returns {number} number of bytesRead 767 * @throws {TypedError | Error} read fail 768 */ 769declare function readSync(fd: number, buffer: ArrayBuffer, options?: { 770 offset?: number; 771 length?: number; 772 position?: number; 773}): number; 774/** 775 * rename. 776 * 777 * @note N/A 778 * @syscap SystemCapability.FileManagement.File.FileIO 779 * @since 7 780 * @permission N/A 781 * @function rename 782 * @param {string} oldPath - oldPath. 783 * @param {string} newPath - newPath. 784 * @param {AsyncCallback<void>} [callback] - callback. 785 * @returns {void | Promise<void>} no callback return Promise otherwise return void 786 * @throws {TypedError} Parameter check failed 787 */ 788declare function rename(oldPath: string, newPath: string): Promise<void>; 789declare function rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): void; 790/** 791 * renameSync. 792 * 793 * @note N/A 794 * @syscap SystemCapability.FileManagement.File.FileIO 795 * @since 7 796 * @permission N/A 797 * @function renameSync 798 * @param {string} oldPath - oldPath. 799 * @param {string} newPath - newPath. 800 * @returns {void} rename success 801 * @throws {TypedError | Error} rename fail 802 */ 803declare function renameSync(oldPath: string, newPath: string): void; 804/** 805 * rmdir. 806 * 807 * @note N/A 808 * @syscap SystemCapability.FileManagement.File.FileIO 809 * @since 7 810 * @permission N/A 811 * @function rmdir 812 * @param {string} path - path. 813 * @param {AsyncCallback<void>} [callback] - callback. 814 * @returns {void | Promise<void>} no callback return Promise otherwise return void 815 * @throws {TypedError} Parameter check failed 816 */ 817declare function rmdir(path: string): Promise<void>; 818declare function rmdir(path: string, callback: AsyncCallback<void>): void; 819/** 820 * rmdirSync. 821 * 822 * @note N/A 823 * @syscap SystemCapability.FileManagement.File.FileIO 824 * @since 7 825 * @permission N/A 826 * @function rmdirSync 827 * @param {string} path - path. 828 * @returns {void} rmdir success 829 * @throws {TypedError | Error} rmdir fail 830 */ 831declare function rmdirSync(path: string): void; 832/** 833 * stat. 834 * @static 835 * @note N/A 836 * @syscap SystemCapability.FileManagement.File.FileIO 837 * @since 6 838 * @permission N/A 839 * @param {string} path - path. 840 * @param {AsyncCallback<number>} [callback] - callback. 841 * @returns {void | Promise<Stat>} no callback return Promise otherwise return void 842 * @throws {TypedError} Parameter check failed 843 */ 844declare function stat(path: string): Promise<Stat>; 845declare function stat(path: string, callback: AsyncCallback<Stat>): void; 846/** 847 * statSync. 848 * @static 849 * @note N/A 850 * @syscap SystemCapability.FileManagement.File.FileIO 851 * @since 6 852 * @permission N/A 853 * @param {string} path - path. 854 * @returns {Stat} stat success 855 * @throws {TypedError | Error} stat fail 856 */ 857declare function statSync(path: string): Stat; 858/** 859 * symlink. 860 * 861 * @note N/A 862 * @syscap SystemCapability.FileManagement.File.FileIO 863 * @since 7 864 * @permission N/A 865 * @function symlink 866 * @param {string} target - target. 867 * @param {string} srcPath - srcPath. 868 * @param {AsyncCallback<void>} [callback] - callback. 869 * @returns {void | Promise<void>} no callback return Promise otherwise return void 870 * @throws {TypedError} Parameter check failed 871 */ 872declare function symlink(target: string, srcPath: string): Promise<void>; 873declare function symlink(target: string, srcPath: string, callback: AsyncCallback<void>): void; 874/** 875 * symlinkSync. 876 * 877 * @note N/A 878 * @syscap SystemCapability.FileManagement.File.FileIO 879 * @since 7 880 * @permission N/A 881 * @function symlinkSync 882 * @param {string} target - target. 883 * @param {string} srcPath - srcPath. 884 * @returns {void} symlink success 885 * @throws {TypedError | Error} symlink fail 886 */ 887 declare function symlinkSync(target: string, srcPath: string): void; 888 /** 889 * truncate. 890 * 891 * @note N/A 892 * @syscap SystemCapability.FileManagement.File.FileIO 893 * @since 7 894 * @permission N/A 895 * @function truncate 896 * @param {string} path - path. 897 * @param {number} [len = 0] - len. 898 * @param {AsyncCallback<void>} [callback] - callback. 899 * @returns {void | Promise<void>} no callback return Promise otherwise return void 900 * @throws {TypedError} Parameter check failed 901 */ 902declare function truncate(path: string, len?: number): Promise<void>; 903declare function truncate(path: string, callback: AsyncCallback<void>): void; 904declare function truncate(path: string, len: number, callback: AsyncCallback<void>): void; 905/** 906 * truncateSync. 907 * 908 * @note N/A 909 * @syscap SystemCapability.FileManagement.File.FileIO 910 * @since 7 911 * @permission N/A 912 * @function truncateSync 913 * @param {string} path - path. 914 * @param {number} [len = 0] - len. 915 * @returns {void} truncate success 916 * @throws {TypedError | Error} truncate fail 917 */ 918declare function truncateSync(path: string, len?: number): void; 919/** 920 * unlink. 921 * 922 * @note N/A 923 * @syscap SystemCapability.FileManagement.File.FileIO 924 * @since 6 925 * @permission N/A 926 * @function unlink 927 * @param {string} path - path. 928 * @param {AsyncCallback<void>} [callback] - callback. 929 * @returns {void | Promise<void>} no callback return Promise otherwise return void 930 * @throws {TypedError} Parameter check failed 931 */ 932declare function unlink(path: string): Promise<void>; 933declare function unlink(path: string, callback: AsyncCallback<void>): void; 934/** 935 * unlinkSync. 936 * 937 * @note N/A 938 * @syscap SystemCapability.FileManagement.File.FileIO 939 * @since 6 940 * @permission N/A 941 * @function unlinkSync 942 * @param {string} path - path. 943 * @returns {void} unlink success 944 * @throws {TypedError | Error} unlink fail 945 */ 946declare function unlinkSync(path: string): void; 947/** 948 * write. 949 * 950 * @note N/A 951 * @syscap SystemCapability.FileManagement.File.FileIO 952 * @since 6 953 * @permission N/A 954 * @function write 955 * @param {number} fd - file descriptor. 956 * @param {ArrayBuffer | string} buffer - file descriptor. 957 * @param {Object} [options] - options. 958 * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. 959 * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. 960 * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. 961 * @param {string} [options.encoding = 'utf-8'] - encoding. 962 * @param {AsyncCallback<number>} [callback] - callback. 963 * @returns {void | Promise<number>} no callback return Promise otherwise return void 964 * @throws {TypedError | RangeError} Parameter check failed 965 */ 966declare function write(fd: number, buffer: ArrayBuffer | string, options?: { 967 offset?: number; 968 length?: number; 969 position?: number; 970 encoding?: string; 971}): Promise<number>; 972declare function write(fd: number, buffer: ArrayBuffer | string, callback: AsyncCallback<number>): void; 973declare function write(fd: number, buffer: ArrayBuffer | string, options: { 974 offset?: number; 975 length?: number; 976 position?: number; 977 encoding?: string; 978}, callback: AsyncCallback<number>): void; 979/** 980 * writeSync. 981 * 982 * @note N/A 983 * @syscap SystemCapability.FileManagement.File.FileIO 984 * @since 6 985 * @permission N/A 986 * @function writeSync 987 * @param {number} fd - file descriptor. 988 * @param {ArrayBuffer | string} buffer - file descriptor. 989 * @param {Object} [options] - options. 990 * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. 991 * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. 992 * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. 993 * @param {string} [options.encoding = 'utf-8'] - encoding. 994 * @returns {number} on success number of bytesRead 995 * @throws {TypedError | RangeError | Error} write fail 996 */ 997declare function writeSync(fd: number, buffer: ArrayBuffer | string, options?: { 998 offset?: number; 999 length?: number; 1000 position?: number; 1001 encoding?: string; 1002}): number; 1003 1004/** 1005 * createWatcher. 1006 * 1007 * @note N/A 1008 * @syscap SystemCapability.FileManagement.File.FileIO 1009 * @since 7 1010 * @permission N/A 1011 * @function createWatcher 1012 * @param {string} filename - filename. 1013 * @param {number} events - events(depends on OS & filesystem) events = 1 rename events =2 change. 1014 * @param {AsyncCallback<number>} [callback] - callback. 1015 * @returns {Watcher} watch success 1016 * @throws {TypedError | Error} watch fail 1017 */ 1018declare function createWatcher(filename: string, events: number, callback: AsyncCallback<number>): Watcher; 1019/** 1020 * Dir 1021 * @syscap SystemCapability.FileManagement.File.FileIO 1022 * @since 6 1023 * @permission N/A 1024 */ 1025declare interface Dir { 1026 /** 1027 * read. 1028 * 1029 * @note N/A 1030 * @syscap SystemCapability.FileManagement.File.FileIO 1031 * @since 6 1032 * @permission N/A 1033 * @function read 1034 * @param {AsyncCallback<Dirent>} [callback] - callback. 1035 * @returns {void | Promise<Dirent>} no callback return Promise otherwise return void 1036 * @throws {TypedError} Parameter check failed if read to end, Error.msg = "NoMore" 1037 */ 1038 read(): Promise<Dirent>; 1039 read(callback: AsyncCallback<Dirent>): void; 1040 /** 1041 * readSync. 1042 * @note N/A 1043 * @syscap SystemCapability.FileManagement.File.FileIO 1044 * @since 6 1045 * @permission N/A 1046 * @function readSync 1047 * @returns {Dirent} Dirent Object 1048 * @throws {TypedError | Error} read fail if read to end, Error.msg = "NoMore" 1049 */ 1050 readSync(): Dirent; 1051 /** 1052 * close. 1053 * @note N/A 1054 * @syscap SystemCapability.FileManagement.File.FileIO 1055 * @since 7 1056 * @permission N/A 1057 * @function close 1058 * @param {AsyncCallback<void>} [callback] - callback. 1059 * @returns {void | Promise<void>} close success 1060 * @throws {TypedError | Error} close fail 1061 */ 1062 close(): Promise<void>; 1063 close(callback: AsyncCallback<void>): void; 1064 /** 1065 * closeSync. 1066 * @note N/A 1067 * @syscap SystemCapability.FileManagement.File.FileIO 1068 * @since 6 1069 * @permission N/A 1070 * @function closeSync 1071 * @returns {void} close success 1072 * @throws {TypedError | Error} close fail 1073 */ 1074 closeSync(): void; 1075} 1076 1077/** 1078 * Dirent 1079 * @syscap SystemCapability.FileManagement.File.FileIO 1080 * @since 6 1081 * @permission N/A 1082 */ 1083declare interface Dirent { 1084 /** 1085 * @type {string} 1086 * @readonly 1087 * @note N/A 1088 * @syscap SystemCapability.FileManagement.File.FileIO 1089 * @since 6 1090 * @permission N/A 1091 */ 1092 readonly name: string; 1093 /** 1094 * isBlockDevice. 1095 * @note N/A 1096 * @syscap SystemCapability.FileManagement.File.FileIO 1097 * @since 6 1098 * @permission N/A 1099 * @returns {boolean} is or not 1100 */ 1101 isBlockDevice(): boolean; 1102 /** 1103 * isCharacterDevice. 1104 * @note N/A 1105 * @syscap SystemCapability.FileManagement.File.FileIO 1106 * @since 6 1107 * @permission N/A 1108 * @returns {boolean} is or not 1109 */ 1110 isCharacterDevice(): boolean; 1111 /** 1112 * isDirectory. 1113 * @note N/A 1114 * @syscap SystemCapability.FileManagement.File.FileIO 1115 * @since 6 1116 * @permission N/A 1117 * @returns {boolean} is or not 1118 */ 1119 isDirectory(): boolean; 1120 /** 1121 * isFIFO. 1122 * @note N/A 1123 * @syscap SystemCapability.FileManagement.File.FileIO 1124 * @since 6 1125 * @permission N/A 1126 * @returns {boolean} is or not 1127 */ 1128 isFIFO(): boolean; 1129 /** 1130 * isFile. 1131 * @note N/A 1132 * @syscap SystemCapability.FileManagement.File.FileIO 1133 * @since 6 1134 * @permission N/A 1135 * @returns {boolean} is or not 1136 */ 1137 isFile(): boolean; 1138 /** 1139 * isSocket. 1140 * @note N/A 1141 * @syscap SystemCapability.FileManagement.File.FileIO 1142 * @since 6 1143 * @permission N/A 1144 * @returns {boolean} is or not 1145 */ 1146 isSocket(): boolean; 1147 /** 1148 * isSymbolicLink. 1149 * @note N/A 1150 * @syscap SystemCapability.FileManagement.File.FileIO 1151 * @since 6 1152 * @permission N/A 1153 * @returns {boolean} is or not 1154 */ 1155 isSymbolicLink(): boolean; 1156} 1157 1158/** 1159 * Stat 1160 * @syscap SystemCapability.FileManagement.File.FileIO 1161 * @since 6 1162 * @permission N/A 1163 */ 1164declare interface Stat { 1165 /** 1166 * @type {number} 1167 * @note N/A 1168 * @syscap SystemCapability.FileManagement.File.FileIO 1169 * @since 6 1170 * @permission N/A 1171 * @readonly 1172 */ 1173 readonly dev: number; 1174 /** 1175 * @type {number} 1176 * @note N/A 1177 * @syscap SystemCapability.FileManagement.File.FileIO 1178 * @since 6 1179 * @permission N/A 1180 * @readonly 1181 */ 1182 readonly ino: number; 1183 /** 1184 * @type {number} 1185 * @note N/A 1186 * @syscap SystemCapability.FileManagement.File.FileIO 1187 * @since 6 1188 * @permission N/A 1189 * @readonly 1190 */ 1191 readonly mode: number; 1192 /** 1193 * @type {number} 1194 * @note N/A 1195 * @syscap SystemCapability.FileManagement.File.FileIO 1196 * @since 6 1197 * @permission N/A 1198 * @readonly 1199 */ 1200 readonly nlink: number; 1201 /** 1202 * @type {number} 1203 * @note N/A 1204 * @syscap SystemCapability.FileManagement.File.FileIO 1205 * @since 6 1206 * @permission N/A 1207 * @readonly 1208 */ 1209 readonly uid: number; 1210 /** 1211 * @type {number} 1212 * @note N/A 1213 * @syscap SystemCapability.FileManagement.File.FileIO 1214 * @since 6 1215 * @permission N/A 1216 * @readonly 1217 */ 1218 readonly gid: number; 1219 /** 1220 * @type {number} 1221 * @note N/A 1222 * @syscap SystemCapability.FileManagement.File.FileIO 1223 * @since 6 1224 * @permission N/A 1225 * @readonly 1226 */ 1227 readonly rdev: number; 1228 /** 1229 * @type {number} 1230 * @note N/A 1231 * @syscap SystemCapability.FileManagement.File.FileIO 1232 * @since 6 1233 * @permission N/A 1234 * @readonly 1235 */ 1236 readonly size: number; 1237 /** 1238 * @type {number} 1239 * @note N/A 1240 * @syscap SystemCapability.FileManagement.File.FileIO 1241 * @since 6 1242 * @permission N/A 1243 * @readonly 1244 */ 1245 readonly blocks: number; 1246 /** 1247 * @type {number} 1248 * @note N/A 1249 * @syscap SystemCapability.FileManagement.File.FileIO 1250 * @since 6 1251 * @permission N/A 1252 * @readonly 1253 */ 1254 readonly atime: number; 1255 /** 1256 * @type {number} 1257 * @note N/A 1258 * @syscap SystemCapability.FileManagement.File.FileIO 1259 * @since 6 1260 * @permission N/A 1261 * @readonly 1262 */ 1263 readonly mtime: number; 1264 /** 1265 * @type {number} 1266 * @note N/A 1267 * @syscap SystemCapability.FileManagement.File.FileIO 1268 * @since 6 1269 * @permission N/A 1270 * @readonly 1271 */ 1272 readonly ctime: number; 1273 /** 1274 * isBlockDevice. 1275 * @note N/A 1276 * @syscap SystemCapability.FileManagement.File.FileIO 1277 * @since 6 1278 * @permission N/A 1279 * @returns {boolean} is or not 1280 */ 1281 isBlockDevice(): boolean; 1282 /** 1283 * isCharacterDevice. 1284 * @note N/A 1285 * @syscap SystemCapability.FileManagement.File.FileIO 1286 * @since 6 1287 * @permission N/A 1288 * @returns {boolean} is or not 1289 */ 1290 isCharacterDevice(): boolean; 1291 /** 1292 * isDirectory. 1293 * @note N/A 1294 * @syscap SystemCapability.FileManagement.File.FileIO 1295 * @since 6 1296 * @permission N/A 1297 * @returns {boolean} is or not 1298 */ 1299 isDirectory(): boolean; 1300 /** 1301 * isFIFO. 1302 * @note N/A 1303 * @syscap SystemCapability.FileManagement.File.FileIO 1304 * @since 6 1305 * @permission N/A 1306 * @returns {boolean} is or not 1307 */ 1308 isFIFO(): boolean; 1309 /** 1310 * isFile. 1311 * @note N/A 1312 * @syscap SystemCapability.FileManagement.File.FileIO 1313 * @since 6 1314 * @permission N/A 1315 * @returns {boolean} is or not 1316 */ 1317 isFile(): boolean; 1318 /** 1319 * isSocket. 1320 * @note N/A 1321 * @syscap SystemCapability.FileManagement.File.FileIO 1322 * @since 6 1323 * @permission N/A 1324 * @returns {boolean} is or not 1325 */ 1326 isSocket(): boolean; 1327 /** 1328 * isSymbolicLink. 1329 * @note N/A 1330 * @syscap SystemCapability.FileManagement.File.FileIO 1331 * @since 6 1332 * @permission N/A 1333 * @returns {boolean} is or not 1334 */ 1335 isSymbolicLink(): boolean; 1336} 1337 1338/** 1339 * Stream 1340 * @syscap SystemCapability.FileManagement.File.FileIO 1341 * @since 6 1342 * @permission N/A 1343 */ 1344declare interface Stream { 1345 /** 1346 * close. 1347 * 1348 * @note N/A 1349 * @syscap SystemCapability.FileManagement.File.FileIO 1350 * @since 7 1351 * @permission N/A 1352 * @param {AsyncCallback<void>} [callback] - callback. 1353 * @returns {void | Promise<void>} close success 1354 * @throws {TypedError | Error} close fail 1355 */ 1356 close(): Promise<void>; 1357 close(callback: AsyncCallback<void>): void; 1358 /** 1359 * closeSync. 1360 * 1361 * @note N/A 1362 * @syscap SystemCapability.FileManagement.File.FileIO 1363 * @since 6 1364 * @permission N/A 1365 * @returns {void} close success 1366 * @throws {TypedError | Error} close fail 1367 */ 1368 closeSync(): void; 1369 /** 1370 * flush. 1371 * 1372 * @note N/A 1373 * @syscap SystemCapability.FileManagement.File.FileIO 1374 * @since 7 1375 * @permission N/A 1376 * @param {AsyncCallback<void>} [callback] - callback. 1377 * @returns {void | Promise<void>} no callback return Promise otherwise return void 1378 * @throws {TypedError} Parameter check failed 1379 */ 1380 flush(): Promise<void>; 1381 flush(callback: AsyncCallback<void>): void; 1382 /** 1383 * flushSync. 1384 * 1385 * @note N/A 1386 * @syscap SystemCapability.FileManagement.File.FileIO 1387 * @since 7 1388 * @permission N/A 1389 * @returns {void} flush success 1390 * @throws {Error} flush fail 1391 */ 1392 flushSync(): void; 1393 /** 1394 * write. 1395 * 1396 * @note N/A 1397 * @syscap SystemCapability.FileManagement.File.FileIO 1398 * @since 7 1399 * @permission N/A 1400 * @param {ArrayBuffer | string} buffer - file description. 1401 * @param {Object} [options] - options. 1402 * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. 1403 * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. 1404 * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. 1405 * @param {string} [options.encoding = 'utf-8'] - encoding. 1406 * @param {AsyncCallback<number>} [callback] - callback. 1407 * @returns {void | Promise<number>} no callback return Promise otherwise return void 1408 * @throws {TypedError} Parameter check failed 1409 */ 1410 write(buffer: ArrayBuffer | string, options?: { 1411 offset?: number; 1412 length?: number; 1413 position?: number; 1414 encoding?: string; 1415 }): Promise<number>; 1416 write(buffer: ArrayBuffer | string, callback: AsyncCallback<number>): void; 1417 write(buffer: ArrayBuffer | string, options: { 1418 offset?: number; 1419 length?: number; 1420 position?: number; 1421 encoding?: string; 1422 }, callback: AsyncCallback<number>): void; 1423 /** 1424 * writeSync. 1425 * 1426 * @note N/A 1427 * @syscap SystemCapability.FileManagement.File.FileIO 1428 * @since 7 1429 * @permission N/A 1430 * @param {ArrayBuffer | string} buffer - file description. 1431 * @param {Object} [options] - options. 1432 * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. 1433 * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. 1434 * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. 1435 * @param {string} [options.encoding = 'utf-8'] - encoding. 1436 * @returns {number} on success number of bytes written 1437 * @throws {TypedError | Error} write fail 1438 */ 1439 writeSync(buffer: ArrayBuffer | string, options?: { 1440 offset?: number; 1441 length?: number; 1442 position?: number; 1443 encoding?: string; 1444 }): number; 1445 /** 1446 * read. 1447 * 1448 * @note N/A 1449 * @syscap SystemCapability.FileManagement.File.FileIO 1450 * @since 7 1451 * @permission N/A 1452 * @param {ArrayBuffer} buffer - file description. 1453 * @param {Object} [options] - options. 1454 * @param {number} [options.offset = 0] - offset. 1455 * @param {number} [options.length = -1] - length. 1456 * @param {AsyncCallback<number>} [callback] - callback. 1457 * @returns {void | Promise<ReadOut>} no callback return Promise otherwise return void 1458 * @throws {TypedError} Parameter check failed 1459 */ 1460 read(buffer: ArrayBuffer, options?: { 1461 position?: number; 1462 offset?: number; 1463 length?: number; 1464 }): Promise<ReadOut>; 1465 read(buffer: ArrayBuffer, callback: AsyncCallback<ReadOut>): void; 1466 read(buffer: ArrayBuffer, options: { 1467 position?: number; 1468 offset?: number; 1469 length?: number; 1470 }, callback: AsyncCallback<ReadOut>): void; 1471 /** 1472 * readSync. 1473 * 1474 * @note N/A 1475 * @syscap SystemCapability.FileManagement.File.FileIO 1476 * @since 7 1477 * @permission N/A 1478 * @param {ArrayBuffer} buffer - file description. 1479 * @param {Object} [options] - options. 1480 * @param {number} [options.offset = 0] - offset. 1481 * @param {number} [options.length = -1] - length. 1482 * @returns {number} number of bytesRead 1483 * @throws {TypedError | Error} read fail 1484 */ 1485 readSync(buffer: ArrayBuffer, options?: { 1486 position?: number; 1487 offset?: number; 1488 length?: number; 1489 }): number; 1490} 1491 1492/** 1493 * ReadOut 1494 * @syscap SystemCapability.FileManagement.File.FileIO 1495 * @since 6 1496 * @permission N/A 1497 */ 1498declare interface ReadOut { 1499 /** 1500 * @type {number} 1501 * @note N/A 1502 * @syscap SystemCapability.FileManagement.File.FileIO 1503 * @since 6 1504 * @permission N/A 1505 * @readonly 1506 */ 1507 bytesRead: number; 1508 /** 1509 * @type {number} 1510 * @note N/A 1511 * @syscap SystemCapability.FileManagement.File.FileIO 1512 * @since 6 1513 * @permission N/A 1514 * @readonly 1515 */ 1516 offset: number; 1517 /** 1518 * @type {ArrayBuffer} 1519 * @note N/A 1520 * @syscap SystemCapability.FileManagement.File.FileIO 1521 * @since 6 1522 * @permission N/A 1523 * @readonly 1524 */ 1525 buffer: ArrayBuffer; 1526} 1527 1528/** 1529 * Watcher 1530 * @syscap SystemCapability.FileManagement.File.FileIO 1531 * @since 7 1532 * @permission N/A 1533 */ 1534declare interface Watcher { 1535 /** 1536 * stop. 1537 * 1538 * @note N/A 1539 * @syscap SystemCapability.FileManagement.File.FileIO 1540 * @since 7 1541 * @permission N/A 1542 * @param {AsyncCallback<void>} [callback] - callback. 1543 * @returns {void | Promise<void>} stop success 1544 * @throws {TypedError | Error} stop fail 1545 */ 1546 stop(): Promise<void>; 1547 stop(callback: AsyncCallback<void>): void; 1548}