From ec84d34017893243dcc77933bbe6db16adeafe1b Mon Sep 17 00:00:00 2001 From: tianp Date: Fri, 18 Jul 2025 14:27:05 +0800 Subject: [PATCH] number to int Signed-off-by: tianp Change-Id: I4cf4a7efc00e15bac3b4414fd6b8b43224555737 --- .../js/src/mod_fs/ani/ets/@ohos.file.fs.ets | 164 +++++++++--------- .../ani/randomaccessfile_ani.cpp | 12 +- .../ani/randomaccessfile_ani.h | 6 +- .../src/mod_fs/properties/ani/fsync_ani.cpp | 2 +- .../js/src/mod_fs/properties/ani/fsync_ani.h | 2 +- .../src/mod_fs/properties/ani/write_ani.cpp | 8 +- .../js/src/mod_fs/properties/ani/write_ani.h | 4 +- .../ani/ets/@ohos.file.statvfs.ets | 28 +-- .../js/src/mod_statvfs/ani/statvfs_ani.cpp | 8 +- .../kits/js/src/mod_statvfs/ani/statvfs_ani.h | 4 +- 10 files changed, 119 insertions(+), 119 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..4136f3354 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 @@ -413,13 +413,13 @@ function mkdtemp(prefix: string, callback: AsyncCallback): void { }); } -function moveFileSync(src: string, dest: string, mode?: number): void { +function moveFileSync(src: string, dest: string, mode?: int): void { return FileIoImpl.moveFileSync(src, dest, mode); } -function moveFile(src: string, dest: string, mode?: number): Promise { +function moveFile(src: string, dest: string, mode?: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((src: string, dest: string, mode?: number): undefined => { + let promise = taskpool.execute((src: string, dest: string, mode?: int): undefined => { return FileIoImpl.moveFileSync(src, dest, mode); }, src, dest, mode); promise.then((ret: NullishType): void => { @@ -430,8 +430,8 @@ function moveFile(src: string, dest: string, mode?: number): Promise { }); } -function moveFile(src: string, dest: string, mode: number, callback: AsyncCallback): void { - let promise = taskpool.execute((src: string, dest: string, mode: number): undefined => { +function moveFile(src: string, dest: string, mode: int, callback: AsyncCallback): void { + let promise = taskpool.execute((src: string, dest: string, mode: int): undefined => { return FileIoImpl.moveFileSync(src, dest, mode); }, src, dest, mode); promise.then((ret: NullishType): void => { @@ -456,13 +456,13 @@ function moveFile(src: string, dest: string, callback: AsyncCallback): voi }); } -function openSync(path: string, mode?: number): File { +function openSync(path: string, mode?: int): File { return FileIoImpl.openSync(path, mode); } -function open(path: String, mode?: number): Promise { +function open(path: String, mode?: int): Promise { return new Promise((resolve: (result: File) => void, reject: (e: BusinessError) => void) => { - let promise = taskpool.execute((path: String, mode?: number): File => { + let promise = taskpool.execute((path: String, mode?: int): File => { return FileIoImpl.openSync(path, mode); },path, mode); promise.then((ret: NullishType): void => { @@ -474,8 +474,8 @@ function open(path: String, mode?: number): Promise { }); } -function open(path: String, mode: number, callback: AsyncCallback): void { - let promise = taskpool.execute((path: String, mode: number): File => { +function open(path: String, mode: int, callback: AsyncCallback): void { + let promise = taskpool.execute((path: String, mode: int): File => { return FileIoImpl.openSync(path, mode); }, path, mode); promise.then((ret: NullishType): void => { @@ -504,17 +504,17 @@ function open(path: String, callback: AsyncCallback): void { }); } -function writeSync(fd: number, buffer: string | ArrayBuffer, options?: WriteOptions): number { +function writeSync(fd: int, buffer: string | ArrayBuffer, options?: WriteOptions): long { return FileIoImpl.writeSync(fd, buffer, options); } -function write(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 => { +function write(fd: int, buffer: string | ArrayBuffer, options?: WriteOptions): Promise { + return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void) => { + let promise = taskpool.execute((fd: int, buffer: string | ArrayBuffer, options?: WriteOptions): long => { return FileIoImpl.writeSync(fd, buffer, options); }, fd, 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); @@ -522,29 +522,29 @@ function write(fd: number, buffer: string | ArrayBuffer, options?: WriteOptions) }); } -function write(fd: number, buffer: string | ArrayBuffer, options: WriteOptions, - callback: AsyncCallback): void { - let promise = taskpool.execute((fd: number, buffer: string | ArrayBuffer, options: WriteOptions): number => { +function write(fd: int, buffer: string | ArrayBuffer, options: WriteOptions, + callback: AsyncCallback): void { + let promise = taskpool.execute((fd: int, buffer: string | ArrayBuffer, options: WriteOptions): long => { return FileIoImpl.writeSync(fd, buffer, options); }, 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); }); } -function write(fd: number, buffer: string | ArrayBuffer, callback: AsyncCallback): void { - let promise = taskpool.execute((fd: number, buffer: string | ArrayBuffer): number => { +function write(fd: int, buffer: string | ArrayBuffer, callback: AsyncCallback): void { + let promise = taskpool.execute((fd: int, buffer: string | ArrayBuffer): long => { return FileIoImpl.writeSync(fd, buffer); }, fd, buffer); 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); @@ -871,13 +871,13 @@ function stat(file: string | number, callback: AsyncCallback): void }); } -function fsyncSync(fd: number): void { +function fsyncSync(fd: int): void { return FileIoImpl.fsyncSync(fd); } -function fsync(fd: number): Promise { +function fsync(fd: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((fd: number): undefined => { + let promise = taskpool.execute((fd: int): undefined => { return FileIoImpl.fsyncSync(fd); }, fd); promise.then((ret: NullishType): void => { @@ -888,8 +888,8 @@ function fsync(fd: number): Promise { }); } -function fsync(fd: number, callback: AsyncCallback): void { - let promise = taskpool.execute((fd: number): undefined => { +function fsync(fd: int, callback: AsyncCallback): void { + let promise = taskpool.execute((fd: int): undefined => { return FileIoImpl.fsyncSync(fd); }, fd); promise.then((ret: NullishType): void => { @@ -948,16 +948,16 @@ function rename(oldPath: string, newPath: string, callback: AsyncCallback) }); } -function createRandomAccessFileSync(file: string | File, mode?: number, +function createRandomAccessFileSync(file: string | File, mode?: int, options?: RandomAccessFileOptions): RandomAccessFile { return FileIoImpl.createRandomAccessFileSync(file, mode, options); } -function createRandomAccessFile(file: string | File, mode?: number, +function createRandomAccessFile(file: string | File, mode?: int, options?: RandomAccessFileOptions): Promise { return new Promise((resolve: (result: RandomAccessFile) => void, reject: (e: BusinessError) => void) => { - let promise = taskpool.execute((file: string | File, mode?: number, + let promise = taskpool.execute((file: string | File, mode?: int, options?: RandomAccessFileOptions): RandomAccessFile => { return FileIoImpl.createRandomAccessFileSync(file, mode, options); }, file, mode, options); @@ -1015,9 +1015,9 @@ function createRandomAccessFile(file: string | File, callback: AsyncCallback): void { - let promise = taskpool.execute((file: string | File, mode: number): RandomAccessFile => { + let promise = taskpool.execute((file: string | File, mode: int): RandomAccessFile => { return FileIoImpl.createRandomAccessFileSync(file, mode); }, file, mode); promise.then((ret: NullishType): void => { @@ -1307,26 +1307,26 @@ export enum AccessFlagType { } export interface RandomAccessFile { - fd: number; - filePointer: number; + fd: int; + filePointer: long; - setFilePointer(filePointer: number): void; + setFilePointer(filePointer: long): void; close(): void; - write(buffer: ArrayBuffer | string, options?: WriteOptions): Promise; - write(buffer: ArrayBuffer | string, callback: AsyncCallback): void; - write(buffer: ArrayBuffer | string, options: WriteOptions, callback: AsyncCallback): void; - 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; + 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; getReadStream(): ReadStream; getWriteStream(): WriteStream; } export class RandomAccessFileInner implements RandomAccessFile { - fd: number = -1; - filePointer: number = -1; + fd: int = -1; + filePointer: long = -1; private nativePtr: long = 0; @@ -1336,30 +1336,30 @@ export class RandomAccessFileInner implements RandomAccessFile { } } - setFilePointer(filePointer: number): void { + setFilePointer(filePointer: long): void { this.setFilePointer0(filePointer); this.filePointer = filePointer; } - native setFilePointer0(filePointer: number): void; + native setFilePointer0(filePointer: long): void; native close(): void; - writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): number { + writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): long { let length = options ? this.writeSync0(buffer, options) : this.writeSync0(buffer); this.filePointer += (options?.offset?? 0) + length; return length; } - native writeSync0(buffer: ArrayBuffer | string, options?: WriteOptions): number; + native writeSync0(buffer: ArrayBuffer | string, options?: WriteOptions): long; - 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); @@ -1367,49 +1367,49 @@ export class RandomAccessFileInner implements RandomAccessFile { }); } - 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); }); } - 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); }); } - readSync(buffer: ArrayBuffer, options?: ReadOptions): number { + readSync(buffer: ArrayBuffer, options?: ReadOptions): long { const length = options ? this.readSync0(buffer, options) : this.readSync0(buffer); this.filePointer += (options?.offset?? 0) + length; 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) => { - 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); @@ -1417,28 +1417,28 @@ export class RandomAccessFileInner implements RandomAccessFile { }); } - 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); }); } - 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); @@ -1450,7 +1450,7 @@ export class RandomAccessFileInner implements RandomAccessFile { } export interface File { - fd: number; + fd: int; path: String; name: String; @@ -1463,7 +1463,7 @@ export interface File { } export class FileInner implements File { - fd: number = -1; + fd: int = -1; path: String = ""; name: String = ""; @@ -2048,13 +2048,13 @@ export interface ReadTextOptions extends ReadOptions { } export interface WriteOptions extends Options { - offset?: number; - length?: number; + offset?: long; + length?: long; } export interface RandomAccessFileOptions { - start?: number; - end?: number; + start?: long; + end?: long; } export interface ListFileOptions { @@ -2149,9 +2149,9 @@ export class FileIoImpl { static native mkdtempSync(prefix: string): string; - static native moveFileSync(src: String, dest: String, mode?: number): void; + static native moveFileSync(src: String, dest: String, mode?: int): void; - static native openSync(path: String, mode?: number): fileIo.File; + static native openSync(path: String, mode?: int): fileIo.File; static native readlinesSync(filePath: string, options?: Options): fileIo.ReaderIterator; @@ -2169,13 +2169,13 @@ export class FileIoImpl { static native unlinkSync(path: string): void; - static native writeSync(fd: number, buffer: string | ArrayBuffer, options?: WriteOptions): number; + static native writeSync(fd: int, buffer: string | ArrayBuffer, options?: WriteOptions): long; - static native fsyncSync(fd: number): void; + static native fsyncSync(fd: int): void; static native renameSync(oldPath: string, newPath: string): void; - static native createRandomAccessFileSync(file: string | fileIo.File, mode?: number, + static native createRandomAccessFileSync(file: string | fileIo.File, mode?: int, options?: RandomAccessFileOptions): fileIo.RandomAccessFile; static native symlinkSync(target: string, srcPath: string): void; diff --git a/interfaces/kits/js/src/mod_fs/class_randomaccessfile/ani/randomaccessfile_ani.cpp b/interfaces/kits/js/src/mod_fs/class_randomaccessfile/ani/randomaccessfile_ani.cpp index 604835791..f3172480b 100644 --- a/interfaces/kits/js/src/mod_fs/class_randomaccessfile/ani/randomaccessfile_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/class_randomaccessfile/ani/randomaccessfile_ani.cpp @@ -134,7 +134,7 @@ static tuple ParseArrayBuffer(ani_env *env, const ani_obj return { true, move(result) }; } -void RandomAccessFileAni::SetFilePointer(ani_env *env, [[maybe_unused]] ani_object object, ani_double fp) +void RandomAccessFileAni::SetFilePointer(ani_env *env, [[maybe_unused]] ani_object object, ani_long fp) { auto rafFile = Unwrap(env, object); if (rafFile == nullptr) { @@ -168,7 +168,7 @@ void RandomAccessFileAni::Close(ani_env *env, [[maybe_unused]] ani_object object } } -ani_double RandomAccessFileAni::WriteSync( +ani_long RandomAccessFileAni::WriteSync( ani_env *env, [[maybe_unused]] ani_object object, ani_object buf, ani_object options) { auto rafFile = Unwrap(env, object); @@ -199,7 +199,7 @@ ani_double RandomAccessFileAni::WriteSync( ErrorHandler::Throw(env, ret.GetError()); return -1; } - return static_cast(ret.GetData().value()); + return static_cast(ret.GetData().value()); } auto [isArrayBuffer, arrayBuffer] = ParseArrayBuffer(env, buf); @@ -216,14 +216,14 @@ ani_double RandomAccessFileAni::WriteSync( ErrorHandler::Throw(env, ret.GetError()); return -1; } - return static_cast(ret.GetData().value()); + return static_cast(ret.GetData().value()); } HILOGE("Unsupported buffer type!"); ErrorHandler::Throw(env, EINVAL); return -1; } -ani_double RandomAccessFileAni::ReadSync( +ani_long RandomAccessFileAni::ReadSync( ani_env *env, [[maybe_unused]] ani_object object, ani_arraybuffer buf, ani_object options) { auto rafFile = Unwrap(env, object); @@ -254,7 +254,7 @@ ani_double RandomAccessFileAni::ReadSync( ErrorHandler::Throw(env, err); return -1; } - return static_cast(ret.GetData().value()); + return static_cast(ret.GetData().value()); } static ani_string GetFilePath(ani_env *env, const int fd) diff --git a/interfaces/kits/js/src/mod_fs/class_randomaccessfile/ani/randomaccessfile_ani.h b/interfaces/kits/js/src/mod_fs/class_randomaccessfile/ani/randomaccessfile_ani.h index d1a29d8ec..f47ee7098 100644 --- a/interfaces/kits/js/src/mod_fs/class_randomaccessfile/ani/randomaccessfile_ani.h +++ b/interfaces/kits/js/src/mod_fs/class_randomaccessfile/ani/randomaccessfile_ani.h @@ -25,10 +25,10 @@ namespace ANI { class RandomAccessFileAni final { public: - static void SetFilePointer(ani_env *env, [[maybe_unused]] ani_object object, ani_double fp); + static void SetFilePointer(ani_env *env, [[maybe_unused]] ani_object object, ani_long fp); static void Close(ani_env *env, [[maybe_unused]] ani_object object); - static ani_double WriteSync(ani_env *env, [[maybe_unused]] ani_object object, ani_object buf, ani_object options); - static ani_double ReadSync( + static ani_long WriteSync(ani_env *env, [[maybe_unused]] ani_object object, ani_object buf, ani_object options); + static ani_long ReadSync( ani_env *env, [[maybe_unused]] ani_object object, ani_arraybuffer buf, ani_object options); static ani_object GetReadStream(ani_env *env, [[maybe_unused]] ani_object object); static ani_object GetWriteStream(ani_env *env, [[maybe_unused]] ani_object object); diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/fsync_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/fsync_ani.cpp index f2680914f..339e2fea4 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/fsync_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/fsync_ani.cpp @@ -25,7 +25,7 @@ namespace ModuleFileIO { namespace ANI { using namespace OHOS::FileManagement::ModuleFileIO; -void FsyncAni::FsyncSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd) +void FsyncAni::FsyncSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd) { auto ret = FsyncCore::DoFsync(static_cast(fd)); if (!ret.IsSuccess()) { diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/fsync_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/fsync_ani.h index ad9d936fe..33da8bf63 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/fsync_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/fsync_ani.h @@ -25,7 +25,7 @@ namespace ANI { class FsyncAni final { public: - static void FsyncSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd); + static void FsyncSync(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/write_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/write_ani.cpp index 6c718e079..99954aacf 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/write_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/write_ani.cpp @@ -94,8 +94,8 @@ static std::tuple ParseArrayBuffer(ani_env *env, const an return { true, std::move(result) }; } -ani_double WriteAni::WriteSync( - ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd, ani_object buf, ani_object options) +ani_long WriteAni::WriteSync( + ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd, ani_object buf, ani_object options) { auto [succOp, op] = ToWriteOptions(env, options); if (!succOp) { @@ -119,7 +119,7 @@ ani_double WriteAni::WriteSync( ErrorHandler::Throw(env, err); return -1; } - return static_cast(ret.GetData().value()); + return static_cast(ret.GetData().value()); } auto [isArrayBuffer, arrayBuffer] = ParseArrayBuffer(env, buf); @@ -137,7 +137,7 @@ ani_double WriteAni::WriteSync( ErrorHandler::Throw(env, err); return -1; } - return static_cast(ret.GetData().value()); + return static_cast(ret.GetData().value()); } HILOGE("Unsupported buffer type!"); ErrorHandler::Throw(env, EINVAL); diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/write_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/write_ani.h index 2ac1c8d70..3d28f711e 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/write_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/write_ani.h @@ -25,8 +25,8 @@ namespace ANI { class WriteAni final { public: - static ani_double WriteSync( - ani_env *env, [[maybe_unused]] ani_class clazz, ani_double fd, ani_object buf, ani_object options); + static ani_long WriteSync( + ani_env *env, [[maybe_unused]] ani_class clazz, ani_int fd, ani_object buf, ani_object options); }; } // namespace ANI 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..64d8e7284 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 @@ -16,15 +16,15 @@ import { BusinessError, AsyncCallback } from '@ohos.base'; namespace statfs { - export function getFreeSizeSync(path: string): number { + export function getFreeSizeSync(path: string): long { return StatvfsImpl.getFreeSizeSync(path); } - export function getFreeSize(path: string): Promise { - return new Promise((resolve: (result: number) => void, reject: (e: BusinessError) => void): void => { + export function getFreeSize(path: string): Promise { + return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute(StatvfsImpl.getFreeSizeSync, path); promise.then((ret: NullishType): void => { - let result = ret as number + let result = ret as long resolve(result); }).catch((e: Error): void => { reject(e as BusinessError); @@ -32,27 +32,27 @@ namespace statfs { }); } - export function getFreeSize(path: string, callback: AsyncCallback): void { + export function getFreeSize(path: string, callback: AsyncCallback): void { let promise = taskpool.execute(StatvfsImpl.getFreeSizeSync, path); 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); }); } - export function getTotalSizeSync(path: string): number { + export function getTotalSizeSync(path: string): long { return StatvfsImpl.getTotalSizeSync(path); } - export function getTotalSize(path: string): Promise { - return new Promise((resolve: (result: number) => void, reject: (e: BusinessError) => void): void => { + export function getTotalSize(path: string): Promise { + return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute(StatvfsImpl.getTotalSizeSync, path); promise.then((ret: NullishType): void => { - let result = ret as number + let result = ret as long resolve(result); }).catch((e: Error): void => { reject(e as BusinessError); @@ -60,12 +60,12 @@ namespace statfs { }); } - export function getTotalSize(path: string, callback: AsyncCallback): void { + export function getTotalSize(path: string, callback: AsyncCallback): void { let promise = taskpool.execute(StatvfsImpl.getTotalSizeSync, path); 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); @@ -81,6 +81,6 @@ class StatvfsImpl { loadLibrary("ani_file_statvfs"); } - static native getFreeSizeSync(path: string): number; - static native getTotalSizeSync(path: string): number; + static native getFreeSizeSync(path: string): long; + static native getTotalSizeSync(path: string): long; } diff --git a/interfaces/kits/js/src/mod_statvfs/ani/statvfs_ani.cpp b/interfaces/kits/js/src/mod_statvfs/ani/statvfs_ani.cpp index 337b78f84..0617b43db 100644 --- a/interfaces/kits/js/src/mod_statvfs/ani/statvfs_ani.cpp +++ b/interfaces/kits/js/src/mod_statvfs/ani/statvfs_ani.cpp @@ -29,7 +29,7 @@ using namespace std; using namespace OHOS::FileManagement::ModuleFileIO; using namespace OHOS::FileManagement::ModuleStatvfs; -ani_double StatvfsAni::GetFreeSizeSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path) +ani_long StatvfsAni::GetFreeSizeSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path) { auto [succPath, srcPath] = TypeConverter::ToUTF8String(env, path); if (!succPath) { @@ -46,10 +46,10 @@ ani_double StatvfsAni::GetFreeSizeSync(ani_env *env, [[maybe_unused]] ani_class return 0; } - return static_cast(ret.GetData().value()); + return static_cast(ret.GetData().value()); } -ani_double StatvfsAni::GetTotalSizeSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path) +ani_long StatvfsAni::GetTotalSizeSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path) { auto [succPath, srcPath] = TypeConverter::ToUTF8String(env, path); if (!succPath) { @@ -66,7 +66,7 @@ ani_double StatvfsAni::GetTotalSizeSync(ani_env *env, [[maybe_unused]] ani_class return 0; } - return static_cast(ret.GetData().value()); + return static_cast(ret.GetData().value()); } } // namespace ANI diff --git a/interfaces/kits/js/src/mod_statvfs/ani/statvfs_ani.h b/interfaces/kits/js/src/mod_statvfs/ani/statvfs_ani.h index 1eaf5081f..feb2854a6 100644 --- a/interfaces/kits/js/src/mod_statvfs/ani/statvfs_ani.h +++ b/interfaces/kits/js/src/mod_statvfs/ani/statvfs_ani.h @@ -25,8 +25,8 @@ namespace ANI { class StatvfsAni final { public: - static ani_double GetFreeSizeSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path); - static ani_double GetTotalSizeSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path); + static ani_long GetFreeSizeSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path); + static ani_long GetTotalSizeSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path); }; } // namespace ANI -- Gitee