From 8af383d00a50b50cb29832e71721b6a47350606d Mon Sep 17 00:00:00 2001 From: yangbiao59 Date: Fri, 18 Jul 2025 11:05:05 +0800 Subject: [PATCH] number Signed-off-by: yangbiao59 --- .../js/src/mod_fs/ani/ets/@ohos.file.fs.ets | 66 +++++++++---------- .../js/src/mod_fs/properties/ani/dup_ani.cpp | 4 +- .../js/src/mod_fs/properties/ani/dup_ani.h | 2 +- .../src/mod_fs/properties/ani/lseek_ani.cpp | 8 +-- .../js/src/mod_fs/properties/ani/lseek_ani.h | 4 +- .../js/src/mod_fs/properties/ani/read_ani.cpp | 8 +-- .../js/src/mod_fs/properties/ani/read_ani.h | 4 +- 7 files changed, 48 insertions(+), 48 deletions(-) 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..67cbae9f2 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 @@ -156,7 +156,7 @@ function getxattr(path: string, key: string): Promise { }); } -function dup(fd: number): File { +function dup(fd: int): File { return FileIoImpl.dup(fd); } @@ -551,17 +551,17 @@ function write(fd: number, buffer: string | ArrayBuffer, callback: AsyncCallback }); } -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; + let result = ret as long; resolve(result); }).catch((e: Error): void => { reject(e as BusinessError); @@ -569,28 +569,28 @@ function read(fd: number, buffer: ArrayBuffer, options?: ReadOptions): Promise): 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 => { 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); }); } -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 => { 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); @@ -839,13 +839,13 @@ 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 => { @@ -857,8 +857,8 @@ function stat(file: string | number): Promise { }); } -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 => { @@ -1108,7 +1108,7 @@ function symlink(target: string, srcPath: string, callback: AsyncCallback) }); } -function utimes(path: string, mtime: number): void { +function utimes(path: string, mtime: double): void { return FileIoImpl.utimes(path, mtime); } @@ -1227,7 +1227,7 @@ function copy(srcUri: string, destUri: string, callback: AsyncCallback): v }); } -function lseek(fd: number, offset: number, whence?: WhenceType): number { +function lseek(fd: int, offset: long, whence?: WhenceType): long { return FileIoImpl.lseekSync(fd, offset, whence); } @@ -1241,8 +1241,8 @@ export interface Filter { } export interface Progress { - processedSize: number; - totalSize: number; + processedSize: long; + totalSize: long; } export interface DfsListeners { @@ -1559,13 +1559,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; @@ -2133,13 +2133,13 @@ export class FileIoImpl { 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; @@ -2155,7 +2155,7 @@ export class FileIoImpl { 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 +2163,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; @@ -2180,5 +2180,5 @@ export class FileIoImpl { static native symlinkSync(target: string, srcPath: string): void; - static native utimes(path: string, mtime: number): void; + static native utimes(path: string, mtime: double): 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 22c002243..0ddd81887 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,9 +28,9 @@ 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)); + FsResult ret = DupCore::DoDup(fd); if (!ret.IsSuccess()) { HILOGE("Dup file failed"); const auto &err = ret.GetError(); 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 c0e4a02c7..9df7bde3a 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 1d689c696..cc1fde998 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) { @@ -46,7 +46,7 @@ ani_double LseekAni::LseekSync( } auto pos = ParseSeekPos(whenceOp); - auto ret = LseekCore::DoLseek(static_cast(fd), static_cast(offset), pos); + auto ret = LseekCore::DoLseek(fd, offset, pos); if (!ret.IsSuccess()) { HILOGE("DoLseek failed!"); const FsError &err = ret.GetError(); @@ -54,7 +54,7 @@ ani_double LseekAni::LseekSync( return -1; } - return ani_double(static_cast(ret.GetData().value())); + return 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 5a7995d79..5c1084fa7 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.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/read_ani.cpp index fa5ce2334..36bcd2040 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/read_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/read_ani.cpp @@ -52,8 +52,8 @@ static tuple> ToReadOptions(ani_env *env, ani_object return { true, make_optional(move(options)) }; } -ani_double ReadAni::ReadSync( - ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd, ani_arraybuffer buffer, ani_object options) +ani_long ReadAni::ReadSync( + ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd, ani_arraybuffer buffer, ani_object options) { auto [succBuf, arrayBuffer] = TypeConverter::ToArrayBuffer(env, buffer); if (!succBuf) { @@ -69,13 +69,13 @@ ani_double ReadAni::ReadSync( return -1; } - auto ret = ReadCore::DoRead(static_cast(fd), arrayBuffer, op); + auto ret = ReadCore::DoRead(fd, arrayBuffer, op); if (!ret.IsSuccess()) { HILOGE("Read file content failed!"); const auto &err = ret.GetError(); ErrorHandler::Throw(env, err); return -1; } - return static_cast(ret.GetData().value()); + return ret.GetData().value(); } } // namespace OHOS::FileManagement::ModuleFileIO::ANI \ No newline at end of file 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 2f18a20f3..7292576b4 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 -- Gitee