From 5256e92252aa3f9066e56caee5a9a576871780af Mon Sep 17 00:00:00 2001 From: ningzuobin Date: Sat, 16 Jul 2022 18:20:58 +0800 Subject: [PATCH] =?UTF-8?q?file=5Fapi=E5=8A=9F=E8=83=BD=E4=BD=BF=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ningzuobin --- interfaces/kits/js/napi/@ohos.fileio.d.ts | 1548 +++++++++++++++++++++ 1 file changed, 1548 insertions(+) create mode 100644 interfaces/kits/js/napi/@ohos.fileio.d.ts diff --git a/interfaces/kits/js/napi/@ohos.fileio.d.ts b/interfaces/kits/js/napi/@ohos.fileio.d.ts new file mode 100644 index 000000000..2a0320679 --- /dev/null +++ b/interfaces/kits/js/napi/@ohos.fileio.d.ts @@ -0,0 +1,1548 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AsyncCallback } from './basic' + +export default fileIO; + +/** + * fileio + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @import import fileio from '@ohos.fileio'; + * @permission N/A + */ +declare namespace fileIO { + export { access }; + export { accessSync }; + export { chmod }; + export { chmodSync }; + export { chown }; + export { chownSync }; + export { close }; + export { closeSync }; + export { copyFile }; + export { copyFileSync }; + export { createStream }; + export { createStreamSync }; + export { createWatcher }; + export { fchmod }; + export { fchmodSync }; + export { fchown }; + export { fchownSync }; + export { fdatasync }; + export { fdatasyncSync }; + export { fdopenStream }; + export { fdopenStreamSync }; + export { fstat }; + export { fstatSync }; + export { fsync }; + export { fsyncSync }; + export { ftruncate }; + export { ftruncateSync }; + export { hash }; + export { lchown }; + export { lchownSync }; + export { lstat }; + export { lstatSync }; + export { mkdir }; + export { mkdirSync }; + export { mkdtemp }; + export { mkdtempSync }; + export { open }; + export { openSync }; + export { opendir }; + export { opendirSync }; + export { read }; + export { readSync }; + export { readText }; + export { readTextSync }; + export { rename }; + export { renameSync }; + export { rmdir }; + export { rmdirSync }; + export { stat }; + export { statSync }; + export { symlink }; + export { symlinkSync }; + export { truncate }; + export { truncateSync }; + export { unlink }; + export { unlinkSync }; + export { write }; + export { writeSync }; + export { Dir }; + export { Dirent }; + export { ReadOut }; + export { Stat }; + export { Stream }; + export { Watcher }; +} + +/** + * access. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function access + * @param {string} path - path. + * @param {number} [mode = 0] - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function access(path: string, mode?: number): Promise; +declare function access(path: string, callback: AsyncCallback): void; +declare function access(path: string, mode: number, callback: AsyncCallback): void; +/** + * accessSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function accessSync + * @param {string} path - path. + * @param {number} [mode = 0] - mode. + * @returns {void} access success + * @throws {TypedError | Error} access fail + */ +declare function accessSync(path: string, mode?: number): void; +/** + * close. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function close + * @param {number} fd - fd. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function close(fd: number): Promise; +declare function close(fd: number, callback: AsyncCallback): void; +/** + * closeSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function closeSync + * @param {number} fd - fd. + * @returns {void} close success + * @throws {TypedError | Error} close fail + */ +declare function closeSync(fd: number): void; +/** + * copyFile. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function copyFile + * @param {string | number} src - src. + * @param {string | number} dest - dest. + * @param {number} [mode = 0] - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function copyFile(src: string | number, dest: string | number, mode?: number): Promise; +declare function copyFile(src: string | number, dest: string | number, callback: AsyncCallback): void; +declare function copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback): void; +/** + * copyFileSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function copyFileSync + * @param {string | number} src - src. + * @param {string | number} dest - dest. + * @param {number} [mode = 0] - mode. + * @returns {void} copyFile success + * @throws {TypedError | Error} copyFile fail + */ +declare function copyFileSync(src: string | number, dest: string | number, mode?: number): void; +/** + * createStream. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function createStream + * @param {string} path - path. + * @param {string} mode - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return Stream + * @throws {TypedError} Parameter check failed + */ +declare function createStream(path: string, mode: string): Promise; +declare function createStream(path: string, mode: string, callback: AsyncCallback): void; +/** + * createStreamSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function createStreamSync + * @param {string} path - path. + * @param {string} mode - mode. + * @returns {Stream} createStream + * @throws {TypedError} Parameter check failed + */ +declare function createStreamSync(path: string, mode: string): Stream; +/** + * chown. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function appendFile + * @param {string} path - path. + * @param {number} uid - mode. + * @param {number} gid - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function chown(path: string, uid: number, gid: number): Promise; +declare function chown(path: string, uid: number, gid: number, callback: AsyncCallback): void; +/** + * chownSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function appendFile + * @param {string} path - path. + * @param {number} uid - mode. + * @param {number} gid - mode. + * @returns {void} chown success + * @throws {TypedError | Error} chown fail + */ +declare function chownSync(path: string, uid: number, gid: number): void; +/** + * chmod. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function chmod + * @param {string} path - path. + * @param {number} mode - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function chmod(path: string, mode: number): Promise; +declare function chmod(path: string, mode: number, callback: AsyncCallback): void; +/** + * chmodSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function chmodSync + * @param {string} path - path. + * @param {number} mode - mode. + * @returns {void} chmod success + * @throws {TypedError | Error} chmod fail + */ +declare function chmodSync(path: string, mode: number): void; +/** + * ftruncate. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function ftruncate + * @param {number} fd - fd. + * @param {number} [len = 0] - len. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function ftruncate(fd: number, len?: number): Promise; +declare function ftruncate(fd: number, callback: AsyncCallback): void; +declare function ftruncate(fd: number, len: number, callback: AsyncCallback): void; +/** + * ftruncateSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function ftruncateSync + * @param {number} fd - fd. + * @param {number} [len = 0] - len. + * @returns {void} ftruncate success + * @throws {TypedError | Error} ftruncate fail + */ +declare function ftruncateSync(fd: number, len?: number): void; +/** + * fsync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fsync + * @param {number} fd - fd. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function fsync(fd: number): Promise; +declare function fsync(fd: number, callback: AsyncCallback): void; +/** + * fsyncSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fsyncSync + * @param {number} fd - fd. + * @returns {void} fsync success + * @throws {TypedError | Error} fsync fail + */ +declare function fsyncSync(fd: number): void; +/** + * fstat. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fstat + * @param {number} fd - fd. + * @returns {Stat} + * @throws {TypedError | Error} fstat fail + */ +declare function fstat(fd: number): Promise; +declare function fstat(fd: number, callback: AsyncCallback): void; +/** + * fstatSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fstatSync + * @param {number} fd - fd. + * @returns {Stat} + * @throws {TypedError | Error} fstat fail + */ +declare function fstatSync(fd: number): Stat; +/** + * fdatasync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fdatasync + * @param {number} fd - fd. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function fdatasync(fd: number): Promise; +declare function fdatasync(fd: number, callback: AsyncCallback): void; +/** + * fdatasyncSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fdatasyncSync + * @param {number} fd - fd. + * @returns {void} fdatasync success + * @throws {TypedError | Error} fdatasync fail + */ +declare function fdatasyncSync(fd: number): void; +/** + * fchown. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fchown + * @param {number} fd - fd. + * @param {number} uid - uid. + * @param {number} gid - gid. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function fchown(fd: number, uid: number, gid: number): Promise; +declare function fchown(fd: number, uid: number, gid: number, callback: AsyncCallback): void; +/** + * fchownSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fchownSync + * @param {number} fd - fd. + * @param {number} uid - uid. + * @param {number} gid - gid. + * @returns {void} fchown success + * @throws {TypedError | Error} fchown fail + */ +declare function fchownSync(fd: number, uid: number, gid: number): void; +/** + * fchmod. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fchmod + * @param {number} fd - fd. + * @param {number} mode - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function fchmod(fd: number, mode: number): Promise; +declare function fchmod(fd: number, mode: number, callback: AsyncCallback): void; +/** + * fchmodSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fchmodSync + * @param {number} fd - fd. + * @param {number} mode - mode. + * @returns {void} fchmod success + * @throws {TypedError | Error} fchmod fail + */ +declare function fchmodSync(fd: number, mode: number): void; +/** + * fdopenStream. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fdopenStream + * @param {number} fd - fd. + * @param {string} mode - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function fdopenStream(fd: number, mode: string): Promise; +declare function fdopenStream(fd: number, mode: string, callback: AsyncCallback): void; +/** + * fdopenStreamSync. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function fdopenStreamSync + * @param {number} fd - fd. + * @param {string} mode - mode. + * @returns {Stream} open stream from fd + * @throws {TypedError | Error} open fail + */ +declare function fdopenStreamSync(fd: number, mode: string): Stream; + /** + * hash. + * @static + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function hash + * @param {string} path - path. + * @param {string} algorithm - algorithm md5 sha1 sha256. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function hash(path: string, algorithm: string): Promise; +declare function hash(path: string, algorithm: string, callback: AsyncCallback): void; +/** + * lchown. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function lchown + * @param {string} path - path. + * @param {number} uid - uid. + * @param {number} gid - gid. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function lchown(path: string, uid: number, gid: number): Promise; +declare function lchown(path: string, uid: number, gid: number, callback: AsyncCallback): void; +/** + * lchownSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function lchownSync + * @param {string} path - path. + * @param {number} uid - uid. + * @param {number} gid - gid. + * @returns {void} lchown success + * @throws {TypedError | Error} lchown fail + */ +declare function lchownSync(path: string, uid: number, gid: number): void; +/** + * lstat. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function lstat + * @param {string} path - path. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function lstat(path: string): Promise; +declare function lstat(path: string, callback: AsyncCallback): void; +/** + * lstatSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function lstatSync + * @param {string} path - path. + * @returns {Stat} lstat success + * @throws {TypedError | Error} lstat fail + */ +declare function lstatSync(path: string): Stat; +/** + * mkdir. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function mkdir + * @param {string} path - path. + * @param {number} [mode = 0o775] - path. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function mkdir(path: string, mode?: number): Promise; +declare function mkdir(path: string, callback: AsyncCallback): void; +declare function mkdir(path: string, mode: number, callback: AsyncCallback): void; +/** + * mkdirSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function mkdirSync + * @param {string} path - path. + * @param {number} [mode = 0o775] - path. + * @returns {void} mkdir success + * @throws {TypedError | Error} mkdir fail + */ +declare function mkdirSync(path: string, mode?: number): void; +/** + * mkdtemp. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function mkdtemp + * @param {string} prefix - dir prefix. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function mkdtemp(prefix: string): Promise; +declare function mkdtemp(prefix: string, callback: AsyncCallback): void; +/** + * mkdtempSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function mkdtempSync + * @param {string} prefix - dir prefix. + * @returns {string} directory name + * @throws {TypedError | Error} mkdtemp fail + */ +declare function mkdtempSync(prefix: string): string; +/** + * open. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function open + * @param {string} path - path. + * @param {number} [flags = 0] - flags. + * @param {number} [mode = 0o666] - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function open(path: string, flags?: number, mode?: number): Promise; +declare function open(path: string, callback: AsyncCallback): void; +declare function open(path: string, flags: number, callback: AsyncCallback): void; +declare function open(path: string, flags: number, mode: number, callback: AsyncCallback): void; +/** + * openSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function openSync + * @param {string} path - path. + * @param {number} [flags = 0] - flags. + * @param {number} [mode = 0o666] - mode. + * @returns {number} open fd + * @throws {TypedError | Error} open fail + */ +declare function openSync(path: string, flags?: number, mode?: number): number; +/** + * opendir. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function opendir + * @param {string} path - directory name. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function opendir(path: string): Promise; +declare function opendir(path: string, callback: AsyncCallback): void; +/** + * opendirSync. + * + * @param {string} path - directory name. + * @returns {Dir} opendir Dir Object + * @throws {TypedError | Error} opendir fail + */ +declare function opendirSync(path: string): Dir; +/** + * readText. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function readText + * @param {string} filePath - file path. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset in bytes. + * @param {number} [options.length = -1] - length in bytes. + * @param {number} [options.encoding = 'utf-8'] - encoding. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function readText(filePath: string, options?: { + position?: number; + length?: number; + encoding?: string; +}): Promise; +declare function readText(filePath: string, options: { + position?: number; + length?: number; + encoding?: string; +}, callback: AsyncCallback): void; + +/** + * readTextSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function readTextSync + * @param {string} filePath - file path. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset in bytes. + * @param {number} [options.length = -1] - length in bytes. + * @param {number} [options.encoding = 'utf-8'] - encoding. + * @returns {string} readout result + * @throws {TypedError} Parameter check failed + */ +declare function readTextSync(filePath: string, options?: { + position?: number; + length?: number; + encoding?: string; +}): string; + +/** + * read. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function read + * @param {number} fd - file descriptor. + * @param {ArrayBuffer} buffer - file descriptor. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.length = -1] - length. + * @param {number} [options.position = -1] - position. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function read(fd: number, buffer: ArrayBuffer, options?: { + offset?: number; + length?: number; + position?: number; +}): Promise +declare function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback): void; +declare function read(fd: number, buffer: ArrayBuffer, options: { + offset?: number; + length?: number; + position?: number; +}, callback: AsyncCallback): void; +/** + * readSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function readSync + * @param {number} fd - file descriptor. + * @param {ArrayBuffer} buffer - file descriptor. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.length = -1] - length. + * @param {number} [options.position = -1] - position. + * @returns {number} number of bytesRead + * @throws {TypedError | Error} read fail + */ +declare function readSync(fd: number, buffer: ArrayBuffer, options?: { + offset?: number; + length?: number; + position?: number; +}): number; +/** + * rename. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function rename + * @param {string} oldPath - oldPath. + * @param {string} newPath - newPath. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function rename(oldPath: string, newPath: string): Promise; +declare function rename(oldPath: string, newPath: string, callback: AsyncCallback): void; +/** + * renameSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function renameSync + * @param {string} oldPath - oldPath. + * @param {string} newPath - newPath. + * @returns {void} rename success + * @throws {TypedError | Error} rename fail + */ +declare function renameSync(oldPath: string, newPath: string): void; +/** + * rmdir. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function rmdir + * @param {string} path - path. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function rmdir(path: string): Promise; +declare function rmdir(path: string, callback: AsyncCallback): void; +/** + * rmdirSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function rmdirSync + * @param {string} path - path. + * @returns {void} rmdir success + * @throws {TypedError | Error} rmdir fail + */ +declare function rmdirSync(path: string): void; +/** + * stat. + * @static + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @param {string} path - path. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function stat(path: string): Promise; +declare function stat(path: string, callback: AsyncCallback): void; +/** + * statSync. + * @static + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @param {string} path - path. + * @returns {Stat} stat success + * @throws {TypedError | Error} stat fail + */ +declare function statSync(path: string): Stat; +/** + * symlink. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function symlink + * @param {string} target - target. + * @param {string} srcPath - srcPath. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function symlink(target: string, srcPath: string): Promise; +declare function symlink(target: string, srcPath: string, callback: AsyncCallback): void; +/** + * symlinkSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function symlinkSync + * @param {string} target - target. + * @param {string} srcPath - srcPath. + * @returns {void} symlink success + * @throws {TypedError | Error} symlink fail + */ + declare function symlinkSync(target: string, srcPath: string): void; + /** + * truncate. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function truncate + * @param {string} path - path. + * @param {number} [len = 0] - len. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function truncate(path: string, len?: number): Promise; +declare function truncate(path: string, callback: AsyncCallback): void; +declare function truncate(path: string, len: number, callback: AsyncCallback): void; +/** + * truncateSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function truncateSync + * @param {string} path - path. + * @param {number} [len = 0] - len. + * @returns {void} truncate success + * @throws {TypedError | Error} truncate fail + */ +declare function truncateSync(path: string, len?: number): void; +/** + * unlink. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function unlink + * @param {string} path - path. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function unlink(path: string): Promise; +declare function unlink(path: string, callback: AsyncCallback): void; +/** + * unlinkSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function unlinkSync + * @param {string} path - path. + * @returns {void} unlink success + * @throws {TypedError | Error} unlink fail + */ +declare function unlinkSync(path: string): void; +/** + * write. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function write + * @param {number} fd - file descriptor. + * @param {ArrayBuffer | string} buffer - file descriptor. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. + * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. + * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. + * @param {string} [options.encoding = 'utf-8'] - encoding. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError | RangeError} Parameter check failed + */ +declare function write(fd: number, buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + position?: number; + encoding?: string; +}): Promise; +declare function write(fd: number, buffer: ArrayBuffer | string, callback: AsyncCallback): void; +declare function write(fd: number, buffer: ArrayBuffer | string, options: { + offset?: number; + length?: number; + position?: number; + encoding?: string; +}, callback: AsyncCallback): void; +/** + * writeSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function writeSync + * @param {number} fd - file descriptor. + * @param {ArrayBuffer | string} buffer - file descriptor. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. + * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. + * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. + * @param {string} [options.encoding = 'utf-8'] - encoding. + * @returns {number} on success number of bytesRead + * @throws {TypedError | RangeError | Error} write fail + */ +declare function writeSync(fd: number, buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + position?: number; + encoding?: string; +}): number; + +/** + * createWatcher. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function createWatcher + * @param {string} filename - filename. + * @param {number} events - events(depends on OS & filesystem) events = 1 rename events =2 change. + * @param {AsyncCallback} [callback] - callback. + * @returns {Watcher} watch success + * @throws {TypedError | Error} watch fail + */ +declare function createWatcher(filename: string, events: number, callback: AsyncCallback): Watcher; +/** + * Dir + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ +declare interface Dir { + /** + * read. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function read + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed if read to end, Error.msg = "NoMore" + */ + read(): Promise; + read(callback: AsyncCallback): void; + /** + * readSync. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function readSync + * @returns {Dirent} Dirent Object + * @throws {TypedError | Error} read fail if read to end, Error.msg = "NoMore" + */ + readSync(): Dirent; + /** + * close. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @function close + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} close success + * @throws {TypedError | Error} close fail + */ + close(): Promise; + close(callback: AsyncCallback): void; + /** + * closeSync. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @function closeSync + * @returns {void} close success + * @throws {TypedError | Error} close fail + */ + closeSync(): void; +} + +/** + * Dirent + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ +declare interface Dirent { + /** + * @type {string} + * @readonly + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ + readonly name: string; + /** + * isBlockDevice. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isBlockDevice(): boolean; + /** + * isCharacterDevice. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isCharacterDevice(): boolean; + /** + * isDirectory. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isDirectory(): boolean; + /** + * isFIFO. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isFIFO(): boolean; + /** + * isFile. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isFile(): boolean; + /** + * isSocket. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isSocket(): boolean; + /** + * isSymbolicLink. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isSymbolicLink(): boolean; +} + +/** + * Stat + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ +declare interface Stat { + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly dev: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly ino: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly mode: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly nlink: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly uid: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly gid: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly rdev: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly size: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly blocks: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly atime: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly mtime: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + readonly ctime: number; + /** + * isBlockDevice. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isBlockDevice(): boolean; + /** + * isCharacterDevice. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isCharacterDevice(): boolean; + /** + * isDirectory. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isDirectory(): boolean; + /** + * isFIFO. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isFIFO(): boolean; + /** + * isFile. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isFile(): boolean; + /** + * isSocket. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isSocket(): boolean; + /** + * isSymbolicLink. + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {boolean} is or not + */ + isSymbolicLink(): boolean; +} + +/** + * Stream + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ +declare interface Stream { + /** + * close. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} close success + * @throws {TypedError | Error} close fail + */ + close(): Promise; + close(callback: AsyncCallback): void; + /** + * closeSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @returns {void} close success + * @throws {TypedError | Error} close fail + */ + closeSync(): void; + /** + * flush. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ + flush(): Promise; + flush(callback: AsyncCallback): void; + /** + * flushSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @returns {void} flush success + * @throws {Error} flush fail + */ + flushSync(): void; + /** + * write. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {ArrayBuffer | string} buffer - file description. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. + * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. + * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. + * @param {string} [options.encoding = 'utf-8'] - encoding. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ + write(buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + position?: number; + encoding?: string; + }): Promise; + write(buffer: ArrayBuffer | string, callback: AsyncCallback): void; + write(buffer: ArrayBuffer | string, options: { + offset?: number; + length?: number; + position?: number; + encoding?: string; + }, callback: AsyncCallback): void; + /** + * writeSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {ArrayBuffer | string} buffer - file description. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset(bytes) ignored when buffer is string. + * @param {number} [options.length = -1] - length(bytes) ignored when buffer is string. + * @param {number} [options.position = -1] - position(bytes) where start to write < 0 use read, else use pread. + * @param {string} [options.encoding = 'utf-8'] - encoding. + * @returns {number} on success number of bytes written + * @throws {TypedError | Error} write fail + */ + writeSync(buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + position?: number; + encoding?: string; + }): number; + /** + * read. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {ArrayBuffer} buffer - file description. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.length = -1] - length. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ + read(buffer: ArrayBuffer, options?: { + position?: number; + offset?: number; + length?: number; + }): Promise; + read(buffer: ArrayBuffer, callback: AsyncCallback): void; + read(buffer: ArrayBuffer, options: { + position?: number; + offset?: number; + length?: number; + }, callback: AsyncCallback): void; + /** + * readSync. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {ArrayBuffer} buffer - file description. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.length = -1] - length. + * @returns {number} number of bytesRead + * @throws {TypedError | Error} read fail + */ + readSync(buffer: ArrayBuffer, options?: { + position?: number; + offset?: number; + length?: number; + }): number; +} + +/** + * ReadOut + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + */ +declare interface ReadOut { + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + bytesRead: number; + /** + * @type {number} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + offset: number; + /** + * @type {ArrayBuffer} + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 6 + * @permission N/A + * @readonly + */ + buffer: ArrayBuffer; +} + +/** + * Watcher + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + */ +declare interface Watcher { + /** + * stop. + * + * @note N/A + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 7 + * @permission N/A + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} stop success + * @throws {TypedError | Error} stop fail + */ + stop(): Promise; + stop(callback: AsyncCallback): void; +} \ No newline at end of file -- Gitee