JS API Changes of the File Management Subsystem

The table below lists the APIs changes of the file management subsystem in OpenHarmony 3.1 Release over OpenHarmony 3.0 LTS.

API Changes

Module Class Method/Attribute/Enumeration/Constant Change Type
ohos.statfs Statfs function getTotalBytes(path: string, callback: AsyncCallback): void;
function getTotalBytes(path: string): Promise;
Added
ohos.statfs Statfs function getFreeBytes(path: string, callback: AsyncCallback): void;
function getFreeBytes(path: string): Promise;
Added
ohos.fileio Watcher stop(): Promise;
stop(callback: AsyncCallback): void;
Added
ohos.fileio ReadOut buffer: ArrayBuffer; Added
ohos.fileio ReadOut offset: number; Added
ohos.fileio ReadOut bytesRead: number; Added
ohos.fileio Stream read(buffer: ArrayBuffer, options?: { position?: number; offset?: number; length?: number; }): Promise;
read(buffer: ArrayBuffer, callback: AsyncCallback): void;
read(buffer: ArrayBuffer, options: { position?: number; offset?: number; length?: number; }, callback: AsyncCallback): void;
Added
ohos.fileio Stream write(buffer: ArrayBuffer | string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): Promise;
write(buffer: ArrayBuffer | string, callback: AsyncCallback): void;
write(buffer: ArrayBuffer | string, options: { offset?: number; length?: number; position?: number; encoding?: string; }, callback: AsyncCallback): void;
Added
ohos.fileio Stream flush(): Promise;
flush(callback: AsyncCallback): void;
Added
ohos.fileio Stream close(): Promise;
close(callback: AsyncCallback): void;
Added
ohos.fileio Dir close(): Promise;
close(callback: AsyncCallback): void;
Added
ohos.fileio Dir read(): Promise;
read(callback: AsyncCallback): void;
Added
ohos.fileio fileIO function createWatcher(filename: string, events: number, callback: AsyncCallback): Watcher; Added
ohos.fileio fileIO function write(fd: number, buffer: ArrayBuffer | string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): Promise;
function write(fd: number, buffer: ArrayBuffer | string, callback: AsyncCallback): void;
function write(fd: number, buffer: ArrayBuffer | string, options: { offset?: number; length?: number; position?: number; encoding?: string; }, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function unlink(path: string): Promise;
function unlink(path: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function truncate(path: string, len?: number): Promise;
function truncate(path: string, callback: AsyncCallback): void;
function truncate(path: string, len: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function symlinkSync(target: string, srcPath: string): void; Added
ohos.fileio fileIO function symlink(target: string, srcPath: string): Promise;
function symlink(target: string, srcPath: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function stat(path: string): Promise;
function stat(path: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function rmdir(path: string): Promise;
function rmdir(path: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function rename(oldPath: string, newPath: string): Promise;
function rename(oldPath: string, newPath: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: number; position?: number; }): Promise
function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback): void;
function read(fd: number, buffer: ArrayBuffer, options: { offset?: number; length?: number; position?: number; }, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function readTextSync(filePath: string, options?: { position?: number; length?: number; encoding?: string; }): string; Added
ohos.fileio fileIO function readText(filePath: string, options?: { position?: number; length?: number; encoding?: string; }): Promise;
function readText(filePath: string, options: { position?: number; length?: number; encoding?: string; }, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function opendir(path: string): Promise;
function opendir(path: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function open(path: string, flags?: number, mode?: number): Promise;
function open(path: string, callback: AsyncCallback): void;
function open(path: string, flags: number, callback: AsyncCallback): void;
function open(path: string, flags: number, mode: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function mkdtempSync(prefix: string): string; Added
ohos.fileio fileIO function mkdtemp(prefix: string): Promise;
function mkdtemp(prefix: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function mkdir(path: string, mode?: number): Promise;
function mkdir(path: string, callback: AsyncCallback): void;
function mkdir(path: string, mode: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function lstatSync(path: string): Stat; Added
ohos.fileio fileIO function lstat(path: string): Promise;
function lstat(path: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function lchownSync(path: string, uid: number, gid: number): void; Added
ohos.fileio fileIO function lchown(path: string, uid: number, gid: number): Promise;
function lchown(path: string, uid: number, gid: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function hash(path: string, algorithm: string): Promise;
function hash(path: string, algorithm: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function fdopenStream(fd: number, mode: string): Promise;
function fdopenStream(fd: number, mode: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function fchmod(fd: number, mode: number): Promise;
function fchmod(fd: number, mode: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function fchown(fd: number, uid: number, gid: number): Promise;
function fchown(fd: number, uid: number, gid: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function fdatasyncSync(fd: number): void; Added
ohos.fileio fileIO function fdatasync(fd: number): Promise;
function fdatasync(fd: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function fstat(fd: number): Promise;
function fstat(fd: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function fsync(fd: number): Promise;
function fsync(fd: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function ftruncate(fd: number, len?: number): Promise;
function ftruncate(fd: number, callback: AsyncCallback): void;
function ftruncate(fd: number, len: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function chmod(path: string, mode: number): Promise;
function chmod(path: string, mode: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function chown(path: string, uid: number, gid: number): Promise;
function chown(path: string, uid: number, gid: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function createStream(path: string, mode: string): Promise;
function createStream(path: string, mode: string, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function copyFile(src: string | number, dest: string | number, mode?: number): Promise;
function copyFile(src: string | number, dest: string | number, callback: AsyncCallback): void;
function copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function close(fd: number): Promise;
function close(fd: number, callback: AsyncCallback): void;
Added
ohos.fileio fileIO function access(path: string, mode?: number): Promise;
function access(path: string, callback: AsyncCallback): void;
function access(path: string, mode: number, callback: AsyncCallback): void;
Added
ohos.document document function show(uri: string, type: string): Promise;
function show(uri: string, type: string, callback: AsyncCallback): void;
Added
ohos.document document function choose(types?: string[]): Promise;
function choose(callback: AsyncCallback): void;
function choose(types: string[], callback: AsyncCallback): void;
Added