From 7f7c73e0e5883470adc71d362377b670a1cfb302 Mon Sep 17 00:00:00 2001 From: Fouckttt Date: Sat, 2 Aug 2025 21:46:14 +0800 Subject: [PATCH] Kernel Platform Overload Correction Issue:https://gitee.com/openharmony/interface_sdk-js/issues/ICQM97 Signed-off-by: Fouckttt --- .../ani/ets/@ohos.file.environment.ets | 11 +- .../js/src/mod_fs/ani/ets/@ohos.file.fs.ets | 304 +++++++++++------- .../ani/ets/@ohos.file.securityLabel.ets | 12 +- .../ani/ets/@ohos.file.statvfs.ets | 12 +- 4 files changed, 211 insertions(+), 128 deletions(-) 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 71b8e1c2d..12f2f7eb0 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 610c1094f..eb4f54914 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: number | File): Promise { +overload accessSync { accessSyncWithPathMode, accessSyncWithPathModeFlag }; + +function closeReturnsPromise(file: number | File): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((file: number | File): undefined => FileIoImpl.closeSync(file), file); promise.then((ret: NullishType): void => { @@ -100,7 +104,7 @@ function close(file: number | File): Promise { }); } -function close(file: number | File, callback: AsyncCallback): void { +function closeWithCallback(file: number | File, callback: AsyncCallback): void { let promise = taskpool.execute((file: number | File): undefined => FileIoImpl.closeSync(file), file); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -111,6 +115,8 @@ function close(file: number | File, callback: AsyncCallback): void { }); } +overload close { closeReturnsPromise, closeWithCallback }; + function closeSync(file: number | File): void { return FileIoImpl.closeSync(file) } @@ -164,7 +170,7 @@ function copyDirSync(src: string, dest: string, mode?: number): void { return FileIoImpl.copyDirSync(src, dest, mode); } -function copyDir(src: string, dest: string, mode?: number): Promise { +function copyDirReturnsPromise(src: string, dest: string, mode?: number): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError>) => void): void => { let promise = taskpool.execute((src: string, dest: string, mode?: number): undefined => @@ -177,7 +183,7 @@ function copyDir(src: string, dest: string, mode?: number): Promise { }); } -function copyDir(src: string, dest: string, callback: AsyncCallback>): void { +function copyDirWithAsyncCallbackOfArrayOfConflictFiles(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 +196,7 @@ function copyDir(src: string, dest: string, callback: AsyncCallback>): void { +function copyDirithModeAsyncCallbackOfArrayOfConflictFiles(src: string, dest: string, mode: number, callback: AsyncCallback>): void { let promise = taskpool.execute((src: string, dest: string, mode: number): undefined => FileIoImpl.copyDirSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { @@ -203,7 +209,7 @@ function copyDir(src: string, dest: string, mode: number, callback: AsyncCallbac }); } -function copyDir(arg0: Object, arg1: Object, arg2: NullishType, arg3: NullishType): void { +function copyDirWithArg0Arg1Arg2Arg3(arg0: Object, arg1: Object, arg2: NullishType, arg3: NullishType): void { let src = arg0 as string; let dest = arg1 as string; if (typeof arg2 === 'number' && typeof arg3 === 'function') { @@ -224,7 +230,10 @@ function copyDir(arg0: Object, arg1: Object, arg2: NullishType, arg3: NullishTyp } } -function mkdirSync(path: string): void { +overload copyDir { copyDirReturnsPromise, copyDirWithAsyncCallbackOfArrayOfConflictFiles, + copyDirithModeAsyncCallbackOfArrayOfConflictFiles, copyDirWithArg0Arg1Arg2Arg3 }; + +function mkdirSyncWithPath(path: string): void { return FileIoImpl.mkdirSync(path) } @@ -232,7 +241,7 @@ function fdatasyncSync(fd: number): void { return FileIoImpl.fdatasyncSync(fd) } -function fdatasync(fd: number): Promise { +function fdatasyncReturnsPromise(fd: number): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((fd: number): undefined => FileIoImpl.fdatasyncSync(fd), fd); promise.then((ret: NullishType): void => { @@ -243,7 +252,7 @@ function fdatasync(fd: number): Promise { }); } -function fdatasync(fd: number, callback: AsyncCallback): void { +function fdatasyncWithCallback(fd: number, callback: AsyncCallback): void { let promise = taskpool.execute((fd: number): undefined => FileIoImpl.fdatasyncSync(fd), fd); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -254,10 +263,14 @@ function fdatasync(fd: number, 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 +281,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 +292,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 +303,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 +315,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 +327,14 @@ function mkdir(path: string, recursion: boolean, callback: AsyncCallback): }); } +overload mkdir { mkdirReturnsPromise, mkdirWithRecursionReturnsPromise, + mkdirWithCallback, mkdirWithRecursionCallback }; + function moveDirSync(src: string, dest: string, mode?: number): void { return FileIoImpl.movedirSync(src, dest, mode) } -function moveDir(src: string, dest: string, mode?: number): Promise { +function moveDirReturnsPromise(src: string, dest: string, mode?: number): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError>) => void): void => { let promise = taskpool.execute((src: string, dest: string, mode?: number): undefined => { @@ -332,7 +348,7 @@ function moveDir(src: string, dest: string, mode?: number): Promise { }) } -function moveDir(src: string, dest: string, callback: AsyncCallback>): void { +function moveDirWithAsyncCallbackOfArrayOfConflictFiles(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 +362,7 @@ function moveDir(src: string, dest: string, callback: AsyncCallback>): void { +function moveDirWithModeAsyncCallbackOfArrayOfConflictFiles(src: string, dest: string, mode: number, callback: AsyncCallback>): void { let promise = taskpool.execute((src: string, dest: string, mode: number): undefined => { return FileIoImpl.movedirSync(src, dest, mode); }, src, dest, mode); @@ -360,7 +376,7 @@ function moveDir(src: string, dest: string, mode: number, callback: AsyncCallbac }); } -function moveDir(arg0: Object, arg1: Object, arg2: NullishType, arg3: NullishType): void { +function moveDirWithArg0Arg1Arg2Arg3(arg0: Object, arg1: Object, arg2: NullishType, arg3: NullishType): void { let src = arg0 as string; let dest = arg1 as string; if (typeof arg2 === 'number' && typeof arg3 === 'function') { @@ -381,11 +397,14 @@ function moveDir(arg0: Object, arg1: Object, arg2: NullishType, arg3: NullishTyp } } +overload moveDir { moveDirReturnsPromise, moveDirWithAsyncCallbackOfArrayOfConflictFiles, + moveDirWithArg0Arg1Arg2Arg3, moveDirWithModeAsyncCallbackOfArrayOfConflictFiles }; + 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 +418,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 +432,13 @@ function mkdtemp(prefix: string, callback: AsyncCallback): void { }); } +overload mkdtemp { mkdtempReturnsPromise, mkdtempWithCallback }; + function moveFileSync(src: string, dest: string, mode?: number): void { return FileIoImpl.moveFileSync(src, dest, mode); } -function moveFile(src: string, dest: string, mode?: number): Promise { +function moveFileReturnsPromise(src: string, dest: string, mode?: number): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((src: string, dest: string, mode?: number): undefined => { return FileIoImpl.moveFileSync(src, dest, mode); @@ -430,7 +451,7 @@ function moveFile(src: string, dest: string, mode?: number): Promise { }); } -function moveFile(src: string, dest: string, mode: number, callback: AsyncCallback): void { +function moveFileWithModeCallback(src: string, dest: string, mode: number, callback: AsyncCallback): void { let promise = taskpool.execute((src: string, dest: string, mode: number): undefined => { return FileIoImpl.moveFileSync(src, dest, mode); }, src, dest, mode); @@ -443,7 +464,7 @@ function moveFile(src: string, dest: string, mode: number, callback: AsyncCallba }); } -function moveFile(src: string, dest: string, callback: AsyncCallback): void { +function movemoveFileWithCallbackFile(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 +477,13 @@ function moveFile(src: string, dest: string, callback: AsyncCallback): voi }); } +overload moveFile { moveFileReturnsPromise, moveFileWithCallback, moveFileWithModeCallback }; + function openSync(path: string, mode?: number): File { return FileIoImpl.openSync(path, mode); } -function open(path: String, mode?: number): Promise { +function openReturnsPromise(path: String, mode?: number): Promise { return new Promise((resolve: (result: File) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((path: String, mode?: number): File => { return FileIoImpl.openSync(path, mode); @@ -474,7 +497,7 @@ function open(path: String, mode?: number): Promise { }); } -function open(path: String, mode: number, callback: AsyncCallback): void { +function openWithModeCallback(path: String, mode: number, callback: AsyncCallback): void { let promise = taskpool.execute((path: String, mode: number): File => { return FileIoImpl.openSync(path, mode); }, path, mode); @@ -489,7 +512,7 @@ function open(path: String, mode: number, callback: AsyncCallback): }); } -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 +527,13 @@ function open(path: String, callback: AsyncCallback): void { }); } +overload open { openReturnsPromise, openWithCallback, openWithModeCallback }; + function writeSync(fd: number, buffer: string | ArrayBuffer, options?: WriteOptions): number { return FileIoImpl.writeSync(fd, buffer, options); } -function write(fd: number, buffer: string | ArrayBuffer, options?: WriteOptions): Promise { +function writeReturnsPromise(fd: number, buffer: string | ArrayBuffer, options?: WriteOptions): Promise { return new Promise((resolve: (result: number) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((fd: number, buffer: string | ArrayBuffer, options?: WriteOptions): number => { return FileIoImpl.writeSync(fd, buffer, options); @@ -522,7 +547,7 @@ function write(fd: number, buffer: string | ArrayBuffer, options?: WriteOptions) }); } -function write(fd: number, buffer: string | ArrayBuffer, options: WriteOptions, +function writeWithOptionsCallback(fd: number, buffer: string | ArrayBuffer, options: WriteOptions, callback: AsyncCallback): void { let promise = taskpool.execute((fd: number, buffer: string | ArrayBuffer, options: WriteOptions): number => { return FileIoImpl.writeSync(fd, buffer, options); @@ -537,7 +562,7 @@ function write(fd: number, buffer: string | ArrayBuffer, options: WriteOptions, }); } -function write(fd: number, buffer: string | ArrayBuffer, callback: AsyncCallback): void { +function writeWithCallback(fd: number, buffer: string | ArrayBuffer, callback: AsyncCallback): void { let promise = taskpool.execute((fd: number, buffer: string | ArrayBuffer): number => { return FileIoImpl.writeSync(fd, buffer); }, fd, buffer); @@ -551,11 +576,13 @@ function write(fd: number, buffer: string | ArrayBuffer, callback: AsyncCallback }); } +overload write { writeReturnsPromise, writeWithCallback, writeWithOptionsCallback }; + function readSync(fd: number, buffer: ArrayBuffer, options?: ReadOptions): number { return FileIoImpl.readSync(fd, buffer, options) } -function read(fd: number, buffer: ArrayBuffer, options?: ReadOptions): Promise { +function readReturnsPromise(fd: number, buffer: ArrayBuffer, options?: ReadOptions): Promise { return new Promise((resolve: (result: number) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((fd: number, buffer: ArrayBuffer, options?: ReadOptions): number => { return FileIoImpl.readSync(fd, buffer, options) @@ -569,7 +596,7 @@ function read(fd: number, buffer: ArrayBuffer, options?: ReadOptions): Promise): void { +function readWithCallback(fd: number, buffer: ArrayBuffer, callback: AsyncCallback): void { let promise = taskpool.execute((fd: number, buffer: ArrayBuffer): number => { return FileIoImpl.readSync(fd, buffer); }, fd, buffer); @@ -583,7 +610,7 @@ function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback): void { +function readWithOptionsCallback(fd: number, buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void { let promise = taskpool.execute((fd: number, buffer: ArrayBuffer, options: ReadOptions): number => { return FileIoImpl.readSync(fd, buffer, options); }, fd, buffer, options); @@ -597,11 +624,13 @@ function read(fd: number, buffer: ArrayBuffer, options: ReadOptions, callback: A }); } +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 +645,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 +660,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 +675,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 +693,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 +704,13 @@ function rmdir(path: string, callback: AsyncCallback): void { }); } +overload rmdir { rmdirReturnsPromise, rmdirWithCallback }; + function truncateSync(file: string | number, len?: number): void { return FileIoImpl.truncateSync(file, len) } -function truncate(file: string | number, len?: number): Promise { +function truncateReturnsPromise(file: string | number, len?: number): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((file: string | number, len?: number): undefined => { return FileIoImpl.truncateSync(file, len); @@ -690,7 +723,7 @@ function truncate(file: string | number, len?: number): Promise { }) } -function truncate(file: string | number, callback: AsyncCallback): void { +function truncateWithCallback(file: string | number, callback: AsyncCallback): void { let promise = taskpool.execute((file: string | number): undefined => { return FileIoImpl.truncateSync(file); }, file); @@ -703,7 +736,7 @@ function truncate(file: string | number, callback: AsyncCallback): void { }); } -function truncate(file: string | number, len: number, callback: AsyncCallback): void { +function truncateWithLenCallback(file: string | number, len: number, callback: AsyncCallback): void { let promise = taskpool.execute((file: string | number, len: number): undefined => { return FileIoImpl.truncateSync(file, len); }, file, len); @@ -716,11 +749,13 @@ function truncate(file: string | number, len: number, callback: AsyncCallback { +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 +767,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 +778,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 +794,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 +808,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 +822,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 +842,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 +856,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 +870,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 +884,7 @@ function statSync(file: string | number): Stat { return FileIoImpl.statSync(file) } -function stat(file: string | number): Promise { +function statReturnsPromise(file: string | number): Promise { return new Promise((resolve: (result: Stat) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((file: string | number): Stat => { return FileIoImpl.statSync(file); @@ -857,7 +898,7 @@ function stat(file: string | number): Promise { }); } -function stat(file: string | number, callback: AsyncCallback): void { +function statWithCallback(file: string | number, callback: AsyncCallback): void { let p = taskpool.execute((file: string | number): Stat => { return FileIoImpl.statSync(file); }, file); @@ -871,11 +912,13 @@ function stat(file: string | number, callback: AsyncCallback): void }); } +overload stat { statReturnsPromise, statWithCallback }; + function fsyncSync(fd: number): void { return FileIoImpl.fsyncSync(fd); } -function fsync(fd: number): Promise { +function fsyncReturnsPromise(fd: number): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((fd: number): undefined => { return FileIoImpl.fsyncSync(fd); @@ -888,7 +931,7 @@ function fsync(fd: number): Promise { }); } -function fsync(fd: number, callback: AsyncCallback): void { +function fsyncWithCallback(fd: number, callback: AsyncCallback): void { let promise = taskpool.execute((fd: number): undefined => { return FileIoImpl.fsyncSync(fd); }, fd); @@ -901,11 +944,13 @@ function fsync(fd: number, 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 +967,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 +980,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 +993,14 @@ function rename(oldPath: string, newPath: string, callback: AsyncCallback) }); } +overload rename { renameReturnsPromise, renameWithCallback }; + function createRandomAccessFileSync(file: string | File, mode?: number, options?: RandomAccessFileOptions): RandomAccessFile { return FileIoImpl.createRandomAccessFileSync(file, mode, options); } -function createRandomAccessFile(file: string | File, mode?: number, +function createRandomAccessFileReturnsPromise(file: string | File, mode?: number, options?: RandomAccessFileOptions): Promise { return new Promise((resolve: (result: RandomAccessFile) => void, reject: (e: BusinessError) => void) => { @@ -970,7 +1017,7 @@ function createRandomAccessFile(file: string | File, mode?: number, }); } -function fdopenStream(fd: number, mode: string): Promise { +function fdopenStreamReturnsPromise(fd: number, mode: string): Promise { return new Promise((resolve: (result: Stream) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((fd: number, mode: string): Stream => { return FileIoImpl.fdopenStreamSync(fd, mode); @@ -1000,7 +1047,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 +1062,7 @@ function createRandomAccessFile(file: string | File, callback: AsyncCallback): void { let promise = taskpool.execute((file: string | File, mode: number): RandomAccessFile => { return FileIoImpl.createRandomAccessFileSync(file, mode); @@ -1031,7 +1078,10 @@ function createRandomAccessFile(file: string | File, mode: number, }); } -function fdopenStream(fd: number, mode: string, callback: AsyncCallback): void { +overload createRandomAccessFile { createRandomAccessFileReturnsPromise, createRandomAccessFileWithCallback, + createRandomAccessFileWithModeCallback }; + +function fdopenStreamWithCallback(fd: number, mode: string, callback: AsyncCallback): void { let promise = taskpool.execute((fd: number, mode: string): Stream => { return FileIoImpl.fdopenStreamSync(fd, mode); }, fd, mode); @@ -1046,11 +1096,13 @@ function fdopenStream(fd: number, mode: string, callback: AsyncCallback) }); } +overload fdopenStream { fdopenStreamReturnsPromise, fdopenStreamWithCallback }; + function fdopenStreamSync(fd: number, 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 +1116,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 +1131,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 +1162,8 @@ function symlink(target: string, srcPath: string, callback: AsyncCallback) }); } +overload symlink { symlinkReturnsPromise, symlinkWithCallback }; + function utimes(path: string, mtime: number): void { return FileIoImpl.utimes(path, mtime); } @@ -1116,7 +1172,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 +1192,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 +1211,10 @@ function lstat(path: string, callback: AsyncCallback): void { callback(e as BusinessError, new StatInner(0)); }); } -function copyFile(src: string | number, dest: string | number, mode?: number): Promise { + +overload lstat { lstatReturnsPromise, lstatWithCallback }; + +function copyFileReturnsPromise(src: string | number, dest: string | number, mode?: number): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((src: string | number, dest: string | number, mode?: number): undefined => FileIoImpl.copyFileSync(src, dest, mode), src, dest, mode); @@ -1167,7 +1226,7 @@ function copyFile(src: string | number, dest: string | number, mode?: number): P }); } -function copy(srcUri: string, destUri: string, options?: CopyOptions): 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 +1238,7 @@ function copy(srcUri: string, destUri: string, options?: CopyOptions): Promise): void { +function copyFileWithModeCallback(src: string | number, dest: string | number, mode: number, callback: AsyncCallback): void { let promise = taskpool.execute((src: string | number, dest: string | number, mode: number): undefined => FileIoImpl.copyFileSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { @@ -1191,7 +1250,7 @@ function copyFile(src: string | number, dest: string | number, mode: number, cal }); } -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 +1262,7 @@ function copy(srcUri: string, destUri: string, options: CopyOptions, callback: A }); } -function copyFile(src: string | number, dest: string | number, callback: AsyncCallback): void { +function copyFileWithCallback(src: string | number, dest: string | number, callback: AsyncCallback): void { let promise = taskpool.execute((src: string | number, dest: string | number): undefined => FileIoImpl.copyFileSync(src, dest), src, dest); promise.then((ret: NullishType): void => { @@ -1215,7 +1274,9 @@ function copyFile(src: string | number, dest: string | number, callback: AsyncCa }); } -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 +1288,8 @@ function copy(srcUri: string, destUri: string, callback: AsyncCallback): v }); } +overload copy { copyReturnsPromise, copyWithCallback, copyWithOptionsCallback }; + function lseek(fd: number, offset: number, whence?: WhenceType): number { return FileIoImpl.lseekSync(fd, offset, whence); } @@ -1312,13 +1375,15 @@ export interface RandomAccessFile { setFilePointer(filePointer: number): 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): number; - 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): number; getReadStream(): ReadStream; getWriteStream(): WriteStream; @@ -1353,7 +1418,7 @@ export class RandomAccessFileInner implements RandomAccessFile { native writeSync0(buffer: ArrayBuffer | string, options?: WriteOptions): number; - write(buffer: ArrayBuffer | string, options?: WriteOptions): Promise { + writeReturnsPromise(buffer: ArrayBuffer | string, options?: WriteOptions): Promise { return new Promise((resolve: (result: number) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((buffer: ArrayBuffer | string, options?: WriteOptions): number => { return this.writeSync(buffer, options); @@ -1367,7 +1432,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): number => { return this.writeSync(buffer, options); }, buffer, options); @@ -1381,7 +1446,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): number => { return this.writeSync(buffer); }, buffer); @@ -1403,7 +1468,7 @@ export class RandomAccessFileInner implements RandomAccessFile { native readSync0(buffer: ArrayBuffer, options?: ReadOptions): number; - read(buffer: ArrayBuffer, options?: ReadOptions): Promise { + readReturnsPromise(buffer: ArrayBuffer, options?: ReadOptions): Promise { return new Promise((resolve: (result: number) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((buffer: ArrayBuffer, options?: ReadOptions): number => { return this.readSync(buffer, options); @@ -1417,7 +1482,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): number => { return this.readSync(buffer, options); }, buffer, options); @@ -1431,7 +1496,7 @@ export class RandomAccessFileInner implements RandomAccessFile { }); } - read(buffer: ArrayBuffer, callback: AsyncCallback): void { + readWithCallback(buffer: ArrayBuffer, callback: AsyncCallback): void { let promise = taskpool.execute((buffer: ArrayBuffer): number => { return this.readSync(buffer); }, buffer); @@ -1455,9 +1520,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; } @@ -1478,7 +1544,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); @@ -1491,7 +1557,7 @@ export class FileInner implements File { }); } - lock(callback: AsyncCallback): void { + lockWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): undefined => { return this.lockSync(); }); @@ -1504,7 +1570,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); @@ -1612,19 +1678,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): number; - 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): number; seek(offset: number, whence?: number): number; } @@ -1638,7 +1708,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 => { @@ -1649,7 +1719,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(); @@ -1662,7 +1732,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 => { @@ -1673,7 +1743,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(); @@ -1686,7 +1756,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: number) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((buffer: ArrayBuffer | string, options?: WriteOptions): number => { return this.writeSync(buffer, options); @@ -1700,7 +1770,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): number => { return this.writeSync(buffer); }, buffer); @@ -1714,7 +1784,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): number => { return this.writeSync(buffer, options); }, buffer, options); @@ -1730,7 +1800,7 @@ export class StreamInner implements Stream { native writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): number; - read(buffer: ArrayBuffer, options?: ReadOptions): Promise { + readReturnsPromise(buffer: ArrayBuffer, options?: ReadOptions): Promise { return new Promise((resolve: (result: number) => void, reject: (e: BusinessError) => void) => { let promise = taskpool.execute((buffer: ArrayBuffer, options?: ReadOptions): number => { return this.readSync(buffer, options); @@ -1744,7 +1814,7 @@ export class StreamInner implements Stream { }); } - read(buffer: ArrayBuffer, callback: AsyncCallback): void { + readWithCallback(buffer: ArrayBuffer, callback: AsyncCallback): void { let promise = taskpool.execute((buffer: ArrayBuffer): number => { return this.readSync(buffer); }, buffer); @@ -1758,7 +1828,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): number => { return this.readSync(buffer, options); }, buffer, options); @@ -2141,9 +2211,11 @@ export class FileIoImpl { static native lseekSync(fd: number, offset: number, whence?: fileIo.WhenceType): number; - 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?: number): 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 4f81cef3d..bb5e483f2 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 f3c569c80..80e459c2c 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: number) => 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): number { return StatvfsImpl.getTotalSizeSync(path); } - export function getTotalSize(path: string): Promise { + export function getTotalSizeReturnsPromise(path: string): Promise { return new Promise((resolve: (result: number) => 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; -- Gitee