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