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 610c1094f2232012805a85fa2e79617f263dd8a4..28a5d25ac4029f9ada378b37c12003d0a0f240c1 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 @@ -13,7 +13,7 @@ * limitations under the License. */ import { BusinessError, AsyncCallback } from '@ohos.base'; -import stream from '@ohos.util.stream'; +// import stream from '@ohos.util.stream'; const UNKNOWN_ERR: number = 13900042 const UNKNOWN_MSG: string = "Unknown error" @@ -47,8 +47,8 @@ function access(path: string, mode?: AccessModeType): Promise { promise.then((ret: NullishType): void => { let result = ret as boolean; resolve(result); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -62,8 +62,8 @@ function access(path: string, callback: AsyncCallback): void { e.code = 0; let result = ret as boolean; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, false); + }).catch((e: BusinessError): void => { + callback(e, false); }); } @@ -75,8 +75,8 @@ function access(path: string, mode: AccessModeType, flag: AccessFlagType): Promi promise.then((ret: NullishType): void => { let result = ret as boolean; resolve(result); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }) } @@ -94,8 +94,8 @@ function close(file: number | File): Promise { let promise = taskpool.execute((file: number | File): undefined => FileIoImpl.closeSync(file), file); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -106,8 +106,8 @@ function close(file: number | File, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -121,8 +121,8 @@ function connectDfs(networkId: string, listeners: DfsListeners): Promise { FileIoImpl.connectDfs(networkId, listeners), networkId, listeners); promise.then((): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -132,8 +132,8 @@ function disconnectDfs(networkId: string): Promise { let promise = taskpool.execute((networkId: string): void => FileIoImpl.disConnectDfs(networkId), networkId); promise.then((): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -150,13 +150,13 @@ function getxattr(path: string, key: string): Promise { promise.then((ret: NullishType): void => { let result = ret as string; resolve(result); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } -function dup(fd: number): File { +function dup(fd: int): File { return FileIoImpl.dup(fd); } @@ -171,8 +171,8 @@ function copyDir(src: string, dest: string, mode?: number): Promise { FileIoImpl.copyDirSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError>); + }).catch((e: BusinessError>): void => { + reject(e); }); }); } @@ -185,8 +185,8 @@ function copyDir(src: string, dest: string, callback: AsyncCallback(0); callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError>, undefined); + }).catch((e: BusinessError>): void => { + callback(e, undefined); }); } @@ -198,8 +198,8 @@ function copyDir(src: string, dest: string, mode: number, callback: AsyncCallbac e.code = 0; e.data = new Array(0); callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError>, undefined); + }).catch((e: BusinessError>): void => { + callback(e, undefined); }); } @@ -237,7 +237,7 @@ function fdatasync(fd: number): Promise { let promise = taskpool.execute((fd: number): undefined => FileIoImpl.fdatasyncSync(fd), fd); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { + }).catch((e: BusinessError): void => { reject(e as BusinessError); }); }); @@ -249,8 +249,8 @@ function fdatasync(fd: number, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -273,7 +273,7 @@ function mkdir(path: string): Promise { let promise = taskpool.execute((path: string): undefined => mkdirSync1(path), path); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { + }).catch((e: BusinessError): void => { reject(e as BusinessError); }); }); @@ -285,8 +285,8 @@ function mkdir(path: string, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -309,8 +309,8 @@ function mkdir(path: string, recursion: boolean, callback: AsyncCallback): let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -326,8 +326,8 @@ function moveDir(src: string, dest: string, mode?: number): Promise { }, src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError>); + }).catch((e: BusinessError>): void => { + reject(e); }); }) } @@ -341,8 +341,8 @@ function moveDir(src: string, dest: string, callback: AsyncCallback(0); callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError>, undefined); + }).catch((e: BusinessError>): void => { + callback(e, undefined); }); } @@ -355,8 +355,8 @@ function moveDir(src: string, dest: string, mode: number, callback: AsyncCallbac e.code = 0; e.data = new Array(0); callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError>, undefined); + }).catch((e: BusinessError>): void => { + callback(e, undefined); }); } @@ -393,8 +393,8 @@ function mkdtemp(prefix: string): Promise { promise.then((ret: NullishType): void => { let result = ret as string; resolve(result); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -408,8 +408,8 @@ function mkdtemp(prefix: string, callback: AsyncCallback): void { e.code = 0; let result = ret as string; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, ""); + }).catch((e: BusinessError): void => { + callback(e, ""); }); } @@ -424,8 +424,8 @@ function moveFile(src: string, dest: string, mode?: number): Promise { }, src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -438,8 +438,8 @@ function moveFile(src: string, dest: string, mode: number, callback: AsyncCallba let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -451,8 +451,8 @@ function moveFile(src: string, dest: string, callback: AsyncCallback): voi let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -468,8 +468,8 @@ function open(path: String, mode?: number): Promise { promise.then((ret: NullishType): void => { let file = ret as File; resolve(file); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -483,9 +483,9 @@ function open(path: String, mode: number, callback: AsyncCallback): e.code = 0; let file = ret as File; callback(e, file); - }).catch((e: Error): void => { + }).catch((e: BusinessError): void => { let f: File = new FileInner(0); - callback(e as BusinessError, f); + callback(e, f); }); } @@ -498,9 +498,9 @@ function open(path: String, callback: AsyncCallback): void { e.code = 0; let file = ret as File; callback(e, file); - }).catch((e: Error): void => { + }).catch((e: BusinessError): void => { let f: File = new FileInner(0); - callback(e as BusinessError, f); + callback(e, f); }); } @@ -516,8 +516,8 @@ function write(fd: number, buffer: string | ArrayBuffer, options?: WriteOptions) promise.then((ret: NullishType): void => { let result = ret as number resolve(result); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -532,8 +532,8 @@ function write(fd: number, buffer: string | ArrayBuffer, options: WriteOptions, e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } @@ -546,31 +546,31 @@ function write(fd: number, buffer: string | ArrayBuffer, callback: AsyncCallback e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } -function readSync(fd: number, buffer: ArrayBuffer, options?: ReadOptions): number { +function readSync(fd: int, buffer: ArrayBuffer, options?: ReadOptions): long { return FileIoImpl.readSync(fd, buffer, options) } -function read(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 => { +function read(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) }, fd, buffer, options); promise.then((ret: NullishType) => { let result = ret as number; resolve(result); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } -function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback): void { - let promise = taskpool.execute((fd: number, buffer: ArrayBuffer): number => { +function read(fd: int, buffer: ArrayBuffer, callback: AsyncCallback): void { + let promise = taskpool.execute((fd: int, buffer: ArrayBuffer): long => { return FileIoImpl.readSync(fd, buffer); }, fd, buffer); promise.then((ret: NullishType): void => { @@ -578,13 +578,13 @@ function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } -function read(fd: number, buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void { - let promise = taskpool.execute((fd: number, buffer: ArrayBuffer, options: ReadOptions): number => { +function read(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); promise.then((ret: NullishType): void => { @@ -592,8 +592,8 @@ function read(fd: number, buffer: ArrayBuffer, options: ReadOptions, callback: A e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } @@ -610,8 +610,8 @@ function readLines(filePath: string, options?: Options): Promise promise.then((ret: NullishType): void => { let it = ret as ReaderIterator; resolve(it); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -625,9 +625,9 @@ function readLines(filePath: string, callback: AsyncCallback): v e.code = 0; let it = ret as ReaderIterator; callback(e, it); - }).catch((e: Error): void => { + }).catch((e: BusinessError): void => { let r: ReaderIterator = new ReaderIteratorInner(0); - callback(e as BusinessError, r); + callback(e, r); }); } @@ -640,9 +640,9 @@ function readLines(filePath: string, options: Options, callback: AsyncCallback { + }).catch((e: BusinessError): void => { let r: ReaderIterator = new ReaderIteratorInner(0); - callback(e as BusinessError, r); + callback(e, r); }); } @@ -656,8 +656,8 @@ function rmdir(path: string): Promise { let promise = taskpool.execute((path: string): void => FileIoImpl.rmdirSync(path), path); promise.then((ret: NullishType) => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -668,8 +668,8 @@ function rmdir(path: string, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -684,8 +684,8 @@ function truncate(file: string | number, len?: number): Promise { }, file, len); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }) } @@ -698,8 +698,8 @@ function truncate(file: string | number, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -711,8 +711,8 @@ function truncate(file: string | number, len: number, callback: AsyncCallback(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -726,8 +726,8 @@ function unlink(path: string): Promise { let promise = taskpool.execute((path: string): undefined => unlinkSync(path), path); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -738,8 +738,8 @@ function unlink(path: string, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -751,9 +751,9 @@ function readText(filePath: string, options?: ReadTextOptions): Promise promise.then((ret: NullishType): void => { let r = ret as string; resolve(r); - }).catch((e: Error): void => { - reject(e as BusinessError); - }); + }).catch((e: BusinessError): void => { + reject(e); + }); }); } @@ -766,8 +766,8 @@ function readText(filePath: string, callback: AsyncCallback): void { e.code = 0; let r = ret as string; callback(e, r); - }).catch((e: Error): void => { - callback(e as BusinessError, ""); + }).catch((e: BusinessError): void => { + callback(e, ""); }); } @@ -780,8 +780,8 @@ function readText(filePath: string, options: ReadTextOptions, callback: AsyncCal e.code = 0; let r = ret as string; callback(e, r); - }).catch((e: Error): void => { - callback(e as BusinessError, ""); + }).catch((e: BusinessError): void => { + callback(e, ""); }); } @@ -797,8 +797,8 @@ function listFile(path: string, options?: ListFileOptions): Promise { promise.then((ret: NullishType): void => { let r = ret as string[]; resolve(r); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -812,8 +812,8 @@ function listFile(path: string, callback: AsyncCallback): void { e.code = 0; let r = ret as string[]; callback(e, r); - }).catch((e: Error): void => { - callback(e as BusinessError, []); + }).catch((e: BusinessError): void => { + callback(e, []); }); } @@ -826,8 +826,8 @@ function listFile(path: string, options: ListFileOptions, callback: AsyncCallbac e.code = 0; let r = ret as string[]; callback(e, r); - }).catch((e: Error): void => { - callback(e as BusinessError, []); + }).catch((e: BusinessError): void => { + callback(e, []); }); } @@ -839,26 +839,26 @@ function copyFileSync(src: string | number, dest: string | number, mode?: number return FileIoImpl.copyFileSync(src, dest, mode) } -function statSync(file: string | number): Stat { +function statSync(file: string | int): Stat { return FileIoImpl.statSync(file) } -function stat(file: string | number): Promise { +function stat(file: string | int): Promise { return new Promise((resolve: (result: Stat) => void, reject: (e: BusinessError) => void) => { - let promise = taskpool.execute((file: string | number): Stat => { + let promise = taskpool.execute((file: string | int): Stat => { return FileIoImpl.statSync(file); }, file); promise.then((ret: NullishType): void => { let r = ret as Stat; resolve(r); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } -function stat(file: string | number, callback: AsyncCallback): void { - let p = taskpool.execute((file: string | number): Stat => { +function stat(file: string | int, callback: AsyncCallback): void { + let p = taskpool.execute((file: string | int): Stat => { return FileIoImpl.statSync(file); }, file); p.then((ret: NullishType): void => { @@ -866,8 +866,8 @@ function stat(file: string | number, callback: AsyncCallback): void e.code = 0; let r = ret as Stat; callback(e, r); - }).catch((e: Error): void => { - callback(e as BusinessError, new StatInner(0)); + }).catch((e: BusinessError): void => { + callback(e, new StatInner(0)); }); } @@ -882,8 +882,8 @@ function fsync(fd: number): Promise { }, fd); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -896,8 +896,8 @@ function fsync(fd: number, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -913,8 +913,8 @@ function symlink(target: string, srcPath: string): Promise { }, target, srcPath); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -929,8 +929,8 @@ function rename(oldPath: string, newPath: string): Promise { }, oldPath, newPath); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -943,8 +943,8 @@ function rename(oldPath: string, newPath: string, callback: AsyncCallback) let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -964,8 +964,8 @@ function createRandomAccessFile(file: string | File, mode?: number, promise.then((ret: NullishType): void => { let raffile = ret as RandomAccessFileInner; resolve(raffile); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -978,8 +978,8 @@ function fdopenStream(fd: number, mode: string): Promise { promise.then((ret: NullishType): void => { let stream = ret as Stream; resolve(stream); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -994,7 +994,7 @@ function setxattr(path: string, key: string, value: string): Promise { FileIoImpl.setxattrSync(path, key, value), path, key, value); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { + }).catch((e: BusinessError): void => { reject(e as BusinessError); }); }); @@ -1009,9 +1009,9 @@ function createRandomAccessFile(file: string | File, callback: AsyncCallback { + }).catch((e: BusinessError): void => { let f: RandomAccessFile = new RandomAccessFileInner(0); - callback(e as BusinessError, f); + callback(e, f); }); } @@ -1025,9 +1025,9 @@ function createRandomAccessFile(file: string | File, mode: number, e.code = 0; let raffile = ret as RandomAccessFile; callback(e, raffile); - }).catch((e: Error): void => { + }).catch((e: BusinessError): void => { let f: RandomAccessFile = new RandomAccessFileInner(0); - callback(e as BusinessError, f); + callback(e, f); }); } @@ -1040,9 +1040,9 @@ function fdopenStream(fd: number, mode: string, callback: AsyncCallback) e.code = 0; let stream = ret as Stream; callback(e, stream); - }).catch((e: Error): void => { + }).catch((e: BusinessError): void => { let r: Stream = new StreamInner(0); - callback(e as BusinessError, r); + callback(e, r); }); } @@ -1058,8 +1058,8 @@ function createStream(path: string, mode: string): Promise { promise.then((ret: NullishType): void => { let stream = ret as Stream; resolve(stream); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -1073,9 +1073,9 @@ function createStream(path: string, mode: string, callback: AsyncCallback { + }).catch((e: BusinessError): void => { let r: Stream = new StreamInner(0); - callback(e as BusinessError, r); + callback(e, r); }); } @@ -1083,13 +1083,13 @@ function createStreamSync(path: string, mode: string): Stream { return FileIoImpl.createStreamSync(path, mode); } -function createReadStream(path: string, options?: ReadStreamOptions): ReadStream { - return new ReadStream(path, options) -} +// function createReadStream(path: string, options?: ReadStreamOptions): ReadStream { +// return new ReadStream(path, options) +// } -function createWriteStream(path: string, options?: WriteStreamOptions): WriteStream { - return new WriteStream(path, options); -} +// function createWriteStream(path: string, options?: WriteStreamOptions): WriteStream { +// return new WriteStream(path, options); +// } function createWatcher(path: string, events: number, listener: WatchEventListener): Watcher { return FileIoImpl.createWatcherSync(path, events, listener); @@ -1103,8 +1103,8 @@ function symlink(target: string, srcPath: string, callback: AsyncCallback) let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -1130,8 +1130,8 @@ function lstat(path: string): Promise { let r = ret as Stat; resolve(r); } - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -1151,8 +1151,8 @@ function lstat(path: string, callback: AsyncCallback): void { let r = ret as Stat; callback(e, r); } - }).catch((e: Error): void => { - callback(e as BusinessError, new StatInner(0)); + }).catch((e: BusinessError): void => { + callback(e, new StatInner(0)); }); } function copyFile(src: string | number, dest: string | number, mode?: number): Promise { @@ -1161,8 +1161,8 @@ function copyFile(src: string | number, dest: string | number, mode?: number): P FileIoImpl.copyFileSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -1173,8 +1173,8 @@ function copy(srcUri: string, destUri: string, options?: CopyOptions): Promise { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -1186,8 +1186,8 @@ function copyFile(src: string | number, dest: string | number, mode: number, cal let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -1198,8 +1198,8 @@ function copy(srcUri: string, destUri: string, options: CopyOptions, callback: A let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -1210,8 +1210,8 @@ function copyFile(src: string | number, dest: string | number, callback: AsyncCa let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -1222,12 +1222,12 @@ function copy(srcUri: string, destUri: string, callback: AsyncCallback): v let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } -function lseek(fd: number, offset: number, whence?: WhenceType): number { +function lseek(fd: int, offset: long, whence?: WhenceType): long { return FileIoImpl.lseekSync(fd, offset, whence); } @@ -1263,31 +1263,20 @@ export type ProgressListener = (progress: Progress) => void; export class TaskSignal { private nativeTaskSignal: long = 0; - private native onCancelNative(): void; - private onCancelResolve: (path: string) => void = (path: string): void => {}; private onCancelCallback(path: string): void { if (this.onCancelResolve) { this.onCancelResolve(path); } } - native cancel(): void; - onCancel(): Promise { - return new Promise((resolve: (result: string) => void, reject: (e: BusinessError) => void): void => { + return new Promise((resolve: (path: string) => void, reject: (e: BusinessError) => void): void => { this.onCancelResolve = resolve; - try { - this.onCancelNative(); - } catch (e: BusinessError) { - reject(e); - } catch (e: Error) { - reject(e as BusinessError); - } + this.onCancelNative(); }); } - } export interface CopyOptions { @@ -1320,8 +1309,8 @@ export interface RandomAccessFile { read(buffer: ArrayBuffer, callback: AsyncCallback): void; read(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void; readSync(buffer: ArrayBuffer, options?: ReadOptions): number; - getReadStream(): ReadStream; - getWriteStream(): WriteStream; + // getReadStream(): ReadStream; + // getWriteStream(): WriteStream; } export class RandomAccessFileInner implements RandomAccessFile { @@ -1342,7 +1331,7 @@ export class RandomAccessFileInner implements RandomAccessFile { } native setFilePointer0(filePointer: number): void; - + native close(): void; writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): number { @@ -1361,8 +1350,8 @@ export class RandomAccessFileInner implements RandomAccessFile { promise.then((ret: NullishType): void => { let result = ret as number resolve(result); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -1376,8 +1365,8 @@ export class RandomAccessFileInner implements RandomAccessFile { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } @@ -1390,8 +1379,8 @@ export class RandomAccessFileInner implements RandomAccessFile { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } @@ -1401,7 +1390,7 @@ export class RandomAccessFileInner implements RandomAccessFile { return length; } - native readSync0(buffer: ArrayBuffer, options?: ReadOptions): number; + native readSync0(buffer: ArrayBuffer, options?: ReadOptions): long; read(buffer: ArrayBuffer, options?: ReadOptions): Promise { return new Promise((resolve: (result: number) => void, reject: (e: BusinessError) => void) => { @@ -1411,8 +1400,8 @@ export class RandomAccessFileInner implements RandomAccessFile { promise.then((ret: NullishType): void => { let result = ret as number; resolve(result); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -1426,8 +1415,8 @@ export class RandomAccessFileInner implements RandomAccessFile { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } @@ -1440,13 +1429,13 @@ export class RandomAccessFileInner implements RandomAccessFile { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } - native getReadStream(): ReadStream; - native getWriteStream(): WriteStream; + // native getReadStream(): ReadStream; + // native getWriteStream(): WriteStream; } export interface File { @@ -1485,8 +1474,8 @@ export class FileInner implements File { }, exclusive); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -1499,8 +1488,8 @@ export class FileInner implements File { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -1512,8 +1501,8 @@ export class FileInner implements File { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -1559,13 +1548,13 @@ export class ReaderIteratorInner implements ReaderIterator { export interface Stat { ino: bigint; - mode: number; - uid: number; - gid: number; - size: number; - atime: number; - mtime: number; - ctime: number; + mode: int; + uid: int; + gid: int; + size: long; + atime: long; + mtime: long; + ctime: long; atimeNs: bigint; mtimeNs: bigint; ctimeNs: bigint; @@ -1601,7 +1590,7 @@ export class StatInner implements Stat { this.nativeStat = stat; } } - + native isBlockDevice(): boolean; native isCharacterDevice(): boolean; native isDirectory(): boolean; @@ -1643,8 +1632,8 @@ export class StreamInner implements Stream { let promise = taskpool.execute((): undefined => this.closeSync()); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -1655,8 +1644,8 @@ export class StreamInner implements Stream { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -1667,8 +1656,8 @@ export class StreamInner implements Stream { let promise = taskpool.execute((): undefined => this.flushSync()); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -1679,8 +1668,8 @@ export class StreamInner implements Stream { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: Error): void => { - callback(e as BusinessError, undefined); + }).catch((e: BusinessError): void => { + callback(e, undefined); }); } @@ -1694,8 +1683,8 @@ export class StreamInner implements Stream { promise.then((ret: NullishType): void => { let result = ret as number resolve(result); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } @@ -1709,8 +1698,8 @@ export class StreamInner implements Stream { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } @@ -1723,29 +1712,29 @@ export class StreamInner implements Stream { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } native writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): number; - read(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 => { + read(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); }, buffer, options); promise.then((ret: NullishType): void => { let result = ret as number resolve(result); - }).catch((e: Error): void => { - reject(e as BusinessError); + }).catch((e: BusinessError): void => { + reject(e); }); }); } - read(buffer: ArrayBuffer, callback: AsyncCallback): void { - let promise = taskpool.execute((buffer: ArrayBuffer): number => { + read(buffer: ArrayBuffer, callback: AsyncCallback): void { + let promise = taskpool.execute((buffer: ArrayBuffer): long => { return this.readSync(buffer); }, buffer); promise.then((ret: NullishType): void => { @@ -1753,13 +1742,13 @@ export class StreamInner implements Stream { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } - read(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void { - let promise = taskpool.execute((buffer: ArrayBuffer, options: ReadOptions): number => { + read(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void { + let promise = taskpool.execute((buffer: ArrayBuffer, options: ReadOptions): long => { return this.readSync(buffer, options); }, buffer, options); promise.then((ret: NullishType): void => { @@ -1767,162 +1756,162 @@ export class StreamInner implements Stream { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: Error): void => { - callback(e as BusinessError, 0); + }).catch((e: BusinessError): void => { + callback(e, 0); }); } - - native readSync(buffer: ArrayBuffer, options?: ReadOptions): number; - native seek(offset: number, whence?: number): number; -} - -export class ReadStream extends stream.Readable { - path: string; - bytesRead: number; - private offset: number; - private start?: number; - private end?: number; - private stream?: Stream; - - constructor(path: string, options?: ReadStreamOptions) { - super(); - this.path = path; - this.bytesRead = 0; - this.start = options?.start; - this.end = options?.end; - this.stream = createStreamSync(this.path, 'r'); - this.offset = this.start ?? 0; - } - - seek(offset: number, whence?: WhenceType): number { - if (whence === undefined) { - let off = this.stream?.seek(offset); - if (off !== undefined) { - this.offset = off - } - } else { - let off = this.stream?.seek(offset, whence); - if (off !== undefined) { - this.offset = off - } - } - return this.offset; - } - - close(): void { - this.stream?.close(); - } - - doInitialize(callback: () => void): void { - callback(); - } - - doRead(size: number): void { - let readSize = size; - let end = this.end - if (end !== undefined) { - if (this.offset > end) { - this.push(null); - return; - } - if (this.offset + readSize > end) { - readSize = end - this.offset; - } - } - let buffer = new ArrayBuffer(readSize); - const off = this.offset; - this.offset += readSize; - this.stream?.read(buffer, { offset: off, length: readSize }) - .then((readOut: number) => { - if (readOut > 0) { - this.bytesRead += readOut; - this.push(new Uint8Array(buffer.slice(0, readOut))); - } - if (readOut !== readSize || readOut < size) { - this.offset = this.offset - readSize + readOut; - this.push(null); - } - }); - } -} - -export class WriteStream extends stream.Writable { - path: string; - bytesWritten: number; - private offset: number; - private mode: string; - private start?: number; - private stream?: Stream; - - constructor(path: string, options?: WriteStreamOptions) { - super(); - this.path = path; - this.bytesWritten = 0; - this.start = options?.start; - this.mode = this.convertOpenMode(options?.mode); - this.stream = createStreamSync(this.path, this.mode); - this.offset = this.start ?? 0; - } - - seek(offset: number, whence?: WhenceType): number { - if (whence === undefined) { - let off = this.stream?.seek(offset); - if (off !== undefined) { - this.offset = off - } - } else { - let off = this.stream?.seek(offset, whence); - if (off !== undefined) { - this.offset = off - } - } - return this.offset; - } - - close(): void { - this.stream?.close(); - } - - closeSync(): void { - this.stream?.closeSync(); - } - - doInitialize(callback: () => void): void { - callback(); - } - - doWrite(chunk: string | ArrayBuffer, encoding: string, callback: () => void): void { - this.stream?.write(chunk, { offset: this.offset }) - .then((writeIn: number) => { - this.offset += writeIn; - this.bytesWritten += writeIn; - callback(); - }) - .finally(() => { - this.stream?.flush(); - }); - } - - convertOpenMode(mode?: number): string { - let modeStr = 'w'; - if (mode === undefined) { - return modeStr; - } - if ((mode as number) & fileIo.OpenMode.WRITE_ONLY) { - modeStr = 'w'; - } - if ((mode as number) & fileIo.OpenMode.READ_WRITE) { - modeStr = 'w+'; - } - if (((mode as number) & fileIo.OpenMode.WRITE_ONLY) && ((mode as number) & fileIo.OpenMode.APPEND)) { - modeStr = 'a'; - } - if (((mode as number) & fileIo.OpenMode.READ_WRITE) && ((mode as number) & fileIo.OpenMode.APPEND)) { - modeStr = 'a+'; - } - return modeStr; - } -} + + native readSync(buffer: ArrayBuffer, options?: ReadOptions): long; + native seek(offset: long, whence?: int): long; +} + +// export class ReadStream extends stream.Readable { +// path: string; +// bytesRead: number; +// private offset: number; +// private start?: number; +// private end?: number; +// private stream?: Stream; + +// constructor(path: string, options?: ReadStreamOptions) { +// super(); +// this.path = path; +// this.bytesRead = 0; +// this.start = options?.start; +// this.end = options?.end; +// this.stream = createStreamSync(this.path, 'r'); +// this.offset = this.start ?? 0; +// } + +// seek(offset: number, whence?: WhenceType): number { +// if (whence === undefined) { +// let off = this.stream?.seek(offset); +// if (off !== undefined) { +// this.offset = off +// } +// } else { +// let off = this.stream?.seek(offset, whence); +// if (off !== undefined) { +// this.offset = off +// } +// } +// return this.offset; +// } + +// close(): void { +// this.stream?.close(); +// } + +// doInitialize(callback: () => void): void { +// callback(); +// } + +// doRead(size: number): void { +// let readSize = size; +// let end = this.end +// if (end !== undefined) { +// if (this.offset > end) { +// this.push(null); +// return; +// } +// if (this.offset + readSize > end) { +// readSize = end - this.offset; +// } +// } +// let buffer = new ArrayBuffer(readSize); +// const off = this.offset; +// this.offset += readSize; +// this.stream?.read(buffer, { offset: off, length: readSize }) +// .then((readOut: number) => { +// if (readOut > 0) { +// this.bytesRead += readOut; +// this.push(new Uint8Array(buffer.slice(0, readOut))); +// } +// if (readOut !== readSize || readOut < size) { +// this.offset = this.offset - readSize + readOut; +// this.push(null); +// } +// }); +// } +// } + +// export class WriteStream extends stream.Writable { +// path: string; +// bytesWritten: number; +// private offset: number; +// private mode: string; +// private start?: number; +// private stream?: Stream; + +// constructor(path: string, options?: WriteStreamOptions) { +// super(); +// this.path = path; +// this.bytesWritten = 0; +// this.start = options?.start; +// this.mode = this.convertOpenMode(options?.mode); +// this.stream = createStreamSync(this.path, this.mode); +// this.offset = this.start ?? 0; +// } + +// seek(offset: number, whence?: WhenceType): number { +// if (whence === undefined) { +// let off = this.stream?.seek(offset); +// if (off !== undefined) { +// this.offset = off +// } +// } else { +// let off = this.stream?.seek(offset, whence); +// if (off !== undefined) { +// this.offset = off +// } +// } +// return this.offset; +// } + +// close(): void { +// this.stream?.close(); +// } + +// closeSync(): void { +// this.stream?.closeSync(); +// } + +// doInitialize(callback: () => void): void { +// callback(); +// } + +// doWrite(chunk: string | ArrayBuffer, encoding: string, callback: () => void): void { +// this.stream?.write(chunk, { offset: this.offset }) +// .then((writeIn: number) => { +// this.offset += writeIn; +// this.bytesWritten += writeIn; +// callback(); +// }) +// .finally(() => { +// this.stream?.flush(); +// }); +// } + +// convertOpenMode(mode?: number): string { +// let modeStr = 'w'; +// if (mode === undefined) { +// return modeStr; +// } +// if ((mode as number) & fileIo.OpenMode.WRITE_ONLY) { +// modeStr = 'w'; +// } +// if ((mode as number) & fileIo.OpenMode.READ_WRITE) { +// modeStr = 'w+'; +// } +// if (((mode as number) & fileIo.OpenMode.WRITE_ONLY) && ((mode as number) & fileIo.OpenMode.APPEND)) { +// modeStr = 'a'; +// } +// if (((mode as number) & fileIo.OpenMode.READ_WRITE) && ((mode as number) & fileIo.OpenMode.APPEND)) { +// modeStr = 'a+'; +// } +// return modeStr; +// } +// } export class AtomicFile { static { @@ -1931,42 +1920,42 @@ export class AtomicFile { private nativePtr: long = 0; private native getPath(): string; - private writeStream: WriteStream | null = null; + // private writeStream: WriteStream | null = null; native constructor(path: string); native getBaseFile(): File; - native openRead(): ReadStream; + // native openRead(): ReadStream; native readFully(): ArrayBuffer; - native nativeStartWrite(): WriteStream; - startWrite(): WriteStream { - let ws = this.nativeStartWrite(); - this.writeStream = ws; - return ws; - } - - native nativeFinishWrite(): void; - finishWrite(): void { - if (!this.writeStream) { - throw createBusinessError(UNKNOWN_ERR, UNKNOWN_MSG); - } - this.writeStream?.close(); - this.nativeFinishWrite(); - this.writeStream = null; - }; - - native nativeFailWrite(): void; - failWrite(): void { - if (!this.writeStream) { - throw createBusinessError(UNKNOWN_ERR, UNKNOWN_MSG); - } - this.writeStream?.close(); - this.nativeFailWrite(); - this.writeStream = null; - }; + // native nativeStartWrite(): WriteStream; + // startWrite(): WriteStream { + // let ws = this.nativeStartWrite(); + // this.writeStream = ws; + // return ws; + // } + + // native nativeFinishWrite(): void; + // finishWrite(): void { + // if (!this.writeStream) { + // throw createBusinessError(UNKNOWN_ERR, UNKNOWN_MSG); + // } + // this.writeStream?.close(); + // this.nativeFinishWrite(); + // this.writeStream = null; + // }; + + // native nativeFailWrite(): void; + // failWrite(): void { + // if (!this.writeStream) { + // throw createBusinessError(UNKNOWN_ERR, UNKNOWN_MSG); + // } + // this.writeStream?.close(); + // this.nativeFailWrite(); + // this.writeStream = null; + // }; native delete(): void; } @@ -2130,16 +2119,16 @@ export class FileIoImpl { static native createStreamSync(path: string, mode: string): fileIo.Stream; static native createWatcherSync(path: string, events: number, listener: WatchEventListener): fileIo.Watcher; - + static native fdopenStreamSync(fd: number, mode: string): fileIo.Stream; - - static native dup(fd: number): fileIo.File; + + static native dup(fd: int): fileIo.File; static native listFileSync(path: string, options?: ListFileOptions): string[]; static native lstatSync(path: string): fileIo.Stat; - - static native lseekSync(fd: number, offset: number, whence?: fileIo.WhenceType): number; + + static native lseekSync(fd: int, offset: long, whence?: fileIo.WhenceType): long; static native mkdirSync(path: string): void; @@ -2154,8 +2143,8 @@ export class FileIoImpl { static native openSync(path: String, mode?: number): fileIo.File; static native readlinesSync(filePath: string, options?: Options): fileIo.ReaderIterator; - - static native readSync(fd: number, buffer: ArrayBuffer, options?: ReadOptions): number; + + static native readSync(fd: int, buffer: ArrayBuffer, options?: ReadOptions): long; static native readTextSync(filePath: string, options?: ReadTextOptions): string; @@ -2163,7 +2152,7 @@ export class FileIoImpl { static native setxattrSync(path: string, key: string, value: string): void; - static native statSync(file: string | number): fileIo.Stat; + static native statSync(file: string | int): fileIo.Stat; static native truncateSync(file: string | number, len?: number): void; diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/dup_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/dup_ani.cpp index 22c002243e45cb58b9dac253eec37acbc6d7feca..a4c5f0482ed5b9de0c71bdacda61ec38cb477685 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/dup_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/dup_ani.cpp @@ -28,7 +28,7 @@ namespace ModuleFileIO { namespace ANI { using namespace OHOS::FileManagement::ModuleFileIO; -ani_object DupAni::Dup(ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd) +ani_object DupAni::Dup(ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd) { FsResult ret = DupCore::DoDup(static_cast(fd)); if (!ret.IsSuccess()) { diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/dup_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/dup_ani.h index c0e4a02c7083134a8e1e92289189c457006b80e7..9df7bde3a3a4bffbb6ff0fd72db5e2420c748ea1 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/dup_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/dup_ani.h @@ -25,7 +25,7 @@ namespace ANI { class DupAni final { public: - static ani_object Dup(ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd); + static ani_object Dup(ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd); }; } // namespace ANI } // namespace ModuleFileIO diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/lseek_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/lseek_ani.cpp index 1d689c696ff61f52234c577d46c741d24b5753c0..6618721000cdfb0b372894f878dd63fa79d18760 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/lseek_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/lseek_ani.cpp @@ -35,8 +35,8 @@ optional ParseSeekPos(const optional &whence) return make_optional(static_cast(move(whence.value()))); } -ani_double LseekAni::LseekSync( - ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd, ani_double offset, ani_enum_item whence) +ani_long LseekAni::LseekSync( + ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd, ani_long offset, ani_enum_item whence) { auto [succWhence, whenceOp] = TypeConverter::EnumToInt32(env, whence); if (!succWhence) { @@ -54,7 +54,7 @@ ani_double LseekAni::LseekSync( return -1; } - return ani_double(static_cast(ret.GetData().value())); + return ani_long(static_cast(ret.GetData().value())); } } // namespace ANI diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/lseek_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/lseek_ani.h index 5a7995d799ec2ab6d000304f4b4a1d9589a58177..5c1084fa7571a58c75d0e380a8ecf2bdffb73bda 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/lseek_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/lseek_ani.h @@ -24,8 +24,8 @@ namespace ModuleFileIO { namespace ANI { class LseekAni final { public: - static ani_double LseekSync( - ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd, ani_double offset, ani_enum_item whence); + static ani_long LseekSync( + ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd, ani_long offset, ani_enum_item whence); }; } // namespace ANI } // namespace ModuleFileIO diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/read_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/read_ani.h index 2f18a20f3f3792b40d0618e0f72c6657ceda2755..7292576b414500ab4871fb9dd7a7ec205136b532 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/read_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/read_ani.h @@ -22,8 +22,8 @@ namespace OHOS::FileManagement::ModuleFileIO::ANI { class ReadAni final { public: - static ani_double ReadSync( - ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd, ani_arraybuffer buffer, ani_object options); + static ani_long ReadSync( + ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd, ani_arraybuffer buffer, ani_object options); }; } // namespace OHOS::FileManagement::ModuleFileIO::ANI