diff --git a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp index 7b5f4ac1c2e996450a57d649605670ae4e63715a..910aea89ca2412fa8927c7f6f358f78542e1deaa 100644 --- a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp +++ b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp @@ -86,6 +86,26 @@ std::tuple> TypeConverter::ToOptionalInt64(ani_env return { false, {} }; } +tuple> TypeConverter::ToOptionalDouble(ani_env *env, const ani_object &value) +{ + if (env == nullptr) { + return { false, {} }; + } + + ani_boolean isUndefined; + env->Reference_IsUndefined(value, &isUndefined); + if (isUndefined) { + return { true, nullopt }; + } + + ani_double doubleValue; + if (ANI_OK == env->Object_CallMethodByName_Double(value, "toDouble", nullptr, &doubleValue)) { + return { true, make_optional(doubleValue) }; + } + + return { false, {} }; +} + std::tuple TypeConverter::ToAniString(ani_env *env, std::string str) { if (env == nullptr) { diff --git a/interfaces/kits/js/src/common/ani_helper/type_converter.h b/interfaces/kits/js/src/common/ani_helper/type_converter.h index 793ad367f2ab1b8b85a7534d2bc6413c84b80ad1..1c11420df25090cfdca5ff89a27b11c1aa8f6a93 100644 --- a/interfaces/kits/js/src/common/ani_helper/type_converter.h +++ b/interfaces/kits/js/src/common/ani_helper/type_converter.h @@ -32,6 +32,7 @@ public: static std::tuple ToUTF8String(ani_env *env, const ani_string &path); static std::tuple> ToOptionalInt32(ani_env *env, const ani_object &value); static std::tuple> ToOptionalInt64(ani_env *env, const ani_object &value); + static std::tuple> ToOptionalDouble(ani_env *env, const ani_object &value); static std::tuple ToAniArrayBuffer(ani_env *env, void *buffer, size_t length); static std::tuple ToAniString(ani_env *env, std::string str); static std::tuple ToAniString(ani_env *env, std::string str, size_t size); 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..20684b7e9e8e43e11eb42382c92eb93ef6b2c432 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 @@ -89,9 +89,9 @@ function accessSync(path: string, mode: AccessModeType, flag: AccessFlagType): b return FileIoImpl.doAccessSync(path, mode, flag); } -function close(file: number | File): Promise { +function close(file: int | 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); + let promise = taskpool.execute((file: int | File): undefined => FileIoImpl.closeSync(file), file); promise.then((ret: NullishType): void => { resolve(undefined); }).catch((e: Error): void => { @@ -100,8 +100,8 @@ function close(file: number | File): Promise { }); } -function close(file: number | File, callback: AsyncCallback): void { - let promise = taskpool.execute((file: number | File): undefined => FileIoImpl.closeSync(file), file); +function close(file: int | File, callback: AsyncCallback): void { + let promise = taskpool.execute((file: int | File): undefined => FileIoImpl.closeSync(file), file); promise.then((ret: NullishType): void => { let e = new BusinessError(); e.code = 0; @@ -111,7 +111,7 @@ function close(file: number | File, callback: AsyncCallback): void { }); } -function closeSync(file: number | File): void { +function closeSync(file: int | File): void { return FileIoImpl.closeSync(file) } @@ -970,9 +970,9 @@ function createRandomAccessFile(file: string | File, mode?: number, }); } -function fdopenStream(fd: number, mode: string): Promise { +function fdopenStream(fd: int, mode: string): Promise { return new Promise((resolve: (result: Stream) => void, reject: (e: BusinessError) => void) => { - let promise = taskpool.execute((fd: number, mode: string): Stream => { + let promise = taskpool.execute((fd: int, mode: string): Stream => { return FileIoImpl.fdopenStreamSync(fd, mode); }, fd, mode); promise.then((ret: NullishType): void => { @@ -1031,8 +1031,8 @@ function createRandomAccessFile(file: string | File, mode: number, }); } -function fdopenStream(fd: number, mode: string, callback: AsyncCallback): void { - let promise = taskpool.execute((fd: number, mode: string): Stream => { +function fdopenStream(fd: int, mode: string, callback: AsyncCallback): void { + let promise = taskpool.execute((fd: int, mode: string): Stream => { return FileIoImpl.fdopenStreamSync(fd, mode); }, fd, mode); promise.then((ret: NullishType): void => { @@ -1046,7 +1046,7 @@ function fdopenStream(fd: number, mode: string, callback: AsyncCallback) }); } -function fdopenStreamSync(fd: number, mode: string): Stream { +function fdopenStreamSync(fd: int, mode: string): Stream { return FileIoImpl.fdopenStreamSync(fd, mode); } @@ -1235,8 +1235,8 @@ export interface Filter { suffix?: Array; displayName?: Array; mimeType?: Array; - fileSizeOver?: number; - lastModifiedAfter?: number; + fileSizeOver?: long; + lastModifiedAfter?: double; excludeMedia?: boolean; } @@ -1618,15 +1618,15 @@ export interface Stream { flush(): Promise; flush(callback: AsyncCallback): void; 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; - 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; - readSync(buffer: ArrayBuffer, options?: ReadOptions): number; - seek(offset: number, whence?: number): number; + write(buffer: ArrayBuffer | string, options?: WriteOptions): Promise; + write(buffer: ArrayBuffer | string, callback: AsyncCallback): void; + write(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void; + writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): long; + read(buffer: ArrayBuffer, options?: ReadOptions): Promise; + read(buffer: ArrayBuffer, callback: AsyncCallback): void; + read(buffer: ArrayBuffer, options: ReadOptions, callback: AsyncCallback): void; + readSync(buffer: ArrayBuffer, options?: ReadOptions): long; + seek(offset: long, whence?: int): long; } export class StreamInner implements Stream { @@ -1686,13 +1686,13 @@ export class StreamInner implements Stream { native flushSync(): void; - write(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 => { + write(buffer: ArrayBuffer | string, options?: WriteOptions): Promise { + return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void) => { + let promise = taskpool.execute((buffer: ArrayBuffer | string, options?: WriteOptions): long => { return this.writeSync(buffer, options); }, buffer, options); promise.then((ret: NullishType): void => { - let result = ret as number + let result = ret as long resolve(result); }).catch((e: Error): void => { reject(e as BusinessError); @@ -1700,43 +1700,43 @@ export class StreamInner implements Stream { }); } - write(buffer: ArrayBuffer | string, callback: AsyncCallback): void { - let promise = taskpool.execute((buffer: ArrayBuffer | string): number => { + write(buffer: ArrayBuffer | string, callback: AsyncCallback): void { + let promise = taskpool.execute((buffer: ArrayBuffer | string): long => { return this.writeSync(buffer); }, buffer); promise.then((ret: NullishType): void => { let e = new BusinessError(); e.code = 0; - let result = ret as number; + let result = ret as long; callback(e, result); }).catch((e: Error): void => { callback(e as BusinessError, 0); }); } - write(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void { - let promise = taskpool.execute((buffer: ArrayBuffer | string, options: WriteOptions): number => { + write(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void { + let promise = taskpool.execute((buffer: ArrayBuffer | string, options: WriteOptions): long => { return this.writeSync(buffer, options); }, buffer, options); promise.then((ret: NullishType): void => { let e = new BusinessError(); e.code = 0; - let result = ret as number; + let result = ret as long; callback(e, result); }).catch((e: Error): void => { callback(e as BusinessError, 0); }); } - native writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): number; + native writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): long; - 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 + let result = ret as long resolve(result); }).catch((e: Error): void => { reject(e as BusinessError); @@ -1744,44 +1744,44 @@ export class StreamInner implements Stream { }); } - 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 => { let e = new BusinessError(); e.code = 0; - let result = ret as number; + let result = ret as long; callback(e, result); }).catch((e: Error): void => { callback(e as BusinessError, 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 => { let e = new BusinessError(); e.code = 0; - let result = ret as number; + let result = ret as long; callback(e, result); }).catch((e: Error): void => { callback(e as BusinessError, 0); }); } - native readSync(buffer: ArrayBuffer, options?: ReadOptions): number; - native seek(offset: number, whence?: number): number; + 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; + bytesRead: long; + private offset: long; + private start?: long; + private end?: long; private stream?: Stream; constructor(path: string, options?: ReadStreamOptions) { @@ -1794,7 +1794,7 @@ export class ReadStream extends stream.Readable { this.offset = this.start ?? 0; } - seek(offset: number, whence?: WhenceType): number { + seek(offset: long, whence?: WhenceType): long { if (whence === undefined) { let off = this.stream?.seek(offset); if (off !== undefined) { @@ -1817,7 +1817,7 @@ export class ReadStream extends stream.Readable { callback(); } - doRead(size: number): void { + doRead(size: long): void { let readSize = size; let end = this.end if (end !== undefined) { @@ -1833,7 +1833,7 @@ export class ReadStream extends stream.Readable { const off = this.offset; this.offset += readSize; this.stream?.read(buffer, { offset: off, length: readSize }) - .then((readOut: number) => { + .then((readOut: long) => { if (readOut > 0) { this.bytesRead += readOut; this.push(new Uint8Array(buffer.slice(0, readOut))); @@ -1848,10 +1848,10 @@ export class ReadStream extends stream.Readable { export class WriteStream extends stream.Writable { path: string; - bytesWritten: number; - private offset: number; + bytesWritten: long; + private offset: long; private mode: string; - private start?: number; + private start?: long; private stream?: Stream; constructor(path: string, options?: WriteStreamOptions) { @@ -1864,7 +1864,7 @@ export class WriteStream extends stream.Writable { this.offset = this.start ?? 0; } - seek(offset: number, whence?: WhenceType): number { + seek(offset: long, whence?: WhenceType): long { if (whence === undefined) { let off = this.stream?.seek(offset); if (off !== undefined) { @@ -1893,7 +1893,7 @@ export class WriteStream extends stream.Writable { doWrite(chunk: string | ArrayBuffer, encoding: string, callback: () => void): void { this.stream?.write(chunk, { offset: this.offset }) - .then((writeIn: number) => { + .then((writeIn: long) => { this.offset += writeIn; this.bytesWritten += writeIn; callback(); @@ -1903,21 +1903,21 @@ export class WriteStream extends stream.Writable { }); } - convertOpenMode(mode?: number): string { + convertOpenMode(mode?: int): string { let modeStr = 'w'; if (mode === undefined) { return modeStr; } - if ((mode as number) & fileIo.OpenMode.WRITE_ONLY) { + if ((mode as int) & fileIo.OpenMode.WRITE_ONLY) { modeStr = 'w'; } - if ((mode as number) & fileIo.OpenMode.READ_WRITE) { + if ((mode as int) & fileIo.OpenMode.READ_WRITE) { modeStr = 'w+'; } - if (((mode as number) & fileIo.OpenMode.WRITE_ONLY) && ((mode as number) & fileIo.OpenMode.APPEND)) { + if (((mode as int) & fileIo.OpenMode.WRITE_ONLY) && ((mode as int) & fileIo.OpenMode.APPEND)) { modeStr = 'a'; } - if (((mode as number) & fileIo.OpenMode.READ_WRITE) && ((mode as number) & fileIo.OpenMode.APPEND)) { + if (((mode as int) & fileIo.OpenMode.READ_WRITE) && ((mode as int) & fileIo.OpenMode.APPEND)) { modeStr = 'a+'; } return modeStr; @@ -2059,7 +2059,7 @@ export interface RandomAccessFileOptions { export interface ListFileOptions { recursion?: boolean; - listNum?: number; + listNum?: int; filter?: Filter; } @@ -2075,14 +2075,14 @@ export interface ReadStreamOptions { export class ReadStreamOptionsInner implements ReadStreamOptions { constructor() {} - start?: number; - end?: number; + start?: long; + end?: long; } export class WriteStreamOptionsInner implements WriteStreamOptions { constructor() {} - mode?: number; - start?: number; + mode?: int; + start?: long; } export interface ReaderIteratorResult { @@ -2111,7 +2111,7 @@ export class FileIoImpl { static native doAccessSync(path: string, mode?: fileIo.AccessModeType, flag?: fileIo.AccessFlagType): boolean; - static native closeSync(file: number | fileIo.File): void; + static native closeSync(file: int | fileIo.File): void; static native copySync(srcUri: string, destUri: string, options?: fileIo.CopyOptions): void; @@ -2131,7 +2131,7 @@ export class FileIoImpl { static native createWatcherSync(path: string, events: number, listener: WatchEventListener): fileIo.Watcher; - static native fdopenStreamSync(fd: number, mode: string): fileIo.Stream; + static native fdopenStreamSync(fd: int, mode: string): fileIo.Stream; static native dup(fd: number): fileIo.File; diff --git a/interfaces/kits/js/src/mod_fs/class_stream/ani/stream_ani.cpp b/interfaces/kits/js/src/mod_fs/class_stream/ani/stream_ani.cpp index a1d694187cd62d43d21440ff4b8f111de4314e13..1748d67f5d346795ddfa31b2b0b858dffe206278 100644 --- a/interfaces/kits/js/src/mod_fs/class_stream/ani/stream_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/class_stream/ani/stream_ani.cpp @@ -170,7 +170,7 @@ void StreamAni::Flush(ani_env *env, [[maybe_unused]] ani_object object) } } -ani_double StreamAni::Write(ani_env *env, [[maybe_unused]] ani_object object, ani_object buf, ani_object options) +ani_long StreamAni::Write(ani_env *env, [[maybe_unused]] ani_object object, ani_object buf, ani_object options) { auto fsStream = Unwrap(env, object); if (fsStream == nullptr) { @@ -217,7 +217,7 @@ ani_double StreamAni::Write(ani_env *env, [[maybe_unused]] ani_object object, an ErrorHandler::Throw(env, err); return -1; } - return static_cast(ret.GetData().value()); + return ret.GetData().value(); } HILOGE("Unsupported buffer type!"); @@ -225,7 +225,7 @@ ani_double StreamAni::Write(ani_env *env, [[maybe_unused]] ani_object object, an return -1; } -ani_double StreamAni::Read(ani_env *env, [[maybe_unused]] ani_object object, ani_arraybuffer buffer, ani_object options) +ani_long StreamAni::Read(ani_env *env, [[maybe_unused]] ani_object object, ani_arraybuffer buffer, ani_object options) { auto fsStream = Unwrap(env, object); if (fsStream == nullptr) { @@ -255,10 +255,10 @@ ani_double StreamAni::Read(ani_env *env, [[maybe_unused]] ani_object object, ani ErrorHandler::Throw(env, err); return -1; } - return static_cast(ret.GetData().value()); + return ret.GetData().value(); } -ani_double StreamAni::Seek(ani_env *env, [[maybe_unused]] ani_object object, ani_double offset, ani_object whence) +ani_long StreamAni::Seek(ani_env *env, [[maybe_unused]] ani_object object, ani_long offset, ani_object whence) { auto fsStream = Unwrap(env, object); if (fsStream == nullptr) { @@ -281,7 +281,7 @@ ani_double StreamAni::Seek(ani_env *env, [[maybe_unused]] ani_object object, ani ErrorHandler::Throw(env, err); return -1; } - return static_cast(ret.GetData().value()); + return ret.GetData().value(); } } // namespace ANI diff --git a/interfaces/kits/js/src/mod_fs/class_stream/ani/stream_ani.h b/interfaces/kits/js/src/mod_fs/class_stream/ani/stream_ani.h index 91fdb9852a432c0dbc754b8763ab53d6c5046802..486788e1a97a7a474119a9f42cb626e1dd1fc5d2 100644 --- a/interfaces/kits/js/src/mod_fs/class_stream/ani/stream_ani.h +++ b/interfaces/kits/js/src/mod_fs/class_stream/ani/stream_ani.h @@ -27,10 +27,10 @@ class StreamAni final { public: static void Close(ani_env *env, [[maybe_unused]] ani_object object); static void Flush(ani_env *env, [[maybe_unused]] ani_object object); - static ani_double Write(ani_env *env, [[maybe_unused]] ani_object object, ani_object buf, ani_object options); - static ani_double Read( + static ani_long Write(ani_env *env, [[maybe_unused]] ani_object object, ani_object buf, ani_object options); + static ani_long Read( ani_env *env, [[maybe_unused]] ani_object object, ani_arraybuffer buffer, ani_object options); - static ani_double Seek(ani_env *env, [[maybe_unused]] ani_object object, ani_double offset, ani_object whence); + static ani_long Seek(ani_env *env, [[maybe_unused]] ani_object object, ani_long offset, ani_object whence); }; } // namespace ANI } // namespace ModuleFileIO diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp index e2f7b9464691f51d71adf67ee1be4dc9fb888a76..7306e63011aca880818fae947349cb844747dfe4 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp @@ -36,12 +36,12 @@ using namespace OHOS::FileManagement::ModuleFileIO::ANI::AniSignature; tuple ParseFdOrFile(ani_env *env, ani_object obj) { int32_t result = -1; - auto doubleClassDesc = BoxedTypes::Double::classDesc.c_str(); - ani_class doubleClass; - env->FindClass(doubleClassDesc, &doubleClass); - ani_boolean isDouble; - env->Object_InstanceOf(obj, doubleClass, &isDouble); - if (isDouble) { + auto intClassDesc = BoxedTypes::Int::classDesc.c_str(); + ani_class intClass; + env->FindClass(intClassDesc, &intClass); + ani_boolean isInt; + env->Object_InstanceOf(obj, intClass, &isInt); + if (isInt) { ani_int fd; if (ANI_OK != env->Object_CallMethodByName_Int(obj, "toInt", nullptr, &fd)) { HILOGE("Get fd value failed"); diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/fdopen_stream_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/fdopen_stream_ani.cpp index bc6e8d27415910d8118119f59264400d58283398..ad98f46e3a581fa336eac8ec604977b9b5436beb 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/fdopen_stream_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/fdopen_stream_ani.cpp @@ -30,7 +30,7 @@ using namespace std; using namespace OHOS::FileManagement::ModuleFileIO; ani_object FdopenStreamAni::FdopenStreamSync( - ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd, ani_string mode) + ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd, ani_string mode) { auto [succMode, openMode] = TypeConverter::ToUTF8String(env, mode); if (!succMode) { diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/fdopen_stream_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/fdopen_stream_ani.h index 81f0fde31b630e1e90a6243ba335cd8b5c254215..3a4a3e5398c6533df2207a4e96e8c74a02701efe 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/fdopen_stream_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/fdopen_stream_ani.h @@ -24,7 +24,7 @@ namespace ModuleFileIO { namespace ANI { class FdopenStreamAni final { public: - static ani_object FdopenStreamSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd, ani_string mode); + static ani_object FdopenStreamSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd, ani_string mode); }; } // namespace ANI } // namespace ModuleFileIO diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp index ac1ec90394420042dcf817eb1f9ce0563b8f5082..cdea592d7e930f5512be3dd1beb09c3e6b6b991d 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp @@ -51,6 +51,28 @@ tuple ParseBooleanParam(ani_env *env, ani_object obj, string tag) return { true, static_cast(boolRef_res) }; } +tuple ParseLongParam(ani_env *env, ani_object obj, string tag) +{ + int result = 0; + ani_boolean isUndefined; + ani_ref result_ref; + if (ANI_OK != env->Object_GetPropertyByName_Ref(obj, tag.c_str(), &result_ref)) { + return { false, result }; + } + env->Reference_IsUndefined(result_ref, &isUndefined); + if (isUndefined) { + return { true, result }; + } + ani_long result_ref_res; + if (ANI_OK != env->Object_CallMethodByName_Long( + static_cast(result_ref), "toLong", nullptr, &result_ref_res)) { + result = -1; + return { false, result }; + } + result = static_cast(result_ref_res); + return { true, result }; +} + tuple ParseIntParam(ani_env *env, ani_object obj, string tag) { int result = 0; @@ -133,7 +155,7 @@ tuple> ParseFilter(ani_env *env, ani_object obj) { FsFileFilter filter; - auto [succfileSizeOver, fileSizeOver] = ParseIntParam(env, obj, "fileSizeOver"); + auto [succfileSizeOver, fileSizeOver] = ParseLongParam(env, obj, "fileSizeOver"); if (!succfileSizeOver) { HILOGE("Illegal option.fileSizeOver parameter"); return { false, move(filter) };