# 文件管理子系统JS API变更 OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,文件管理子系统的API变更如下: ## 接口变更 | 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | |---|---|---|---| | ohos.statfs | Statfs | function getTotalBytes(path: string, callback: AsyncCallback): void;
function getTotalBytes(path: string): Promise; | 新增 | | ohos.statfs | Statfs | function getFreeBytes(path: string, callback: AsyncCallback): void;
function getFreeBytes(path: string): Promise; | 新增 | | ohos.fileio | Watcher | stop(): Promise;
stop(callback: AsyncCallback): void; | 新增 | | ohos.fileio | ReadOut | buffer: ArrayBuffer; | 新增 | | ohos.fileio | ReadOut | offset: number; | 新增 | | ohos.fileio | ReadOut | bytesRead: number; | 新增 | | 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; | 新增 | | 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; | 新增 | | ohos.fileio | Stream | flush(): Promise;
flush(callback: AsyncCallback): void; | 新增 | | ohos.fileio | Stream | close(): Promise;
close(callback: AsyncCallback): void; | 新增 | | ohos.fileio | Dir | close(): Promise;
close(callback: AsyncCallback): void; | 新增 | | ohos.fileio | Dir | read(): Promise;
read(callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function createWatcher(filename: string, events: number, callback: AsyncCallback): Watcher; | 新增 | | 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; | 新增 | | ohos.fileio | fileIO | function unlink(path: string): Promise;
function unlink(path: string, callback: AsyncCallback): void; | 新增 | | 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; | 新增 | | ohos.fileio | fileIO | function symlinkSync(target: string, srcPath: string): void; | 新增 | | ohos.fileio | fileIO | function symlink(target: string, srcPath: string): Promise;
function symlink(target: string, srcPath: string, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function stat(path: string): Promise;
function stat(path: string, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function rmdir(path: string): Promise;
function rmdir(path: string, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function rename(oldPath: string, newPath: string): Promise;
function rename(oldPath: string, newPath: string, callback: AsyncCallback): void; | 新增 | | 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; | 新增 | | ohos.fileio | fileIO | function readTextSync(filePath: string, options?: { position?: number; length?: number; encoding?: string; }): string;| 新增 | | 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; | 新增 | | ohos.fileio | fileIO | function opendir(path: string): Promise;
function opendir(path: string, callback: AsyncCallback): void; | 新增 | | 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; | 新增 | | ohos.fileio | fileIO | function mkdtempSync(prefix: string): string; | 新增 | | ohos.fileio | fileIO | function mkdtemp(prefix: string): Promise;
function mkdtemp(prefix: string, callback: AsyncCallback): void; | 新增 | | 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; | 新增 | | ohos.fileio | fileIO | function lstatSync(path: string): Stat; | 新增 | | ohos.fileio | fileIO | function lstat(path: string): Promise;
function lstat(path: string, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function lchownSync(path: string, uid: number, gid: number): void; | 新增 | | ohos.fileio | fileIO | function lchown(path: string, uid: number, gid: number): Promise;
function lchown(path: string, uid: number, gid: number, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function hash(path: string, algorithm: string): Promise;
function hash(path: string, algorithm: string, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function fdopenStream(fd: number, mode: string): Promise;
function fdopenStream(fd: number, mode: string, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function fchmod(fd: number, mode: number): Promise;
function fchmod(fd: number, mode: number, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function fchown(fd: number, uid: number, gid: number): Promise;
function fchown(fd: number, uid: number, gid: number, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function fdatasyncSync(fd: number): void; | 新增 | | ohos.fileio | fileIO | function fdatasync(fd: number): Promise;
function fdatasync(fd: number, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function fstat(fd: number): Promise;
function fstat(fd: number, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function fsync(fd: number): Promise;
function fsync(fd: number, callback: AsyncCallback): void; | 新增 | | 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; | 新增 | | ohos.fileio | fileIO | function chmod(path: string, mode: number): Promise;
function chmod(path: string, mode: number, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function chown(path: string, uid: number, gid: number): Promise;
function chown(path: string, uid: number, gid: number, callback: AsyncCallback): void; | 新增 | | ohos.fileio | fileIO | function createStream(path: string, mode: string): Promise;
function createStream(path: string, mode: string, callback: AsyncCallback): void; | 新增 | | 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; | 新增 | | ohos.fileio | fileIO | function close(fd: number): Promise;
function close(fd: number, callback: AsyncCallback): void; | 新增 | | 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; | 新增 | | ohos.document | document | function show(uri: string, type: string): Promise;
function show(uri: string, type: string, callback: AsyncCallback): void; | 新增 | | ohos.document | document | function choose(types?: string[]): Promise;
function choose(callback: AsyncCallback): void;
function choose(types: string[], callback: AsyncCallback): void; | 新增 |