diff --git a/interfaces/kits/js/src/mod_environment/ani/ets/@ohos.file.environment.ets b/interfaces/kits/js/src/mod_environment/ani/ets/@ohos.file.environment.ets index 71b8e1c2dac3e5e36a47f44b92cdb0f47dd4591a..55fd59a0f2406d7c518a5d22bdc7483aab199a15 100644 --- a/interfaces/kits/js/src/mod_environment/ani/ets/@ohos.file.environment.ets +++ b/interfaces/kits/js/src/mod_environment/ani/ets/@ohos.file.environment.ets @@ -16,7 +16,7 @@ import { BusinessError, AsyncCallback } from '@ohos.base'; namespace Environment { - export function getStorageDataDir(): Promise { + export function getStorageDataDirReturnsPromise(): Promise { return new Promise((resolve: (result: string) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute(EnvironmentImpl.getStorageDataDirSync); promise.then((ret: NullishType): void => { @@ -28,7 +28,7 @@ namespace Environment { }); } - export function getStorageDataDir(callback: AsyncCallback): void { + export function getStorageDataDirWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute(EnvironmentImpl.getStorageDataDirSync); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -40,7 +40,9 @@ namespace Environment { }); } - export function getUserDataDir(): Promise { + export overload getStorageDataDir { getStorageDataDirReturnsPromise, getStorageDataDirWithCallback } + + export function getUserDataDirReturnsPromise(): Promise { return new Promise((resolve: (result: string) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute(EnvironmentImpl.getUserDataDirSync); promise.then((ret: NullishType): void => { @@ -51,7 +53,7 @@ namespace Environment { }); }); } - export function getUserDataDir(callback: AsyncCallback): void { + export function getUserDataDirWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute(EnvironmentImpl.getUserDataDirSync); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -62,6 +64,7 @@ namespace Environment { callback(e as BusinessError, ""); }); } + export overload getUserDataDir { getUserDataDirReturnsPromise, getUserDataDirWithCallback } export function getUserDownloadDir(): string { return EnvironmentImpl.getUserDownloadDirSync(); diff --git a/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets b/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets index ee6be66d5a913dac4d46191cb7135bf55eee7c44..4b42b75fc2de98f6547036723053899e3262a16b 100644 --- a/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets +++ b/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets @@ -39,7 +39,7 @@ namespace fileIo { export const SYNC = 0o4010000; } -function access(path: string, mode?: AccessModeType): Promise { +function accessReturnsPromise(path: string, mode?: AccessModeType): Promise { return new Promise((resolve: (result: boolean) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((path: string, mode?: AccessModeType): boolean => { return FileIoImpl.doAccessSync(path, mode); @@ -53,7 +53,7 @@ function access(path: string, mode?: AccessModeType): Promise { }); } -function access(path: string, callback: AsyncCallback): void { +function accessWithCallback(path: string, callback: AsyncCallback): void { let promise = taskpool.execute((path: string): boolean => { return FileIoImpl.doAccessSync(path); }, path); @@ -67,7 +67,7 @@ function access(path: string, callback: AsyncCallback): void { }); } -function access(path: string, mode: AccessModeType, flag: AccessFlagType): Promise { +function accessWithFlagReturnsPromise(path: string, mode: AccessModeType, flag: AccessFlagType): Promise { return new Promise((resolve: (result: boolean) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((path: string, mode: AccessModeType, flag: AccessFlagType): boolean => { return FileIoImpl.doAccessSync(path, mode, flag); @@ -81,15 +81,19 @@ function access(path: string, mode: AccessModeType, flag: AccessFlagType): Promi }) } -function accessSync(path: string, mode?: AccessModeType): boolean { +overload access { accessReturnsPromise, accessWithCallback, accessWithFlagReturnsPromise } + +function accessSyncWithPathMode(path: string, mode?: AccessModeType): boolean { return FileIoImpl.doAccessSync(path, mode); } -function accessSync(path: string, mode: AccessModeType, flag: AccessFlagType): boolean { +function accessSyncWithPathModeFlag(path: string, mode: AccessModeType, flag: AccessFlagType): boolean { return FileIoImpl.doAccessSync(path, mode, flag); } -function close(file: int | File): Promise { +overload accessSync { accessSyncWithPathMode, accessSyncWithPathModeFlag } + +function closeReturnsPromise(file: int | File): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((file: int | File): undefined => FileIoImpl.closeSync(file), file); promise.then((ret: NullishType): void => { @@ -100,7 +104,7 @@ function close(file: int | File): Promise { }); } -function close(file: int | File, callback: AsyncCallback): void { +function closeWithCallback(file: int | File, callback: AsyncCallback): void { let promise = taskpool.execute((file: int | File): undefined => FileIoImpl.closeSync(file), file); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -111,6 +115,8 @@ function close(file: int | File, callback: AsyncCallback): void { }); } +overload close { closeReturnsPromise, closeWithCallback } + function closeSync(file: int | File): void { return FileIoImpl.closeSync(file) } @@ -164,7 +170,7 @@ function copyDirSync(src: string, dest: string, mode?: int): void { return FileIoImpl.copyDirSync(src, dest, mode); } -function copyDir(src: string, dest: string, mode?: int): Promise { +function copyDirReturnsPromise(src: string, dest: string, mode?: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError>) => void): void => { let promise = taskpool.execute((src: string, dest: string, mode?: int): undefined => @@ -177,7 +183,8 @@ function copyDir(src: string, dest: string, mode?: int): Promise { }); } -function copyDir(src: string, dest: string, callback: AsyncCallback>): void { +function copyDirWithCallbackOfArrayOfConflictFiles(src: string, dest: string, + callback: AsyncCallback>): void { let promise = taskpool.execute((src: string, dest: string): undefined => FileIoImpl.copyDirSync(src, dest), src, dest); promise.then((ret: NullishType): void => { @@ -190,7 +197,8 @@ function copyDir(src: string, dest: string, callback: AsyncCallback>): void { +function copyDirWithModeCallbackOfArrayOfConflictFiles(src: string, dest: string, + mode: int, callback: AsyncCallback>): void { let promise = taskpool.execute((src: string, dest: string, mode: int): undefined => FileIoImpl.copyDirSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { @@ -203,28 +211,35 @@ function copyDir(src: string, dest: string, mode: int, callback: AsyncCallback>; - copyDir(src, dest, mode, callback); - return; - } - if (typeof arg2 === 'function') { - let callback = arg2 as AsyncCallback>; - copyDir(src, dest, callback); - return; - } +function copyDirWithCallback(src: string, dest: string, callback: AsyncCallback): void { + let promise = taskpool.execute((src: string, dest: string): undefined => + FileIoImpl.copyDirSync(src, dest), src, dest); + promise.then((ret: NullishType): void => { + let e = new BusinessError(); + e.code = 0; + callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); + }); +} + +function copyDirWithModeCallback(src: string, dest: string, mode: int, callback: AsyncCallback): void { + let promise = taskpool.execute((src: string, dest: string, mode: int): undefined => + FileIoImpl.copyDirSync(src, dest, mode), src, dest, mode); + promise.then((ret: NullishType): void => { + let e = new BusinessError(); + e.code = 0; + callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); + }); } -function mkdirSync(path: string): void { +overload copyDir { copyDirReturnsPromise, copyDirWithCallback, + copyDirWithCallbackOfArrayOfConflictFiles, copyDirWithModeCallback, + copyDirWithModeCallbackOfArrayOfConflictFiles} + +function mkdirSyncWithPath(path: string): void { return FileIoImpl.mkdirSync(path) } @@ -232,7 +247,7 @@ function fdatasyncSync(fd: int): void { return FileIoImpl.fdatasyncSync(fd) } -function fdatasync(fd: int): Promise { +function fdatasyncReturnsPromise(fd: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((fd: int): undefined => FileIoImpl.fdatasyncSync(fd), fd); promise.then((ret: NullishType): void => { @@ -243,7 +258,7 @@ function fdatasync(fd: int): Promise { }); } -function fdatasync(fd: int, callback: AsyncCallback): void { +function fdatasyncWithCallback(fd: int, callback: AsyncCallback): void { let promise = taskpool.execute((fd: int): undefined => FileIoImpl.fdatasyncSync(fd), fd); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -254,10 +269,14 @@ function fdatasync(fd: int, callback: AsyncCallback): void { }); } -function mkdirSync(path: string, recursion: boolean): void { +overload fdatasync { fdatasyncReturnsPromise, fdatasyncWithCallback } + +function mkdirSyncWithPathRecursion(path: string, recursion: boolean): void { return FileIoImpl.mkdirSync(path, recursion) } +overload mkdirSync { mkdirSyncWithPath, mkdirSyncWithPathRecursion } + function mkdirSync1(path: string): undefined { FileIoImpl.mkdirSync(path); return undefined; @@ -268,7 +287,7 @@ function mkdirSync2(path: string, recursion: boolean): undefined { return undefined; } -function mkdir(path: string): Promise { +function mkdirReturnsPromise(path: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((path: string): undefined => mkdirSync1(path), path); promise.then((ret: NullishType): void => { @@ -279,7 +298,7 @@ function mkdir(path: string): Promise { }); } -function mkdir(path: string, callback: AsyncCallback): void { +function mkdirWithCallback(path: string, callback: AsyncCallback): void { let promise = taskpool.execute((path: string): undefined => mkdirSync1(path), path); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -290,7 +309,7 @@ function mkdir(path: string, callback: AsyncCallback): void { }); } -function mkdir(path: string, recursion: boolean): Promise { +function mkdirWithRecursionReturnsPromise(path: string, recursion: boolean): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((path: string, recursion: boolean): undefined => mkdirSync2(path, recursion), path, recursion); @@ -302,7 +321,7 @@ function mkdir(path: string, recursion: boolean): Promise { }); } -function mkdir(path: string, recursion: boolean, callback: AsyncCallback): void { +function mkdirWithRecursionCallback(path: string, recursion: boolean, callback: AsyncCallback): void { let promise = taskpool.execute((path: string, recursion: boolean): undefined => mkdirSync2(path, recursion), path, recursion); promise.then((ret: NullishType): void => { @@ -314,11 +333,14 @@ function mkdir(path: string, recursion: boolean, callback: AsyncCallback): }); } +overload mkdir { mkdirReturnsPromise, mkdirWithRecursionReturnsPromise, + mkdirWithCallback, mkdirWithRecursionCallback } + function moveDirSync(src: string, dest: string, mode?: int): void { return FileIoImpl.movedirSync(src, dest, mode) } -function moveDir(src: string, dest: string, mode?: int): Promise { +function moveDirReturnsPromise(src: string, dest: string, mode?: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError>) => void): void => { let promise = taskpool.execute((src: string, dest: string, mode?: int): undefined => { @@ -332,7 +354,7 @@ function moveDir(src: string, dest: string, mode?: int): Promise { }) } -function moveDir(src: string, dest: string, callback: AsyncCallback>): void { +function moveDirWithCallbackOfArrayOfConflictFiles(src: string, dest: string, callback: AsyncCallback>): void { let promise = taskpool.execute((src: string, dest: string): undefined => { return FileIoImpl.movedirSync(src, dest); }, src, dest); @@ -346,7 +368,7 @@ function moveDir(src: string, dest: string, callback: AsyncCallback>): void { +function moveDirWithModeCallbackOfArrayOfConflictFiles(src: string, dest: string, mode: int, callback: AsyncCallback>): void { let promise = taskpool.execute((src: string, dest: string, mode: int): undefined => { return FileIoImpl.movedirSync(src, dest, mode); }, src, dest, mode); @@ -360,32 +382,41 @@ function moveDir(src: string, dest: string, mode: int, callback: AsyncCallback>; - moveDir(src, dest, mode, callback); - return; - } - if (typeof arg2 === 'function') { - let callback = arg2 as AsyncCallback>; - moveDir(src, dest, callback); - return; - } +function moveDirWithCallback(src: string, dest: string, callback: AsyncCallback): void { + let promise = taskpool.execute((src: string, dest: string): undefined => { + return FileIoImpl.movedirSync(src, dest); + }, src, dest); + promise.then((ret: NullishType): void => { + let e = new BusinessError(); + e.code = 0; + callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); + }); } +function moveDirWithModeCallback(src: string, dest: string, mode: int, callback: AsyncCallback): void { + let promise = taskpool.execute((src: string, dest: string, mode: int): undefined => { + return FileIoImpl.movedirSync(src, dest, mode); + }, src, dest, mode); + promise.then((ret: NullishType): void => { + let e = new BusinessError(); + e.code = 0; + callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); + }); +} + +overload moveDir { moveDirReturnsPromise, moveDirWithCallback, + moveDirWithCallbackOfArrayOfConflictFiles, moveDirWithModeCallback, + moveDirWithModeCallbackOfArrayOfConflictFiles } + function mkdtempSync(prefix: string): string { return FileIoImpl.mkdtempSync(prefix); } -function mkdtemp(prefix: string): Promise { +function mkdtempReturnsPromise(prefix: string): Promise { return new Promise((resolve: (result: string) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((prefix: string): string => { return FileIoImpl.mkdtempSync(prefix); @@ -399,7 +430,7 @@ function mkdtemp(prefix: string): Promise { }); } -function mkdtemp(prefix: string, callback: AsyncCallback): void { +function mkdtempWithCallback(prefix: string, callback: AsyncCallback): void { let promise = taskpool.execute((prefix: string): string => { return FileIoImpl.mkdtempSync(prefix); }, prefix); @@ -413,11 +444,13 @@ function mkdtemp(prefix: string, callback: AsyncCallback): void { }); } +overload mkdtemp { mkdtempReturnsPromise, mkdtempWithCallback } + function moveFileSync(src: string, dest: string, mode?: int): void { return FileIoImpl.moveFileSync(src, dest, mode); } -function moveFile(src: string, dest: string, mode?: int): Promise { +function moveFileReturnsPromise(src: string, dest: string, mode?: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((src: string, dest: string, mode?: int): undefined => { return FileIoImpl.moveFileSync(src, dest, mode); @@ -430,7 +463,7 @@ function moveFile(src: string, dest: string, mode?: int): Promise { }); } -function moveFile(src: string, dest: string, mode: int, callback: AsyncCallback): void { +function moveFileWithModeCallback(src: string, dest: string, mode: int, callback: AsyncCallback): void { let promise = taskpool.execute((src: string, dest: string, mode: int): undefined => { return FileIoImpl.moveFileSync(src, dest, mode); }, src, dest, mode); @@ -443,7 +476,7 @@ function moveFile(src: string, dest: string, mode: int, callback: AsyncCallback< }); } -function moveFile(src: string, dest: string, callback: AsyncCallback): void { +function moveFileWithCallback(src: string, dest: string, callback: AsyncCallback): void { let promise = taskpool.execute((src: string, dest: string): undefined => { return FileIoImpl.moveFileSync(src, dest); }, src, dest); @@ -456,11 +489,13 @@ function moveFile(src: string, dest: string, callback: AsyncCallback): voi }); } +overload moveFile { moveFileReturnsPromise, moveFileWithCallback, moveFileWithModeCallback } + function openSync(path: string, mode?: int): File { return FileIoImpl.openSync(path, mode); } -function open(path: String, mode?: int): Promise { +function openReturnsPromise(path: String, mode?: int): Promise { return new Promise((resolve: (result: File) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((path: String, mode?: int): File => { return FileIoImpl.openSync(path, mode); @@ -474,7 +509,7 @@ function open(path: String, mode?: int): Promise { }); } -function open(path: String, mode: int, callback: AsyncCallback): void { +function openWithModeCallback(path: String, mode: int, callback: AsyncCallback): void { let promise = taskpool.execute((path: String, mode: int): File => { return FileIoImpl.openSync(path, mode); }, path, mode); @@ -489,7 +524,7 @@ function open(path: String, mode: int, callback: AsyncCallback): voi }); } -function open(path: String, callback: AsyncCallback): void { +function openWithCallback(path: String, callback: AsyncCallback): void { let promise = taskpool.execute((path: String): File => { return FileIoImpl.openSync(path); }, path); @@ -504,11 +539,13 @@ function open(path: String, callback: AsyncCallback): void { }); } +overload open { openReturnsPromise, openWithCallback, openWithModeCallback } + function writeSync(fd: int, buffer: string | ArrayBuffer, options?: WriteOptions): long { return FileIoImpl.writeSync(fd, buffer, options); } -function write(fd: int, buffer: string | ArrayBuffer, options?: WriteOptions): Promise { +function writeReturnsPromise(fd: int, buffer: string | ArrayBuffer, options?: WriteOptions): Promise { return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((fd: int, buffer: string | ArrayBuffer, options?: WriteOptions): long => { return FileIoImpl.writeSync(fd, buffer, options); @@ -522,7 +559,7 @@ function write(fd: int, buffer: string | ArrayBuffer, options?: WriteOptions): P }); } -function write(fd: int, buffer: string | ArrayBuffer, options: WriteOptions, +function writeWithOptionsCallback(fd: int, buffer: string | ArrayBuffer, options: WriteOptions, callback: AsyncCallback): void { let promise = taskpool.execute((fd: int, buffer: string | ArrayBuffer, options: WriteOptions): long => { return FileIoImpl.writeSync(fd, buffer, options); @@ -537,7 +574,7 @@ function write(fd: int, buffer: string | ArrayBuffer, options: WriteOptions, }); } -function write(fd: int, buffer: string | ArrayBuffer, callback: AsyncCallback): void { +function writeWithCallback(fd: int, buffer: string | ArrayBuffer, callback: AsyncCallback): void { let promise = taskpool.execute((fd: int, buffer: string | ArrayBuffer): long => { return FileIoImpl.writeSync(fd, buffer); }, fd, buffer); @@ -551,11 +588,13 @@ function write(fd: int, buffer: string | ArrayBuffer, callback: AsyncCallback { +function readReturnsPromise(fd: int, buffer: ArrayBuffer, options?: ReadOptions): Promise { return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((fd: int, buffer: ArrayBuffer, options?: ReadOptions): long => { return FileIoImpl.readSync(fd, buffer, options) @@ -569,7 +608,7 @@ function read(fd: int, buffer: ArrayBuffer, options?: ReadOptions): Promise): void { +function readWithCallback(fd: int, buffer: ArrayBuffer, callback: AsyncCallback): void { let promise = taskpool.execute((fd: int, buffer: ArrayBuffer): long => { return FileIoImpl.readSync(fd, buffer); }, fd, buffer); @@ -583,7 +622,7 @@ function read(fd: int, buffer: ArrayBuffer, callback: AsyncCallback) }); } -function read(fd: int, buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void { +function readWithOptionsCallback(fd: int, buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void { let promise = taskpool.execute((fd: int, buffer: ArrayBuffer, options: ReadOptions): long => { return FileIoImpl.readSync(fd, buffer, options); }, fd, buffer, options); @@ -597,11 +636,13 @@ function read(fd: int, buffer: ArrayBuffer, options: ReadOptions, callback: Asyn }); } +overload read { readReturnsPromise, readWithCallback, readWithOptionsCallback } + function readLinesSync(filePath: string, options?: Options): ReaderIterator { return FileIoImpl.readlinesSync(filePath, options) } -function readLines(filePath: string, options?: Options): Promise { +function readLinesReturnsPromise(filePath: string, options?: Options): Promise { return new Promise((resolve: (result: ReaderIterator) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((filePath: string, options?: Options): ReaderIterator => { @@ -616,7 +657,7 @@ function readLines(filePath: string, options?: Options): Promise }); } -function readLines(filePath: string, callback: AsyncCallback): void { +function readLinesWithCallback(filePath: string, callback: AsyncCallback): void { let promise = taskpool.execute((filePath: string): ReaderIterator => { return FileIoImpl.readlinesSync(filePath); }, filePath); @@ -631,7 +672,7 @@ function readLines(filePath: string, callback: AsyncCallback): v }); } -function readLines(filePath: string, options: Options, callback: AsyncCallback): void { +function readLinesWithOptionsCallback(filePath: string, options: Options, callback: AsyncCallback): void { let promise = taskpool.execute((filePath: string, options: Options): ReaderIterator => { return FileIoImpl.readlinesSync(filePath, options); }, filePath, options); @@ -646,11 +687,13 @@ function readLines(filePath: string, options: Options, callback: AsyncCallback { +function rmdirReturnsPromise(path: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((path: string): void => FileIoImpl.rmdirSync(path), path); @@ -662,7 +705,7 @@ function rmdir(path: string): Promise { }); } -function rmdir(path: string, callback: AsyncCallback): void { +function rmdirWithCallback(path: string, callback: AsyncCallback): void { let promise = taskpool.execute((path: string): void => FileIoImpl.rmdirSync(path), path); promise.then((ret: NullishType) => { let e = new BusinessError(); @@ -673,11 +716,13 @@ function rmdir(path: string, callback: AsyncCallback): void { }); } +overload rmdir { rmdirReturnsPromise, rmdirWithCallback } + function truncateSync(file: string | int, len?: long): void { return FileIoImpl.truncateSync(file, len) } -function truncate(file: string | int, len?: long): Promise { +function truncateReturnsPromise(file: string | int, len?: long): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((file: string | int, len?: long): undefined => { return FileIoImpl.truncateSync(file, len); @@ -690,7 +735,7 @@ function truncate(file: string | int, len?: long): Promise { }) } -function truncate(file: string | int, callback: AsyncCallback): void { +function truncateWithCallback(file: string | int, callback: AsyncCallback): void { let promise = taskpool.execute((file: string | int): undefined => { return FileIoImpl.truncateSync(file); }, file); @@ -703,7 +748,7 @@ function truncate(file: string | int, callback: AsyncCallback): void { }); } -function truncate(file: string | int, len: long, callback: AsyncCallback): void { +function truncateWithLenCallback(file: string | int, len: long, callback: AsyncCallback): void { let promise = taskpool.execute((file: string | int, len: long): undefined => { return FileIoImpl.truncateSync(file, len); }, file, len); @@ -716,11 +761,13 @@ function truncate(file: string | int, len: long, callback: AsyncCallback): }); } +overload truncate { truncateReturnsPromise, truncateWithCallback, truncateWithLenCallback } + function unlinkSync(path: string): void { return FileIoImpl.unlinkSync(path) } -function unlink(path: string): Promise { +function unlinkReturnsPromise(path: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((path: string): undefined => unlinkSync(path), path); @@ -732,7 +779,7 @@ function unlink(path: string): Promise { }); } -function unlink(path: string, callback: AsyncCallback): void { +function unlinkWithCallback(path: string, callback: AsyncCallback): void { let promise = taskpool.execute((path: string): undefined => unlinkSync(path), path); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -743,7 +790,9 @@ function unlink(path: string, callback: AsyncCallback): void { }); } -function readText(filePath: string, options?: ReadTextOptions): Promise { +overload unlink { unlinkReturnsPromise, unlinkWithCallback } + +function readTextReturnsPromise(filePath: string, options?: ReadTextOptions): Promise { return new Promise((resolve: (result: string) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((filePath: string, options?: ReadTextOptions): string => { return FileIoImpl.readTextSync(filePath, options); @@ -757,7 +806,7 @@ function readText(filePath: string, options?: ReadTextOptions): Promise }); } -function readText(filePath: string, callback: AsyncCallback): void { +function readTextWithCallback(filePath: string, callback: AsyncCallback): void { let promise = taskpool.execute((filePath: string): string => { return FileIoImpl.readTextSync(filePath); }, filePath); @@ -771,7 +820,7 @@ function readText(filePath: string, callback: AsyncCallback): void { }); } -function readText(filePath: string, options: ReadTextOptions, callback: AsyncCallback): void { +function readTextWithOptionsCallback(filePath: string, options: ReadTextOptions, callback: AsyncCallback): void { let promise = taskpool.execute((filePath: string, options: ReadTextOptions): string => { return FileIoImpl.readTextSync(filePath, options); }, filePath, options); @@ -785,11 +834,13 @@ function readText(filePath: string, options: ReadTextOptions, callback: AsyncCal }); } +overload readText { readTextReturnsPromise, readTextWithCallback, readTextWithOptionsCallback } + function readTextSync(filePath: string, options?: ReadTextOptions): string { return FileIoImpl.readTextSync(filePath, options); } -function listFile(path: string, options?: ListFileOptions): Promise { +function listFileReturnsPromise(path: string, options?: ListFileOptions): Promise { return new Promise((resolve: (result: string[]) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((path: string, options?: ListFileOptions): string[] => { return FileIoImpl.listFileSync(path, options); @@ -803,7 +854,7 @@ function listFile(path: string, options?: ListFileOptions): Promise { }); } -function listFile(path: string, callback: AsyncCallback): void { +function listFileWithCallback(path: string, callback: AsyncCallback): void { let promise = taskpool.execute((path: string): string[] => { return FileIoImpl.listFileSync(path); }, path); @@ -817,7 +868,7 @@ function listFile(path: string, callback: AsyncCallback): void { }); } -function listFile(path: string, options: ListFileOptions, callback: AsyncCallback): void { +function listFileWithOptionsCallback(path: string, options: ListFileOptions, callback: AsyncCallback): void { let promise = taskpool.execute((path: string, options: ListFileOptions): string[] => { return FileIoImpl.listFileSync(path, options); }, path, options); @@ -831,6 +882,8 @@ function listFile(path: string, options: ListFileOptions, callback: AsyncCallbac }); } +overload listFile { listFileReturnsPromise, listFileWithCallback, listFileWithOptionsCallback } + function listFileSync(path: string, options?: ListFileOptions): string[] { return FileIoImpl.listFileSync(path, options); } @@ -843,7 +896,7 @@ function statSync(file: string | int): Stat { return FileIoImpl.statSync(file) } -function stat(file: string | int): Promise { +function statReturnsPromise(file: string | int): Promise { return new Promise((resolve: (result: Stat) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((file: string | int): Stat => { return FileIoImpl.statSync(file); @@ -857,7 +910,7 @@ function stat(file: string | int): Promise { }); } -function stat(file: string | int, callback: AsyncCallback): void { +function statWithCallback(file: string | int, callback: AsyncCallback): void { let p = taskpool.execute((file: string | int): Stat => { return FileIoImpl.statSync(file); }, file); @@ -871,11 +924,13 @@ function stat(file: string | int, callback: AsyncCallback): void { }); } +overload stat { statReturnsPromise, statWithCallback } + function fsyncSync(fd: int): void { return FileIoImpl.fsyncSync(fd); } -function fsync(fd: int): Promise { +function fsyncReturnsPromise(fd: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((fd: int): undefined => { return FileIoImpl.fsyncSync(fd); @@ -888,7 +943,7 @@ function fsync(fd: int): Promise { }); } -function fsync(fd: int, callback: AsyncCallback): void { +function fsyncWithCallback(fd: int, callback: AsyncCallback): void { let promise = taskpool.execute((fd: int): undefined => { return FileIoImpl.fsyncSync(fd); }, fd); @@ -901,11 +956,13 @@ function fsync(fd: int, callback: AsyncCallback): void { }); } +overload fsync { fsyncReturnsPromise, fsyncWithCallback } + function symlinkSync(target: string, srcPath: string): void { return FileIoImpl.symlinkSync(target, srcPath); } -function symlink(target: string, srcPath: string): Promise { +function symlinkReturnsPromise(target: string, srcPath: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((target: string, srcPath: string): undefined => { @@ -922,7 +979,7 @@ function renameSync(oldPath: string, newPath: string): void { return FileIoImpl.renameSync(oldPath, newPath); } -function rename(oldPath: string, newPath: string): Promise { +function renameReturnsPromise(oldPath: string, newPath: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((oldPath: string, newPath: string): undefined => { return FileIoImpl.renameSync(oldPath, newPath); @@ -935,7 +992,7 @@ function rename(oldPath: string, newPath: string): Promise { }); } -function rename(oldPath: string, newPath: string, callback: AsyncCallback): void { +function renameWithCallback(oldPath: string, newPath: string, callback: AsyncCallback): void { let promise = taskpool.execute((oldPath: string, newPath: string): undefined => { return FileIoImpl.renameSync(oldPath, newPath); }, oldPath, newPath); @@ -948,12 +1005,14 @@ function rename(oldPath: string, newPath: string, callback: AsyncCallback) }); } +overload rename { renameReturnsPromise, renameWithCallback } + function createRandomAccessFileSync(file: string | File, mode?: int, options?: RandomAccessFileOptions): RandomAccessFile { return FileIoImpl.createRandomAccessFileSync(file, mode, options); } -function createRandomAccessFile(file: string | File, mode?: int, +function createRandomAccessFileReturnsPromise(file: string | File, mode?: int, options?: RandomAccessFileOptions): Promise { return new Promise((resolve: (result: RandomAccessFile) => void, reject: (e: BusinessError) => void) => { @@ -970,7 +1029,7 @@ function createRandomAccessFile(file: string | File, mode?: int, }); } -function fdopenStream(fd: int, mode: string): Promise { +function fdopenStreamReturnsPromise(fd: int, mode: string): Promise { return new Promise((resolve: (result: Stream) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((fd: int, mode: string): Stream => { return FileIoImpl.fdopenStreamSync(fd, mode); @@ -1000,7 +1059,7 @@ function setxattr(path: string, key: string, value: string): Promise { }); } -function createRandomAccessFile(file: string | File, callback: AsyncCallback): void { +function createRandomAccessFileWithCallback(file: string | File, callback: AsyncCallback): void { let promise = taskpool.execute((file: string | File): RandomAccessFile => { return FileIoImpl.createRandomAccessFileSync(file); }, file); @@ -1015,7 +1074,7 @@ function createRandomAccessFile(file: string | File, callback: AsyncCallback): void { let promise = taskpool.execute((file: string | File, mode: int): RandomAccessFile => { return FileIoImpl.createRandomAccessFileSync(file, mode); @@ -1031,7 +1090,10 @@ function createRandomAccessFile(file: string | File, mode: int, }); } -function fdopenStream(fd: int, mode: string, callback: AsyncCallback): void { +overload createRandomAccessFile { createRandomAccessFileReturnsPromise, createRandomAccessFileWithCallback, + createRandomAccessFileWithModeCallback } + +function fdopenStreamWithCallback(fd: int, mode: string, callback: AsyncCallback): void { let promise = taskpool.execute((fd: int, mode: string): Stream => { return FileIoImpl.fdopenStreamSync(fd, mode); }, fd, mode); @@ -1046,11 +1108,13 @@ function fdopenStream(fd: int, mode: string, callback: AsyncCallback): v }); } +overload fdopenStream { fdopenStreamReturnsPromise, fdopenStreamWithCallback } + function fdopenStreamSync(fd: int, mode: string): Stream { return FileIoImpl.fdopenStreamSync(fd, mode); } -function createStream(path: string, mode: string): Promise { +function createStreamReturnsPromise(path: string, mode: string): Promise { return new Promise((resolve: (result: Stream) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((path: string, mode: string): Stream => { return FileIoImpl.createStreamSync(path, mode); @@ -1064,7 +1128,7 @@ function createStream(path: string, mode: string): Promise { }); } -function createStream(path: string, mode: string, callback: AsyncCallback): void { +function createStreamWithCallback(path: string, mode: string, callback: AsyncCallback): void { let promise = taskpool.execute((path: string, mode: string): Stream => { return FileIoImpl.createStreamSync(path, mode); }, path, mode); @@ -1079,6 +1143,8 @@ function createStream(path: string, mode: string, callback: AsyncCallback): void { +function symlinkWithCallback(target: string, srcPath: string, callback: AsyncCallback): void { let promise = taskpool.execute((target: string, srcPath: string): undefined => { return FileIoImpl.symlinkSync(target, srcPath); }, target, srcPath); @@ -1108,6 +1174,8 @@ function symlink(target: string, srcPath: string, callback: AsyncCallback) }); } +overload symlink { symlinkReturnsPromise, symlinkWithCallback } + function utimes(path: string, mtime: double): void { return FileIoImpl.utimes(path, mtime); } @@ -1116,7 +1184,7 @@ function lstatSync(path: string): Stat { return FileIoImpl.lstatSync(path) } -function lstat(path: string): Promise { +function lstatReturnsPromise(path: string): Promise { return new Promise((resolve: (result: Stat) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((path: string): Stat => { return FileIoImpl.lstatSync(path); @@ -1136,7 +1204,7 @@ function lstat(path: string): Promise { }); } -function lstat(path: string, callback: AsyncCallback): void { +function lstatWithCallback(path: string, callback: AsyncCallback): void { let p = taskpool.execute((path: string): Stat => { return FileIoImpl.lstatSync(path); }, path); @@ -1155,7 +1223,10 @@ function lstat(path: string, callback: AsyncCallback): void { callback(e as BusinessError, new StatInner(0)); }); } -function copyFile(src: string | int, dest: string | int, mode?: int): Promise { + +overload lstat { lstatReturnsPromise, lstatWithCallback } + +function copyFileReturnsPromise(src: string | int, dest: string | int, mode?: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((src: string | int, dest: string | int, mode?: int): undefined => FileIoImpl.copyFileSync(src, dest, mode), src, dest, mode); @@ -1167,7 +1238,7 @@ function copyFile(src: string | int, dest: string | int, mode?: int): Promise { +function copyReturnsPromise(srcUri: string, destUri: string, options?: CopyOptions): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((srcUri: string, destUri: string, options?: CopyOptions): undefined => FileIoImpl.copySync(srcUri, destUri, options), srcUri, destUri, options); @@ -1179,7 +1250,7 @@ function copy(srcUri: string, destUri: string, options?: CopyOptions): Promise): void { +function copyFileWithModeCallback(src: string | int, dest: string | int, mode: int, callback: AsyncCallback): void { let promise = taskpool.execute((src: string | int, dest: string | int, mode: int): undefined => FileIoImpl.copyFileSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { @@ -1191,7 +1262,7 @@ function copyFile(src: string | int, dest: string | int, mode: int, callback: As }); } -function copy(srcUri: string, destUri: string, options: CopyOptions, callback: AsyncCallback): void { +function copyWithOptionsCallback(srcUri: string, destUri: string, options: CopyOptions, callback: AsyncCallback): void { let promise = taskpool.execute((srcUri: string, destUri: string, options: CopyOptions): undefined => FileIoImpl.copySync(srcUri, destUri, options), srcUri, destUri, options); promise.then((ret: NullishType): void => { @@ -1203,7 +1274,7 @@ function copy(srcUri: string, destUri: string, options: CopyOptions, callback: A }); } -function copyFile(src: string | int, dest: string | int, callback: AsyncCallback): void { +function copyFileWithCallback(src: string | int, dest: string | int, callback: AsyncCallback): void { let promise = taskpool.execute((src: string | int, dest: string | int): undefined => FileIoImpl.copyFileSync(src, dest), src, dest); promise.then((ret: NullishType): void => { @@ -1215,7 +1286,9 @@ function copyFile(src: string | int, dest: string | int, callback: AsyncCallback }); } -function copy(srcUri: string, destUri: string, callback: AsyncCallback): void { +overload copyFile { copyFileReturnsPromise, copyFileWithCallback, copyFileWithModeCallback } + +function copyWithCallback(srcUri: string, destUri: string, callback: AsyncCallback): void { let promise = taskpool.execute((srcUri: string, destUri: string): undefined => FileIoImpl.copySync(srcUri, destUri), srcUri, destUri); promise.then((ret: NullishType): void => { @@ -1227,6 +1300,8 @@ function copy(srcUri: string, destUri: string, callback: AsyncCallback): v }); } +overload copy { copyReturnsPromise, copyWithCallback, copyWithOptionsCallback } + function lseek(fd: int, offset: long, whence?: WhenceType): long { return FileIoImpl.lseekSync(fd, offset, whence); } @@ -1303,13 +1378,15 @@ export interface RandomAccessFile { setFilePointer(filePointer: long): void; close(): void; - write(buffer: ArrayBuffer | string, options?: WriteOptions): Promise; - write(buffer: ArrayBuffer | string, callback: AsyncCallback): void; - write(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void; + writeReturnsPromise(buffer: ArrayBuffer | string, options?: WriteOptions): Promise; + writeWithCallback(buffer: ArrayBuffer | string, callback: AsyncCallback): void; + writeWithOptionsCallback(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void; + overload write { writeReturnsPromise, writeWithCallback, writeWithOptionsCallback }; writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): long; - read(buffer: ArrayBuffer, options?: ReadOptions): Promise; - read(buffer: ArrayBuffer, callback: AsyncCallback): void; - read(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void; + readReturnsPromise(buffer: ArrayBuffer, options?: ReadOptions): Promise; + readWithCallback(buffer: ArrayBuffer, callback: AsyncCallback): void; + readWithOptionsCallback(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void; + overload read { readReturnsPromise, readWithCallback, readWithOptionsCallback }; readSync(buffer: ArrayBuffer, options?: ReadOptions): long; getReadStream(): ReadStream; getWriteStream(): WriteStream; @@ -1344,7 +1421,7 @@ export class RandomAccessFileInner implements RandomAccessFile { native writeSync0(buffer: ArrayBuffer | string, options?: WriteOptions): long; - write(buffer: ArrayBuffer | string, options?: WriteOptions): Promise { + writeReturnsPromise(buffer: ArrayBuffer | string, options?: WriteOptions): Promise { return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((buffer: ArrayBuffer | string, options?: WriteOptions): long => { return this.writeSync(buffer, options); @@ -1358,7 +1435,7 @@ export class RandomAccessFileInner implements RandomAccessFile { }); } - write(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void { + writeWithOptionsCallback(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void { let promise = taskpool.execute((buffer: ArrayBuffer | string, options: WriteOptions): long => { return this.writeSync(buffer, options); }, buffer, options); @@ -1372,7 +1449,7 @@ export class RandomAccessFileInner implements RandomAccessFile { }); } - write(buffer: ArrayBuffer | string, callback: AsyncCallback): void { + writeWithCallback(buffer: ArrayBuffer | string, callback: AsyncCallback): void { let promise = taskpool.execute((buffer: ArrayBuffer | string): long => { return this.writeSync(buffer); }, buffer); @@ -1394,7 +1471,7 @@ export class RandomAccessFileInner implements RandomAccessFile { native readSync0(buffer: ArrayBuffer, options?: ReadOptions): long; - read(buffer: ArrayBuffer, options?: ReadOptions): Promise { + readReturnsPromise(buffer: ArrayBuffer, options?: ReadOptions): Promise { return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((buffer: ArrayBuffer, options?: ReadOptions): long => { return this.readSync(buffer, options); @@ -1408,7 +1485,7 @@ export class RandomAccessFileInner implements RandomAccessFile { }); } - read(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void { + readWithOptionsCallback(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void { let promise = taskpool.execute((buffer: ArrayBuffer, options: ReadOptions): long => { return this.readSync(buffer, options); }, buffer, options); @@ -1422,7 +1499,7 @@ export class RandomAccessFileInner implements RandomAccessFile { }); } - read(buffer: ArrayBuffer, callback: AsyncCallback): void { + readWithCallback(buffer: ArrayBuffer, callback: AsyncCallback): void { let promise = taskpool.execute((buffer: ArrayBuffer): long => { return this.readSync(buffer); }, buffer); @@ -1446,9 +1523,10 @@ export interface File { name: String; getParent(): String; - lock(exclusive?: boolean): Promise; - lock(callback: AsyncCallback): void; - lock(exclusive: boolean, callback: AsyncCallback): void; + lockReturnsPromise(exclusive?: boolean): Promise; + lockWithCallback(callback: AsyncCallback): void; + lockWithExclusiveCallback(exclusive: boolean, callback: AsyncCallback): void; + overload lock { lockReturnsPromise, lockWithCallback, lockWithExclusiveCallback }; tryLock(exclusive?: boolean): void; unlock(): void; } @@ -1469,7 +1547,7 @@ export class FileInner implements File { native getParent(): String; native lockSync(exclusive?: boolean): void; - lock(exclusive?: boolean): Promise { + lockReturnsPromise(exclusive?: boolean): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((exclusive?: boolean): undefined => { return this.lockSync(exclusive); @@ -1482,7 +1560,7 @@ export class FileInner implements File { }); } - lock(callback: AsyncCallback): void { + lockWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): undefined => { return this.lockSync(); }); @@ -1495,7 +1573,7 @@ export class FileInner implements File { }); } - lock(exclusive: boolean, callback: AsyncCallback): void { + lockWithExclusiveCallback(exclusive: boolean, callback: AsyncCallback): void { let promise = taskpool.execute((exclusive: boolean): undefined => { return this.lockSync(exclusive); }, exclusive); @@ -1603,19 +1681,23 @@ export class StatInner implements Stat { } export interface Stream { - close(): Promise; - close(callback: AsyncCallback): void; + closeReturnsPromise(): Promise; + closeWithCallback(callback: AsyncCallback): void; + overload close { closeReturnsPromise, closeWithCallback }; closeSync(): void; - flush(): Promise; - flush(callback: AsyncCallback): void; + flushReturnsPromise(): Promise; + flushWithCallback(callback: AsyncCallback): void; + overload flush { flushReturnsPromise, flushWithCallback }; flushSync(): void; - write(buffer: ArrayBuffer | string, options?: WriteOptions): Promise; - write(buffer: ArrayBuffer | string, callback: AsyncCallback): void; - write(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void; + writeReturnsPromise(buffer: ArrayBuffer | string, options?: WriteOptions): Promise; + writeWithCallback(buffer: ArrayBuffer | string, callback: AsyncCallback): void; + writeWithOptionsCallback(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void; + overload write { writeReturnsPromise, writeWithCallback, writeWithOptionsCallback }; writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): long; - read(buffer: ArrayBuffer, options?: ReadOptions): Promise; - read(buffer: ArrayBuffer, callback: AsyncCallback): void; - read(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void; + readReturnsPromise(buffer: ArrayBuffer, options?: ReadOptions): Promise; + readWithCallback(buffer: ArrayBuffer, callback: AsyncCallback): void; + readWithOptionsCallback(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void; + overload read { readReturnsPromise, readWithCallback, readWithOptionsCallback }; readSync(buffer: ArrayBuffer, options?: ReadOptions): long; seek(offset: long, whence?: int): long; } @@ -1629,7 +1711,7 @@ export class StreamInner implements Stream { } } - close(): Promise { + closeReturnsPromise(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): undefined => this.closeSync()); promise.then((ret: NullishType): void => { @@ -1640,7 +1722,7 @@ export class StreamInner implements Stream { }); } - close(callback: AsyncCallback): void { + closeWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): undefined => this.closeSync()); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -1653,7 +1735,7 @@ export class StreamInner implements Stream { native closeSync(): void; - flush(): Promise { + flushReturnsPromise(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): undefined => this.flushSync()); promise.then((ret: NullishType): void => { @@ -1664,7 +1746,7 @@ export class StreamInner implements Stream { }); } - flush(callback: AsyncCallback): void { + flushWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): undefined => this.flushSync()); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -1677,7 +1759,7 @@ export class StreamInner implements Stream { native flushSync(): void; - write(buffer: ArrayBuffer | string, options?: WriteOptions): Promise { + writeReturnsPromise(buffer: ArrayBuffer | string, options?: WriteOptions): Promise { return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((buffer: ArrayBuffer | string, options?: WriteOptions): long => { return this.writeSync(buffer, options); @@ -1691,7 +1773,7 @@ export class StreamInner implements Stream { }); } - write(buffer: ArrayBuffer | string, callback: AsyncCallback): void { + writeWithCallback(buffer: ArrayBuffer | string, callback: AsyncCallback): void { let promise = taskpool.execute((buffer: ArrayBuffer | string): long => { return this.writeSync(buffer); }, buffer); @@ -1705,7 +1787,7 @@ export class StreamInner implements Stream { }); } - write(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void { + writeWithOptionsCallback(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void { let promise = taskpool.execute((buffer: ArrayBuffer | string, options: WriteOptions): long => { return this.writeSync(buffer, options); }, buffer, options); @@ -1721,7 +1803,7 @@ export class StreamInner implements Stream { native writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): long; - read(buffer: ArrayBuffer, options?: ReadOptions): Promise { + readReturnsPromise(buffer: ArrayBuffer, options?: ReadOptions): Promise { return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((buffer: ArrayBuffer, options?: ReadOptions): long => { return this.readSync(buffer, options); @@ -1735,7 +1817,7 @@ export class StreamInner implements Stream { }); } - read(buffer: ArrayBuffer, callback: AsyncCallback): void { + readWithCallback(buffer: ArrayBuffer, callback: AsyncCallback): void { let promise = taskpool.execute((buffer: ArrayBuffer): long => { return this.readSync(buffer); }, buffer); @@ -1749,7 +1831,7 @@ export class StreamInner implements Stream { }); } - read(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void { + readWithOptionsCallback(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void { let promise = taskpool.execute((buffer: ArrayBuffer, options: ReadOptions): long => { return this.readSync(buffer, options); }, buffer, options); @@ -2138,9 +2220,11 @@ export class FileIoImpl { static native lseekSync(fd: int, offset: long, whence?: fileIo.WhenceType): long; - static native mkdirSync(path: string): void; + static native mkdirSyncWithPath(path: string): void; + + static native mkdirSyncWithPathRecursion(path: string, recursion: boolean): void; - static native mkdirSync(path: string, recursion: boolean): void; + static overload mkdirSync { mkdirSyncWithPath, mkdirSyncWithPathRecursion }; static native movedirSync(src: string, dest: string, mode?: int): void; diff --git a/interfaces/kits/js/src/mod_securitylabel/ani/ets/@ohos.file.securityLabel.ets b/interfaces/kits/js/src/mod_securitylabel/ani/ets/@ohos.file.securityLabel.ets index 4f81cef3d8fc0f2c702d436507c7493149fb2cfb..0860ec020bfcd4f569250234cd563d33cba629ac 100644 --- a/interfaces/kits/js/src/mod_securitylabel/ani/ets/@ohos.file.securityLabel.ets +++ b/interfaces/kits/js/src/mod_securitylabel/ani/ets/@ohos.file.securityLabel.ets @@ -18,7 +18,7 @@ import { BusinessError, AsyncCallback } from '@ohos.base'; namespace securityLabel { export type DataLevel = 's0' | 's1' | 's2' | 's3' | 's4'; - export function setSecurityLabel(path: string, type: DataLevel): Promise { + export function setSecurityLabelReturnsPromise(path: string, type: DataLevel): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((path: string, type: DataLevel): void => SecurityLabelImpl.setSecurityLabelSync(path, type), path, type); promise.then((ret: NullishType): void => { @@ -29,7 +29,7 @@ namespace securityLabel { }); } - export function setSecurityLabel(path: string, type: DataLevel, callback: AsyncCallback): void { + export function setSecurityLabelWithCallback(path: string, type: DataLevel, callback: AsyncCallback): void { let promise = taskpool.execute((path: string, type: DataLevel): void => SecurityLabelImpl.setSecurityLabelSync(path, type), path, type); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -40,11 +40,13 @@ namespace securityLabel { }); } + export overload setSecurityLabel { setSecurityLabelReturnsPromise, setSecurityLabelWithCallback } + export function setSecurityLabelSync(path: string, type: DataLevel): void { return SecurityLabelImpl.setSecurityLabelSync(path, type); } - export function getSecurityLabel(path: string): Promise { + export function getSecurityLabelReturnsPromise(path: string): Promise { return new Promise((resolve: (result: string) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((path: string): string => SecurityLabelImpl.getSecurityLabelSync(path), path); promise.then((ret: NullishType): void => { @@ -56,7 +58,7 @@ namespace securityLabel { }); } - export function getSecurityLabel(path: string, callback: AsyncCallback): void { + export function getSecurityLabelWithCallback(path: string, callback: AsyncCallback): void { let promise = taskpool.execute((path: string): string => SecurityLabelImpl.getSecurityLabelSync(path), path); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -68,6 +70,8 @@ namespace securityLabel { }); } + export overload getSecurityLabel { getSecurityLabelReturnsPromise, getSecurityLabelWithCallback } + export function getSecurityLabelSync(path: string): string { return SecurityLabelImpl.getSecurityLabelSync(path); } diff --git a/interfaces/kits/js/src/mod_statvfs/ani/ets/@ohos.file.statvfs.ets b/interfaces/kits/js/src/mod_statvfs/ani/ets/@ohos.file.statvfs.ets index 64d8e72845c13a880d5eefe8bac1c2fce690da43..737ed03e946f1529d0e466536ce06ede735993ae 100644 --- a/interfaces/kits/js/src/mod_statvfs/ani/ets/@ohos.file.statvfs.ets +++ b/interfaces/kits/js/src/mod_statvfs/ani/ets/@ohos.file.statvfs.ets @@ -20,7 +20,7 @@ namespace statfs { return StatvfsImpl.getFreeSizeSync(path); } - export function getFreeSize(path: string): Promise { + export function getFreeSizeReturnsPromise(path: string): Promise { return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute(StatvfsImpl.getFreeSizeSync, path); promise.then((ret: NullishType): void => { @@ -32,7 +32,7 @@ namespace statfs { }); } - export function getFreeSize(path: string, callback: AsyncCallback): void { + export function getFreeSizeWithCallback(path: string, callback: AsyncCallback): void { let promise = taskpool.execute(StatvfsImpl.getFreeSizeSync, path); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -44,11 +44,13 @@ namespace statfs { }); } + export overload getFreeSize { getFreeSizeWithCallback, getFreeSizeReturnsPromise } + export function getTotalSizeSync(path: string): long { return StatvfsImpl.getTotalSizeSync(path); } - export function getTotalSize(path: string): Promise { + export function getTotalSizeReturnsPromise(path: string): Promise { return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute(StatvfsImpl.getTotalSizeSync, path); promise.then((ret: NullishType): void => { @@ -60,7 +62,7 @@ namespace statfs { }); } - export function getTotalSize(path: string, callback: AsyncCallback): void { + export function getTotalSizeWithCallback(path: string, callback: AsyncCallback): void { let promise = taskpool.execute(StatvfsImpl.getTotalSizeSync, path); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -71,6 +73,8 @@ namespace statfs { callback(e as BusinessError, 0); }); } + + export overload getTotalSize { getTotalSizeWithCallback, getTotalSizeReturnsPromise } } export default statfs;