diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index fc4205ce6cf0407ba851aceff378213e2abf89f6..8850e5c9c6048e0ec01dd1b028fe6da9ea9c2a95 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -3,7 +3,13 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -该模块提供文件存储相关的常用功能:向应用程序提供用于IO的JS接口,包括用于管理文件的基本文件接口,用于管理目录的基本目录接口,用于获取文件信息的统计接口,用于流式读写文件的流式接口。 +该模块提供文件存储相关的常用功能,向应用程序提供用于IO的JS接口,包括: + +- 用于管理文件的基本文件接口 +- 用于管理目录的基本目录接口 +- 用于获取文件信息的统计接口 +- 用于流式读写文件的流式接口 + ## 导入模块 @@ -14,10 +20,8 @@ import fileio from '@ohos.fileio'; ## 使用说明 -使用该功能模块对文件/目录进行操作前,需要先获取其应用沙箱路径,获取方式及其接口用法请参考:[Context模块的接口getOrCreateLocalDir](js-apis-Context.md)。 - -“文件/目录应用沙箱路径”=“应用目录路径”+“文件/目录名” - +使用该功能模块对文件/目录进行操作前,需要先获取其应用沙箱绝对路径,“文件/目录应用沙箱路径”=“应用目录路径”+“文件/目录名”。 +应用目录路径dir的获取方式及对应的接口用法请参考:[Context模块的接口getOrCreateLocalDir](js-apis-Context.md)。 通过上述接口获取到应用目录路径dir,文件名为“xxx.txt”,文件所在应用沙箱路径为: ```js @@ -37,7 +41,7 @@ let fd = fileio.openSync(path); stat(path: string): Promise<Stat> -以异步方法获取文件信息,使用promise形式返回结果。 +获取文件信息,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -51,12 +55,12 @@ stat(path: string): Promise<Stat> | 类型 | 说明 | | ---------------------------- | ---------- | - | Promise<[Stat](#stat)> | 表示文件的具体信息。 | + | Promise<[Stat](#stat)> | Promise对象。返回文件的具体信息。 | **示例:** ```js fileio.stat(path).then(function(stat){ - console.info("getFileInfo successfully:"+ JSON.stringify(stat)); + console.info("getFileInfo succeed:"+ JSON.stringify(stat)); }).catch(function(err){ console.info("getFileInfo failed with error:"+ err); }); @@ -67,7 +71,7 @@ stat(path: string): Promise<Stat> stat(path:string, callback:AsyncCallback<Stat>): void -以异步方法获取文件信息,使用callback形式返回结果。 +获取文件信息,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -115,7 +119,7 @@ statSync(path:string): Stat opendir(path: string): Promise<Dir> -以异步方法打开文件目录,使用promise形式返回结果。 +打开文件目录,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -127,12 +131,12 @@ opendir(path: string): Promise<Dir> **返回值:** | 类型 | 说明 | | -------------------------- | -------- | - | Promise<[Dir](#dir)> | 返回Dir对象。 | + | Promise<[Dir](#dir)> | Promise对象。返回Dir对象。 | **示例:** ```js fileio.opendir(path).then(function(dir){ - console.info("opendir successfully:"+ JSON.stringify(dir)); + console.info("opendir succeed:"+ JSON.stringify(dir)); }).catch(function(err){ console.info("opendir failed with error:"+ err); }); @@ -143,7 +147,7 @@ opendir(path: string): Promise<Dir> opendir(path: string, callback: AsyncCallback<Dir>): void -以异步方法打开文件目录,使用callback形式返回结果。 +打开文件目录,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -195,7 +199,7 @@ opendirSync(path: string): Dir access(path: string, mode?: number): Promise<void> -以异步方法检查当前进程是否可访问某文件,使用promise形式返回结果。 +检查当前进程是否可访问某文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -209,12 +213,12 @@ access(path: string, mode?: number): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.access(path).then(function() { - console.info("access successfully"); + console.info("access succeed"); }).catch(function(err){ console.info("access failed with error:"+ err); }); @@ -225,7 +229,7 @@ access(path: string, mode?: number): Promise<void> access(path: string, mode: number, callback: AsyncCallback<void>): void -以异步方法检查当前进程是否可访问某文件,使用callback形式返回结果。 +检查当前进程是否可访问某文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -272,7 +276,7 @@ accessSync(path: string, mode?: number): void close(fd: number):Promise<void> -以异步方法关闭文件,使用promise形式返回结果。 +关闭文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -284,13 +288,13 @@ close(fd: number):Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js let fd = fileio.openSync(path); fileio.close(fd).then(function(){ - console.info("close file successfully"); + console.info("close file succeed"); }).catch(function(err){ console.info("close file failed with error:"+ err); }); @@ -301,7 +305,7 @@ close(fd: number):Promise<void> close(fd: number, callback:AsyncCallback<void>): void -以异步方法关闭文件,使用callback形式返回结果。 +关闭文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -343,19 +347,19 @@ closeSync(fd: number): void close(): Promise<void> -以异步方法关闭文件流,使用promise形式返回结果。 +关闭文件流,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.close().then(function(){ - console.info("close file stream successfully"); + console.info("close file stream succeed"); }).catch(function(err){ console.info("close file stream failed with error:"+ err); }); @@ -366,7 +370,7 @@ close(): Promise<void> close(callback: AsyncCallback<void>): void -以异步方法关闭文件流,使用callback形式返回结果。 +关闭文件流,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -387,7 +391,7 @@ close(callback: AsyncCallback<void>): void copyFile(src:string | number, dest:string | number, mode?:number):Promise<void> -以异步方法复制文件,使用promise形式返回结果。 +复制文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -401,12 +405,12 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise<voi **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.copyFile(src, dest).then(function(){ - console.info("copyFile successfully"); + console.info("copyFile succeed"); }).catch(function(err){ console.info("copyFile failed with error:"+ err); }); @@ -417,7 +421,7 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise<voi copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback<void>): void -以异步方法复制文件,使用callback形式返回结果。 +复制文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -462,7 +466,7 @@ copyFileSync(src: string | number, dest: string | number, mode?: number): void mkdir(path:string, mode?: number): Promise<void> -以异步方法创建目录,使用promise形式返回结果。 +创建目录,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -475,12 +479,12 @@ mkdir(path:string, mode?: number): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.mkdir(path).then(function() { - console.info("mkdir successfully"); + console.info("mkdir succeed"); }).catch(function (error){ console.info("mkdir failed with error:"+ error); }); @@ -491,7 +495,7 @@ mkdir(path:string, mode?: number): Promise<void> mkdir(path: string, mode: number, callback: AsyncCallback<void>): void -以异步方法创建目录,使用callback形式返回结果。 +创建目录,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -505,7 +509,7 @@ mkdir(path: string, mode: number, callback: AsyncCallback<void>): void **示例:** ```js fileio.mkdir(path, function(err) { - console.info("mkdir successfully"); + console.info("mkdir succeed"); }); ``` @@ -534,7 +538,7 @@ mkdirSync(path: string, mode?: number): void open(path: string, flags?: number, mode?: number): Promise<number> -以异步的方法打开文件,使用promise形式返回结果。 +打开文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -548,12 +552,12 @@ open(path: string, flags?: number, mode?: number): Promise<number> **返回值:** | 类型 | 说明 | | --------------------- | ----------- | - | Promise<number> | 打开文件的文件描述符。 | + | Promise<number> | Promise对象。返回打开文件的文件描述符。 | **示例:** ```js fileio.open(path, 0o1, 0o0200).then(function(number){ - console.info("open file successfully"); + console.info("open file succeed"); }).catch(function(error){ console.info("open file failed with error:"+ err); }); @@ -564,7 +568,7 @@ open(path: string, flags?: number, mode?: number): Promise<number> open(path: string, flags: number, mode: number, callback: AsyncCallback<number>): void -以异步的方法打开文件,使用callback形式返回结果。 +打开文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -618,7 +622,7 @@ read(fd: number, buffer: ArrayBuffer, options?: { position?: number; }): Promise<ReadOut> -以异步方法从文件读取数据,使用promise形式返回结果。 +从文件读取数据,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -633,14 +637,14 @@ read(fd: number, buffer: ArrayBuffer, options?: { | 类型 | 说明 | | ---------------------------------- | ------ | - | Promise<[ReadOut](#readout)> | 读取的结果。 | + | Promise<[ReadOut](#readout)> | Promise对象。返回读取的结果。 | **示例:** ```js let fd = fileio.openSync(path, 0o2); let buf = new ArrayBuffer(4096); fileio.read(fd, buf).then(function(readout){ - console.info("read file data successfully"); + console.info("read file data succeed"); console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); }).catch(function(error){ console.info("read file data failed with error:"+ error); @@ -656,7 +660,7 @@ read(fd: number, buffer: ArrayBuffer, options: { position?: number; }, callback: AsyncCallback<ReadOut>): void -以异步方法从文件读取数据,使用callback形式返回结果。 +从文件读取数据,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -674,7 +678,7 @@ read(fd: number, buffer: ArrayBuffer, options: { let buf = new ArrayBuffer(4096); fileio.read(fd, buf, function (err, readOut) { if (readOut) { - console.info("read file data successfully"); + console.info("read file data succeed"); console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); } }); @@ -717,7 +721,7 @@ readSync(fd: number, buffer: ArrayBuffer, options?: { rmdir(path: string): Promise<void> -以异步方法删除目录,使用promise形式返回结果。 +删除目录,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -729,12 +733,12 @@ rmdir(path: string): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.rmdir(path).then(function() { - console.info("rmdir successfully"); + console.info("rmdir succeed"); }).catch(function(err){ console.info("rmdir failed with error:"+ err); }); @@ -745,7 +749,7 @@ rmdir(path: string): Promise<void> rmdir(path: string, callback:AsyncCallback<void>): void -以异步方法删除目录,使用callback形式返回结果。 +删除目录,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -759,7 +763,7 @@ rmdir(path: string, callback:AsyncCallback<void>): void ```js fileio.rmdir(path, function(err){ // do something - console.info("rmdir successfully"); + console.info("rmdir succeed"); }); ``` @@ -787,7 +791,7 @@ rmdirSync(path: string): void unlink(path:string): Promise<void> -以异步方法删除文件,使用promise形式返回结果。 +删除文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -799,12 +803,12 @@ unlink(path:string): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.unlink(path).then(function(){ - console.info("remove file successfully"); + console.info("remove file succeed"); }).catch(function(error){ console.info("remove file failed with error:"+ error); }); @@ -815,7 +819,7 @@ unlink(path:string): Promise<void> unlink(path:string, callback:AsyncCallback<void>): void -以异步方法删除文件,使用callback形式返回结果。 +删除文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -828,7 +832,7 @@ unlink(path:string, callback:AsyncCallback<void>): void **示例:** ```js fileio.unlink(path, function(err) { - console.info("remove file successfully"); + console.info("remove file succeed"); }); ``` @@ -861,7 +865,7 @@ write(fd: number, buffer: ArrayBuffer | string, options?: { encoding?: string; }): Promise<number> -以异步方法将数据写入文件,使用promise形式返回结果。 +将数据写入文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -875,13 +879,13 @@ write(fd: number, buffer: ArrayBuffer | string, options?: { **返回值:** | 类型 | 说明 | | --------------------- | -------- | - | Promise<number> | 实际写入的长度。 | + | Promise<number> | Promise对象。返回实际写入的长度。 | **示例:** ```js let fd = fileio.openSync(fpath, 0o100 | 0o2, 0o666); fileio.write(fd, "hello, world").then(function(number){ - console.info("write data to file successfully and size is:"+ number); + console.info("write data to file succeed and size is:"+ number); }).catch(function(err){ console.info("write data to file failed with error:"+ err); }); @@ -897,7 +901,7 @@ write(fd: number, buffer: ArrayBuffer | string, options: { encoding?: string; }, callback: AsyncCallback<number>): void -以异步方法将数据写入文件,使用callback形式返回结果。 +将数据写入文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -914,7 +918,7 @@ write(fd: number, buffer: ArrayBuffer | string, options: { let fd = fileio.openSync(path, 0o100 | 0o2, 0o666); fileio.write(fd, "hello, world", function (err, bytesWritten) { if (bytesWritten) { - console.info("write data to file successfully and size is:"+ bytesWritten); + console.info("write data to file succeed and size is:"+ bytesWritten); } }); ``` @@ -956,7 +960,7 @@ writeSync(fd: number, buffer: ArrayBuffer | string, options?: { hash(path: string, algorithm: string): Promise<string> -以异步方法计算文件的哈希值,使用promise形式返回结果。 +计算文件的哈希值,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -969,12 +973,12 @@ hash(path: string, algorithm: string): Promise<string> **返回值:** | 类型 | 说明 | | --------------------- | -------------------------- | - | Promise<string> | 文件的哈希值。表示为十六进制数字串,所有字母均大写。 | + | Promise<string> | Promise对象。返回文件的哈希值。表示为十六进制数字串,所有字母均大写。 | **示例:** ```js fileio.hash(path, "sha256").then(function(str){ - console.info("calculate file hash successfully:"+ str); + console.info("calculate file hash succeed:"+ str); }).catch(function(error){ console.info("calculate file hash failed with error:"+ err); }); @@ -985,7 +989,7 @@ hash(path: string, algorithm: string): Promise<string> hash(path: string, algorithm: string, callback: AsyncCallback<string>): void -以异步方法计算文件的哈希值,使用callback形式返回结果。 +计算文件的哈希值,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -994,13 +998,13 @@ hash(path: string, algorithm: string, callback: AsyncCallback<string>): vo | --------- | --------------------------- | ---- | ------------------------------------------------------------ | | path | string | 是 | 待计算哈希值文件的应用沙箱路径。 | | algorithm | string | 是 | 哈希计算采用的算法。可选 "md5"、"sha1" 或 "sha256"。建议采用安全强度更高的 "sha256"。 | -| callback | AsyncCallback<string> | 是 | 异步计算文件哈希操之后的回调函数(其中给定文件哈希值表示为十六进制数字串,所有字母均大写)。 | +| callback | AsyncCallback<string> | 是 | 异步计算文件哈希操作之后的回调函数(其中给定文件哈希值表示为十六进制数字串,所有字母均大写)。 | **示例:** ```js fileio.hash(fpath, "sha256", function(err, hashStr) { if (hashStr) { - console.info("calculate file hash successfully:"+ hashStr); + console.info("calculate file hash succeed:"+ hashStr); } }); ``` @@ -1010,25 +1014,25 @@ hash(path: string, algorithm: string, callback: AsyncCallback<string>): vo chmod(path: string, mode: number):Promise<void> -以异步方法基于文件路径改变文件权限,使用promise形式返回结果。 +改变文件权限,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | -| path | string | 是 | 待改变文件权限的应用沙箱路径。 | +| path | string | 是 | 所需变更权限的文件的应用沙箱路径。 | | mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.chmod(path, mode).then(function() { - console.info("chmod successfully"); + console.info("chmod succeed"); }).catch(function(err){ console.info("chmod failed with error:"+ err); }); @@ -1039,14 +1043,14 @@ chmod(path: string, mode: number):Promise<void> chmod(path: string, mode: number, callback: AsyncCallback<void>): void -以异步方法基于文件路径改变文件权限,使用callback形式返回结果。 +改变文件权限,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| path | string | 是 | 待改变文件权限的应用沙箱路径。 | +| path | string | 是 | 所需变更权限的文件的应用沙箱路径。 | | mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | | callback | AsyncCallback<void> | 是 | 异步改变文件权限之后的回调。 | @@ -1062,14 +1066,14 @@ chmod(path: string, mode: number, callback: AsyncCallback<void>): void chmodSync(path: string, mode: number): void -以同步方法基于文件路径改变文件权限。 +以同步方法改变文件权限。 **系统能力**:SystemCapability.FileManagement.File.FileIO **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | -| path | string | 是 | 待改变文件权限的应用沙箱路径。 | +| path | string | 是 | 所需变更权限的文件的应用沙箱路径。 | | mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | **示例:** @@ -1082,24 +1086,24 @@ chmodSync(path: string, mode: number): void fstat(fd: number): Promise<Stat> -以异步方法基于文件描述符获取文件状态信息,使用promise形式返回结果。 +基于文件描述符获取文件状态信息,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO **参数:** | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------ | - | fd | number | 是 | 待获取文件的文件描述符。 | + | fd | number | 是 | 待获取文件状态的文件描述符。 | **返回值:** | 类型 | 说明 | | ---------------------------- | ---------- | - | Promise<[Stat](#stat)> | 表示文件的具体信息。 | + | Promise<[Stat](#stat)> | Promise对象。返回表示文件状态的具体信息。 | **示例:** ```js fileio.fstat(fd).then(function(stat){ - console.info("fstat successfully:"+ JSON.stringify(stat)); + console.info("fstat succeed:"+ JSON.stringify(stat)); }).catch(function(err){ console.info("fstat failed with error:"+ err); }); @@ -1110,14 +1114,14 @@ fstat(fd: number): Promise<Stat> fstat(fd: number, callback: AsyncCallback<Stat>): void -以异步方法基于文件描述符获取文件状态信息,使用callback形式返回结果。 +基于文件描述符获取文件状态信息,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------- | ---- | ---------------- | - | fd | number | 是 | 待获取文件的文件描述符。 | + | fd | number | 是 | 待获取文件状态的文件描述符。 | | callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取文件状态信息之后的回调。 | **示例:** @@ -1140,12 +1144,12 @@ fstatSync(fd: number): Stat **参数:** | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------ | - | fd | number | 是 | 待获取文件的文件描述符。 | + | fd | number | 是 | 待获取文件状态的文件描述符。 | **返回值:** | 类型 | 说明 | | ------------- | ---------- | - | [Stat](#stat) | 表示文件的具体信息。 | + | [Stat](#stat) | 表示文件状态的具体信息。 | **示例:** ```js @@ -1158,7 +1162,7 @@ fstatSync(fd: number): Stat ftruncate(fd: number, len?: number): Promise<void> -以异步方法基于文件描述符截断文件,使用promise形式返回结果。 +基于文件描述符截断文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1166,18 +1170,18 @@ ftruncate(fd: number, len?: number): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ---------------- | | fd | number | 是 | 待截断文件的文件描述符。 | - | len | number | 是 | 文件截断后的长度,以字节为单位。 | + | len | number | 否 | 文件截断后的长度,以字节为单位。 | **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。| **示例:** ```js let fd = fileio.openSync(path); fileio.ftruncate(fd, 5).then(function(err) { - console.info("truncate file successfully"); + console.info("truncate file succeed"); }).catch(function(err){ console.info("truncate file failed with error:"+ err); }); @@ -1188,7 +1192,7 @@ ftruncate(fd: number, len?: number): Promise<void> ftruncate(fd: number, len: number, callback:AsyncCallback<void>): void -以异步方法基于文件描述符截断文件,使用callback形式返回结果。 +基于文件描述符截断文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1231,7 +1235,7 @@ ftruncateSync(fd: number, len?: number): void truncate(path: string, len?: number): Promise<void> -以异步方法基于文件路径截断文件,使用promise形式返回结果。 +基于文件路径截断文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1239,17 +1243,17 @@ truncate(path: string, len?: number): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | -------------------------------- | | path | string | 是 | 待截断文件的应用沙箱路径。 | -| len | number | 是 | 文件截断后的长度,以字节为单位。 | +| len | number | 否 | 文件截断后的长度,以字节为单位。 | **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.truncate(path, len).then(function(){ - console.info("truncate file successfully"); + console.info("truncate file succeed"); }).catch(function(err){ console.info("truncate file failed with error:"+ err); }); @@ -1260,7 +1264,7 @@ truncate(path: string, len?: number): Promise<void> truncate(path: string, len: number, callback:AsyncCallback<void>): void -以异步方法基于文件路径截断文件,使用callback形式返回结果。 +基于文件路径截断文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1307,7 +1311,7 @@ readText(filePath: string, options?: { encoding?: string; }): Promise<string> -以异步方法基于文本方式读取文件(即直接读取文件的文本内容),使用promise形式返回结果。 +基于文本方式读取文件(即直接读取文件的文本内容),使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1320,12 +1324,12 @@ readText(filePath: string, options?: { **返回值:** | 类型 | 说明 | | --------------------- | ---------- | - | Promise<string> | 返回读取文件的内容。 | + | Promise<string> | Promise对象。返回读取文件的内容。 | **示例:** ```js fileio.readText(path).then(function(str) { - console.info("readText successfully:"+ str); + console.info("readText succeed:"+ str); }).catch(function(err){ console.info("readText failed with error:"+ err); }); @@ -1340,7 +1344,7 @@ readText(filePath: string, options: { encoding?: string; }, callback: AsyncCallback<string>): void -以异步方法基于文本方式读取文件(即直接读取文件的文本内容),使用callback形式返回结果。 +基于文本方式读取文件(即直接读取文件的文本内容),使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1392,24 +1396,24 @@ readTextSync(filePath: string, options?: { lstat(path: string): Promise<Stat> -以异步方法获取链接状态信息,使用promise形式返回结果。 +获取链接信息,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | -------------------------------------- | -| path | string | 是 | 目标文件的应用沙箱路径,指向链接状态。 | +| path | string | 是 | 目标文件的应用沙箱路径,指向链接。 | **返回值:** | 类型 | 说明 | | ---------------------------- | ---------- | - | Promise<[Stat](#stat)> | 表示文件的具体信息。 | + | Promise<[Stat](#stat)> | Promise对象。返回表示文件状态的具体信息。 | **示例:** ```js fileio.lstat(path).then(function(stat){ - console.info("get link status successfully:"+ number); + console.info("get link status succeed:"+ number); }).catch(function(err){ console.info("get link status failed with error:"+ err); }); @@ -1420,15 +1424,15 @@ lstat(path: string): Promise<Stat> lstat(path:string, callback:AsyncCallback<Stat>): void -以异步方法获取链接状态信息,使用callback形式返回结果。 +获取链接信息,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------- | ---- | -------------------------------------- | -| path | string | 是 | 目标文件的应用沙箱路径,指向链接状态。 | -| callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取链接状态信息之后的回调。 | +| path | string | 是 | 目标文件的应用沙箱路径,指向链接。 | +| callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取链接信息之后的回调。 | **示例:** ```js @@ -1442,14 +1446,14 @@ lstat(path:string, callback:AsyncCallback<Stat>): void lstatSync(path:string): Stat -以同步方法获取链接状态信息。 +以同步方法获取链接信息。 **系统能力**:SystemCapability.FileManagement.File.FileIO **参数:** | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | -------------------------------------- | -| path | string | 是 | 目标文件的应用沙箱路径,指向链接状态。 | +| path | string | 是 | 目标文件的应用沙箱路径,指向链接。 | **返回值:** | 类型 | 说明 | @@ -1470,7 +1474,7 @@ read(buffer: ArrayBuffer, options?: { length?: number; }): Promise<ReadOut> -以异步方法从文件读取数据,使用promise形式返回结果。 +从文件读取数据,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1483,12 +1487,12 @@ read(buffer: ArrayBuffer, options?: { **返回值:** | 类型 | 说明 | | ---------------------------------- | ------ | - | Promise<[ReadOut](#readout)> | 读取的结果。 | + | Promise<[ReadOut](#readout)> | Promise对象。返回读取的结果。 | **示例:** ```js fileio.read(new ArrayBuffer(4096)).then(function(readout){ - console.info("read file data successfully"); + console.info("read file data succeed"); console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); }).catch(function(err){ console.info("read file data failed with error:"+ err); @@ -1504,7 +1508,7 @@ read(buffer: ArrayBuffer, options: { length?: number; }, callback: AsyncCallback<ReadOut>): void -异步方法从文件读取数据,使用callback形式返回结果。 +从文件读取数据,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1520,7 +1524,7 @@ read(buffer: ArrayBuffer, options: { let buf = new ArrayBuffer(4096); fileio.read(buf, function (err, readOut) { if (readOut) { - console.info("read file data successfully"); + console.info("read file data succeed"); console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); } }); @@ -1531,7 +1535,7 @@ read(buffer: ArrayBuffer, options: { rename(oldPath: string, newPath: string): Promise<void> -以异步方法重命名文件,使用promise形式返回结果。 +重命名文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1544,12 +1548,12 @@ rename(oldPath: string, newPath: string): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.rename(oldPath, newPath).then(function() { - console.info("rename successfully"); + console.info("rename succeed"); }).catch(function(err){ console.info("rename failed with error:"+ err); }); @@ -1560,7 +1564,7 @@ rename(oldPath: string, newPath: string): Promise<void> rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): void -以异步方法重命名文件,使用callback形式返回结果。 +重命名文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1602,7 +1606,7 @@ renameSync(oldPath: string, newPath: string): void fsync(fd: number): Promise<void> -以异步方法同步文件数据,使用promise形式返回结果。 +同步文件数据,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1614,12 +1618,12 @@ fsync(fd: number): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.fsync(fd).then(function(){ - console.info("sync data successfully"); + console.info("sync data succeed"); }).catch(function(err){ console.info("sync data failed with error:"+ err); }); @@ -1630,7 +1634,7 @@ fsync(fd: number): Promise<void> fsync(fd: number, callback: AsyncCallback<void>): void -以异步方法同步文件数据,使用callback形式返回结果。 +同步文件数据,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1671,7 +1675,7 @@ fsyncSync(fd: number): void fdatasync(fd: number): Promise<void> -以异步方法实现文件内容数据同步,使用promise形式返回结果。 +实现文件内容数据同步,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1683,12 +1687,12 @@ fdatasync(fd: number): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.fdatasync(fd).then(function(err) { - console.info("sync data successfully"); + console.info("sync data succeed"); }).catch(function(err){ console.info("sync data failed with error:"+ err); }); @@ -1699,7 +1703,7 @@ fdatasync(fd: number): Promise<void> fdatasync(fd: number, callback:AsyncCallback<void>): void -以异步方法实现文件内容数据同步,使用callback形式返回结果。 +实现文件内容数据同步,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1740,7 +1744,7 @@ fdatasyncSync(fd: number): void symlink(target: string, srcPath: string): Promise<void> -以异步方法基于文件路径创建符号链接,使用promise形式返回结果。 +基于文件路径创建符号链接,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1753,12 +1757,12 @@ symlink(target: string, srcPath: string): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.symlink(target, srcPath).then(function() { - console.info("symlink successfully"); + console.info("symlink succeed"); }).catch(function(err){ console.info("symlink failed with error:"+ err); }); @@ -1769,7 +1773,7 @@ symlink(target: string, srcPath: string): Promise<void> symlink(target: string, srcPath: string, callback: AsyncCallback<void>): void -以异步方法基于文件路径创建符号链接,使用callback形式返回结果。 +基于文件路径创建符号链接,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1812,7 +1816,7 @@ symlinkSync(target: string, srcPath: string): void chown(path: string, uid: number, gid: number): Promise<void> -以异步的方法基于文件路径改变文件所有者,使用promise形式返回结果。 +基于文件路径改变文件所有者,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1826,13 +1830,13 @@ chown(path: string, uid: number, gid: number): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js let stat = fileio.statSync(path); fileio.chown(path, stat.uid, stat.gid).then(function(){ - console.info("chown successfully"); + console.info("chown succeed"); }).catch(function(err){ console.info("chown failed with error:"+ err); }); @@ -1843,7 +1847,7 @@ chown(path: string, uid: number, gid: number): Promise<void> chown(path: string, uid: number, gid: number, callback: AsyncCallback<void>): void -以异步的方法基于文件路径改变文件所有者,使用callback形式返回结果。 +基于文件路径改变文件所有者,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1890,7 +1894,7 @@ chownSync(path: string, uid: number, gid: number): void mkdtemp(prefix: string): Promise<string> -以异步的方法创建临时目录,使用promise形式返回结果。 +创建临时目录,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1902,12 +1906,12 @@ mkdtemp(prefix: string): Promise<string> **返回值:** | 类型 | 说明 | | --------------------- | ---------- | - | Promise<string> | 生成的唯一目录路径。 | + | Promise<string> | Promise对象。返回生成的唯一目录路径。 | **示例:** ```js fileio.mkdtemp(path + "XXXX").then(function(path){ - console.info("mkdtemp successfully:"+ path); + console.info("mkdtemp succeed:"+ path); }).catch(function(err){ console.info("mkdtemp failed with error:"+ err); }); @@ -1918,7 +1922,7 @@ mkdtemp(prefix: string): Promise<string> mkdtemp(prefix: string, callback: AsyncCallback<string>): void -以异步的方法创建临时目录,使用callback形式返回结果。 +创建临时目录,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1964,7 +1968,7 @@ mkdtempSync(prefix: string): string fchmod(fd: number, mode: number): Promise<void> -以异步方法基于文件描述符改变文件权限,使用promise形式返回结果。 +基于文件描述符改变文件权限,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -1977,12 +1981,12 @@ fchmod(fd: number, mode: number): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js fileio.fchmod(fd, mode).then(function() { - console.info("chmod successfully"); + console.info("chmod succeed"); }).catch(function(err){ console.info("chmod failed with error:"+ err); }); @@ -1993,7 +1997,7 @@ fchmod(fd: number, mode: number): Promise<void> fchmod(fd: number, mode: number, callback: AsyncCallback<void>): void -以异步方法基于文件描述符改变文件权限,使用callback形式返回结果。 +基于文件描述符改变文件权限,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2036,7 +2040,7 @@ fchmodSync(fd: number, mode: number): void createStream(path: string, mode: string): Promise<Stream> -以异步方法基于文件路径打开文件流,使用promise形式返回结果。 +基于文件路径打开文件流,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2049,12 +2053,12 @@ createStream(path: string, mode: string): Promise<Stream> **返回值:** | 类型 | 说明 | | --------------------------------- | --------- | - | Promise<[Stream](#stream7)> | 返回文件流的结果。 | + | Promise<[Stream](#stream7)> | Promise对象。返回文件流的结果。 | **示例:** ```js fileio.createStream(path, "r+").then(function(stream){ - console.info("createStream successfully"); + console.info("createStream succeed"); }).catch(function(err){ console.info("createStream failed with error:"+ err); }); @@ -2065,7 +2069,7 @@ createStream(path: string, mode: string): Promise<Stream> createStream(path: string, mode: string, callback: AsyncCallback<Stream>): void -以异步方法基于文件路径打开文件流,使用callback形式返回结果。 +基于文件路径打开文件流,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2113,7 +2117,7 @@ createStreamSync(path: string, mode: string): Stream fdopenStream(fd: number, mode: string): Promise<Stream> -以异步方法基于文件描述符打开文件流,使用promise形式返回结果。 +基于文件描述符打开文件流,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2126,12 +2130,12 @@ fdopenStream(fd: number, mode: string): Promise<Stream> **返回值:** | 类型 | 说明 | | --------------------------------- | --------- | - | Promise<[Stream](#stream7)> | 返回文件流的结果。 | + | Promise<[Stream](#stream7)> | Promise对象。返回文件流的结果。 | **示例:** ```js fileio.fdopenStream(fd, mode).then(function(stream){ - console.info("openStream successfully"); + console.info("openStream succeed"); }).catch(function(err){ console.info("openStream failed with error:"+ err); }); @@ -2142,7 +2146,7 @@ fdopenStream(fd: number, mode: string): Promise<Stream> fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): void -以异步方法基于文件描述符打开文件流,使用callback形式返回结果。 +基于文件描述符打开文件流,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2190,7 +2194,7 @@ fdopenStreamSync(fd: number, mode: string): Stream fchown(fd: number, uid: number, gid: number): Promise<void> -以异步方法基于文件描述符改变文件所有者,使用promise形式返回结果。 +基于文件描述符改变文件所有者,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2204,13 +2208,13 @@ fchown(fd: number, uid: number, gid: number): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js let stat = fileio.statSync(path); fileio.fchown(fd, stat.uid, stat.gid).then(function() { - console.info("chown successfully"); + console.info("chown succeed"); }).catch(function(err){ console.info("chown failed with error:"+ err); }); @@ -2221,7 +2225,7 @@ fchown(fd: number, uid: number, gid: number): Promise<void> fchown(fd: number, uid: number, gid: number, callback: AsyncCallback<void>): void -以异步方法基于文件描述符改变文件所有者,使用callback形式返回结果。 +基于文件描述符改变文件所有者,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2268,7 +2272,7 @@ fchownSync(fd: number, uid: number, gid: number): void lchown(path: string, uid: number, gid: number): Promise<void> -以异步方法基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是符号链接所指向的实际文件,使用promise形式返回结果。 +基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是符号链接所指向的实际文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2282,13 +2286,13 @@ lchown(path: string, uid: number, gid: number): Promise<void> **返回值:** | 类型 | 说明 | | ------------------- | ---------------------------- | - | Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 | + | Promise<void> | Promise对象。无返回值。 | **示例:** ```js let stat = fileio.statSync(path); fileio.lchown(path, stat.uid, stat.gid).then(function() { - console.info("chown successfully"); + console.info("chown succeed"); }).catch(function(err){ console.info("chown failed with error:"+ err); }); @@ -2299,7 +2303,7 @@ lchown(path: string, uid: number, gid: number): Promise<void> lchown(path: string, uid: number, gid: number, callback: AsyncCallback<void>): void -以异步方法基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是更改符号链接所指向的实际文件,使用callback形式返回结果。 +基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是更改符号链接所指向的实际文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2346,7 +2350,7 @@ lchownSync(path: string, uid: number, gid: number): void createWatcher(filename: string, events: number, callback: AsyncCallback<number>): Watcher -以异步方法监听文件或者目录的变化,使用callback形式返回结果。 +监听文件或者目录的变化,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2360,7 +2364,7 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe **返回值:** | 类型 | 说明 | | -------------------- | ---------- | - | [Watcher](#watcher7) | 文件变化监听的实例。 | + | [Watcher](#watcher7) | Promise对象。返回文件变化监听的实例。 | **示例:** ```js @@ -2549,7 +2553,7 @@ Watcher是文件变化监听的实例,调用Watcher.stop()方法(同步或 stop(): Promise<void> -以异步方法关闭watcher监听,使用promise形式返回结果。 +关闭watcher监听,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2563,7 +2567,7 @@ stop(): Promise<void> stop(callback: AsyncCallback<void>): void -以异步方法关闭watcher监听,使用callback形式返回结果。 +关闭watcher监听,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2589,20 +2593,20 @@ stop(callback: AsyncCallback<void>): void close(): Promise<void> -异步关闭文件流,使用promise形式返回结果。 +关闭文件流,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO **返回值:** | 类型 | 说明 | | ------------------- | ------------- | - | Promise<void> | 表示异步关闭文件流的结果。 | + | Promise<void> | Promise对象。返回表示异步关闭文件流的结果。 | **示例:** ```js let ss= fileio.createStreamSync(path); ss.close().then(function(){ - console.info("close fileStream successfully"); + console.info("close fileStream succeed"); }).catch(function(err){ console.info("close fileStream failed with error:"+ err); }); @@ -2613,7 +2617,7 @@ close(): Promise<void> close(callback: AsyncCallback<void>): void -异步关闭文件流,使用callback形式返回结果。 +异步关闭文件流,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2650,20 +2654,20 @@ closeSync(): void flush(): Promise<void> -异步刷新文件流,使用promise形式返回结果。 +刷新文件流,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO **返回值:** | 类型 | 说明 | | ------------------- | ------------- | - | Promise<void> | 表示异步刷新文件流的结果。 | + | Promise<void> | Promise对象。返回表示异步刷新文件流的结果。 | **示例:** ```js let ss= fileio.createStreamSync(path); ss.flush().then(function (){ - console.info("flush successfully"); + console.info("flush succeed"); }).catch(function(err){ console.info("flush failed with error:"+ err); }); @@ -2674,7 +2678,7 @@ flush(): Promise<void> flush(callback: AsyncCallback<void>): void -异步刷新文件流,使用callback形式返回结果。 +异步刷新文件流,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2716,7 +2720,7 @@ write(buffer: ArrayBuffer | string, options?: { encoding?: string; }): Promise<number> -以异步方法将数据写入流文件,使用promise形式返回结果。 +将数据写入流文件,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2729,13 +2733,13 @@ write(buffer: ArrayBuffer | string, options?: { **返回值:** | 类型 | 说明 | | --------------------- | -------- | - | Promise<number> | 实际写入的长度。 | + | Promise<number> | Promise对象。返回实际写入的长度。 | **示例:** ```js let ss= fileio.createStreamSync(fpath, "r+"); ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number){ - console.info("write successfully and size is:"+ number); + console.info("write succeed and size is:"+ number); }).catch(function(err){ console.info("write failed with error:"+ err); }); @@ -2751,7 +2755,7 @@ write(buffer: ArrayBuffer | string, options: { encoding?: string; }, callback: AsyncCallback<number>): void -以异步方法将数据写入流文件,使用callback形式返回结果。 +将数据写入流文件,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2768,7 +2772,7 @@ write(buffer: ArrayBuffer | string, options: { ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) { if (bytesWritten) { // do something - console.info("write successfully and size is:"+ bytesWritten); + console.info("write succeed and size is:"+ bytesWritten); } }); ``` @@ -2813,7 +2817,7 @@ read(buffer: ArrayBuffer, options?: { length?: number; }): Promise<ReadOut> -以异步方法从流文件读取数据,使用promise形式返回结果。 +从流文件读取数据,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2826,13 +2830,13 @@ read(buffer: ArrayBuffer, options?: { **返回值:** | 类型 | 说明 | | ---------------------------------- | ------ | - | Promise<[ReadOut](#readout)> | 读取的结果。 | + | Promise<[ReadOut](#readout)> | Promise对象。返回读取的结果。 | **示例:** ```js let ss = fileio.createStreamSync(fpath, "r+"); ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readout){ - console.info("read data successfully"); + console.info("read data succeed"); console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); }).catch(function(err){ console.info("read data failed with error:"+ err); @@ -2848,7 +2852,7 @@ read(buffer: ArrayBuffer, options: { length?: number; }, callback: AsyncCallback<ReadOut>): void -以异步方法从流文件读取数据,使用callback形式返回结果。 +从流文件读取数据,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2864,7 +2868,7 @@ read(buffer: ArrayBuffer, options: { let ss = fileio.createStreamSync(fpath, "r+"); ss.read(new ArrayBuffer(4096),{offset: 1, length: 5, position: 5},function (err, readOut) { if (readOut) { - console.info("read data successfully"); + console.info("read data succeed"); console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); } }); @@ -2912,20 +2916,20 @@ readSync(buffer: ArrayBuffer, options?: { read(): Promise<Dirent> -异步读取下一个目录项,使用promise形式返回结果。 +读取下一个目录项,使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO **返回值:** | 类型 | 说明 | | -------------------------------- | ------------- | - | Promise<[Dirent](#dirent)> | 表示异步读取目录项的结果。 | + | Promise<[Dirent](#dirent)> | Promise对象。返回表示异步读取目录项的结果。 | **示例:** ```js let dir = fileio.opendirSync(path); dir.read().then(function (dirent){ - console.log("read successfully:"+JSON.stringify(dirent)); + console.log("read succeed:"+JSON.stringify(dirent)); }).catch(function(err){ console.info("read failed with error:"+ err); }); @@ -2936,7 +2940,7 @@ read(): Promise<Dirent> read(callback: AsyncCallback<Dirent>): void -异步读取下一个目录项,使用callback形式返回结果。 +读取下一个目录项,使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.File.FileIO @@ -2951,7 +2955,7 @@ read(callback: AsyncCallback<Dirent>): void dir.read(function (err, dirent) { if (dirent) { // do something - console.log("read successfully:"+JSON.stringify(dirent)); + console.log("read succeed:"+JSON.stringify(dirent)); } }); ```