diff --git a/api/@ohos.file.environment.d.ts b/api/@ohos.file.environment.d.ts index 5d89e2c967fc799815049604852d2b59344036a2..cb5c78b0fd6a47e2f5d2dedc6d893ae01600dffb 100644 --- a/api/@ohos.file.environment.d.ts +++ b/api/@ohos.file.environment.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Huawei Device Co., Ltd. + * Copyright (C) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -25,7 +25,8 @@ import type { AsyncCallback } from './@ohos.base'; * * @namespace Environment * @syscap SystemCapability.FileManagement.File.Environment - * @since 11 + * @since arkts {'1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ declare namespace Environment { /** @@ -37,7 +38,8 @@ declare namespace Environment { * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.Environment * @systemapi - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function getStorageDataDir(): Promise; @@ -50,7 +52,8 @@ declare namespace Environment { * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.Environment * @systemapi - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function getStorageDataDir(callback: AsyncCallback): void; @@ -63,7 +66,8 @@ declare namespace Environment { * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.Environment * @systemapi - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function getUserDataDir(): Promise; @@ -76,7 +80,8 @@ declare namespace Environment { * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.Environment * @systemapi - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function getUserDataDir(callback: AsyncCallback): void; @@ -98,7 +103,8 @@ declare namespace Environment { * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 13900042 - Unknown error. * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain - * @since 12 + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ function getUserDownloadDir(): string; @@ -120,7 +126,8 @@ declare namespace Environment { * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 13900042 - Unknown error. * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain - * @since 12 + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ function getUserDesktopDir(): string; @@ -142,7 +149,8 @@ declare namespace Environment { * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 13900042 - Unknown error. * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain - * @since 12 + * @since arkts {'1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ function getUserDocumentDir(): string; @@ -157,7 +165,8 @@ declare namespace Environment { * @throws { BusinessError } 13900042 - Unknown error. * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain * @systemapi Hide this for inner system use. - * @since 11 + * @since arkts {'1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ function getExternalStorageDir(): string; @@ -172,7 +181,8 @@ declare namespace Environment { * @throws { BusinessError } 13900042 - Unknown error. * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain * @systemapi Hide this for inner system use. - * @since 11 + * @since arkts {'1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ function getUserHomeDir(): string; } diff --git a/api/@ohos.file.fs.d.ets b/api/@ohos.file.fs.d.ets index 13361e559a198e85850a36bb695e73e9823a5b33..730f6cc2f518dc6f7bce3ffebeecc227529aa05d 100644 --- a/api/@ohos.file.fs.d.ets +++ b/api/@ohos.file.fs.d.ets @@ -315,109 +315,126 @@ function close(file: number | File, callback: AsyncCallback): void; function closeSync(file: number | File): void; /** - * Copy file. + * Copy file or directory. * - * @param { string | number } src - src. - * @param { string | number } dest - dest. - * @param { number } [mode = 0] - mode. + * @param { string } srcUri - src uri. + * @param { string } destUri - dest uri. + * @param { CopyOptions } [options] - options. * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameter types. + * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory - * @throws { BusinessError } 13900012 - Permission denied - * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900012 - Permission denied by the file system + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900021 - File table overflow + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900031 - Function not implemented - * @throws { BusinessError } 13900033 - Too many symbolic links encountered * @throws { BusinessError } 13900034 - Operation would block * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function copyFile(src: string | number, dest: string | number, mode?: number): Promise; +function copy(srcUri: string, destUri: string, options?: CopyOptions): Promise; /** - * Copy file. + * Copy file or directory. * - * @param { string | number } src - src. - * @param { string | number } dest - dest. + * @param { string } srcUri - src uri. + * @param { string } destUri - dest uri. * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameter types. + * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory - * @throws { BusinessError } 13900012 - Permission denied - * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900012 - Permission denied by the file system + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900021 - File table overflow + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900031 - Function not implemented - * @throws { BusinessError } 13900033 - Too many symbolic links encountered * @throws { BusinessError } 13900034 - Operation would block * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function copyFile(src: string | number, dest: string | number, callback: AsyncCallback): void; +function copy(srcUri: string, destUri: string, callback: AsyncCallback): void; /** - * Copy file. + * Copy file or directory. * - * @param { string | number } src - src. - * @param { string | number } dest - dest. - * @param { number } [mode = 0] - mode. + * @param { string } srcUri - src uri. + * @param { string } destUri - dest uri. + * @param { CopyOptions } options - options. * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameter types. + * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory - * @throws { BusinessError } 13900012 - Permission denied - * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900012 - Permission denied by the file system + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900021 - File table overflow + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900031 - Function not implemented - * @throws { BusinessError } 13900033 - Too many symbolic links encountered * @throws { BusinessError } 13900034 - Operation would block * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function copyFile( - src: string | number, - dest: string | number, - mode: number, - callback: AsyncCallback -): void; +function copy(srcUri: string, destUri: string, options: CopyOptions, callback: AsyncCallback): void; /** - * Copy file with sync interface. + * Copy directory. * - * @param { string | number } src - src. - * @param { string | number } dest - dest. + * @param { string } src - source path. + * @param { string } dest - destination path. * @param { number } [mode = 0] - mode. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900005 - I/O error @@ -437,436 +454,599 @@ function copyFile( * @throws { BusinessError } 13900042 - Unknown error * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function copyFileSync(src: string | number, dest: string | number, mode?: number): void; +function copyDir(src: string, dest: string, mode?: number): Promise; /** - * List file. + * Copy directory. * - * @param { string } path - path. - * @param { ListFileOptions } [options] - options. - * @returns { Promise } Returns an Array containing the name of files or directories that meet the filter criteria. - * If present, Include the subdirectory structure. + * @param { string } src - source path. + * @param { string } dest - destination path. + * @param { AsyncCallback } callback - Return the callback function. * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function listFile( - path: string, - options?: ListFileOptions -): Promise; +function copyDir(src: string, dest: string, callback: AsyncCallback): void; /** - * List file. + * Copy directory. * - * @param { string } path - path. - * @param { AsyncCallback } callback - The callback is used to return an Array containing the name of files or directories - * that meet the filter criteria in promise mode. If present, Include the subdirectory structure. + * @param { string } src - source path. + * @param { string } dest - destination path. + * @param { number } mode - mode. + * @param { AsyncCallback } callback - Return the callback function. * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function listFile(path: string, callback: AsyncCallback): void; +function copyDir(src: string, dest: string, mode: number, callback: AsyncCallback): void; /** - * List file. + * Copy directory with sync interface. * - * @param { string } path - path. - * @param { ListFileOptions } [options] - options. - * @param { AsyncCallback } callback - The callback is used to return an Array containing the name of files or directories - * that meet the filter criteria in promise mode. If present, Include the subdirectory structure. + * @param { string } src - source path. + * @param { string } dest - destination path. + * @param { number } [mode = 0] - mode. * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function listFile( - path: string, - options: ListFileOptions, - callback: AsyncCallback -): void; +function copyDirSync(src: string, dest: string, mode?: number): void; /** - * List file with sync interface. + * Copy file. * - * @param { string } path - path. - * @param { ListFileOptions } [options] - options. - * @returns { string[] } Returns an Array containing the name of files or directories that meet the filter criteria. + * @param { string | number } src - src. + * @param { string | number } dest - dest. + * @param { number } [mode = 0] - mode. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function listFileSync( - path: string, - options?: ListFileOptions -): string[]; +function copyFile(src: string | number, dest: string | number, mode?: number): Promise; /** - * Make dir. + * Copy file. * - * @param { string } path - path. - * @returns { Promise } The promise returned by the function. - * @throws { BusinessError } 13900001 - Operation not permitted + * @param { string | number } src - src. + * @param { string | number } dest - dest. + * @param { AsyncCallback } callback - Return the callback function. * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function mkdir(path: string): Promise; +function copyFile(src: string | number, dest: string | number, callback: AsyncCallback): void; /** - * Make dir. + * Copy file. * - * @param { string } path - path. - * @param { boolean } recursion - whether to recursively make directory. - * @returns { Promise } The promise returned by the function. - * @throws { BusinessError } 13900001 - Operation not permitted + * @param { string | number } src - src. + * @param { string | number } dest - dest. + * @param { number } [mode = 0] - mode. + * @param { AsyncCallback } callback - Return the callback function. * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function mkdir(path: string, recursion: boolean): Promise; +function copyFile( + src: string | number, + dest: string | number, + mode: number, + callback: AsyncCallback +): void; /** - * Make dir. + * Copy file with sync interface. * - * @param { string } path - path. - * @param { AsyncCallback } callback - Return the callback function. - * @throws { BusinessError } 13900001 - Operation not permitted + * @param { string | number } src - src. + * @param { string | number } dest - dest. + * @param { number } [mode = 0] - mode. * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function mkdir(path: string, callback: AsyncCallback): void; +function copyFileSync(src: string | number, dest: string | number, mode?: number): void; /** - * Make dir. + * Create class Stream. * * @param { string } path - path. - * @param { boolean } recursion - whether to recursively make directory. - * @param { AsyncCallback } callback - Return the callback function. + * @param { string } mode - mode. + * @returns { Promise } return Promise * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900017 - No such device * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900029 - Resource deadlock would occur * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function mkdir(path: string, recursion: boolean, callback: AsyncCallback): void; +function createStream(path: string, mode: string): Promise; /** - * Make dir with sync interface. + * Create class Stream. * * @param { string } path - path. + * @param { string } mode - mode. + * @param { AsyncCallback } callback - callback. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900017 - No such device * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900029 - Resource deadlock would occur * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function mkdirSync(path: string): void; +function createStream(path: string, mode: string, callback: AsyncCallback): void; /** - * Make dir with sync interface. + * Create class Stream with sync interface. * * @param { string } path - path. - * @param { boolean } recursion - whether to recursively make directory. + * @param { string } mode - mode. + * @returns { Stream } createStream * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900017 - No such device * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900029 - Resource deadlock would occur * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function mkdirSync(path: string, recursion: boolean): void; - +function createStreamSync(path: string, mode: string): Stream; /** - * Move file. + * Create class RandomAccessFile. * - * @param { string } src - source file path. - * @param { string } dest - destination file path. - * @param { number } [mode = 0] - move mode when duplicate file name exists. - * @returns { Promise } The promise returned by the function. + * @param { string | File } file - file path, object. + * @param { number } [mode = OpenMode.READ_ONLY] - mode. + * @param { RandomAccessFileOptions } [options] - RandomAccessFile options + * @returns { Promise } Returns the RandomAccessFile object which has been created in promise mode. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900015 - File exists - * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900017 - No such device * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device * @throws { BusinessError } 13900027 - Read-only file system - * @throws { BusinessError } 13900028 - Too many links - * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900029 - Resource deadlock would occur + * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ -function moveFile(src: string, dest: string, mode?: number): Promise; +function createRandomAccessFile(file: string | File, mode?: number, + options?: RandomAccessFileOptions): Promise; /** - * Move file. + * Create class RandomAccessFile. * - * @param { string } src - source file path. - * @param { string } dest - destination file path. - * @param { AsyncCallback } callback - Return the callback function. + * @param { string | File } file - file path, object. + * @param { AsyncCallback } callback - The callback is used to return the RandomAccessFile object which has been created. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900015 - File exists - * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900017 - No such device * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device * @throws { BusinessError } 13900027 - Read-only file system - * @throws { BusinessError } 13900028 - Too many links - * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900029 - Resource deadlock would occur + * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ -function moveFile(src: string, dest: string, callback: AsyncCallback): void; +function createRandomAccessFile(file: string | File, callback: AsyncCallback): void; /** - * Move file. + * Create class RandomAccessFile. * - * @param { string } src - source file path. - * @param { string } dest - destination file path. - * @param { number } [mode = 0] - move mode when duplicate file name exists. - * @param { AsyncCallback } callback - Return the callback function. + * @param { string | File } file - file path, object. + * @param { number } [mode = OpenMode.READ_ONLY] - mode. + * @param { AsyncCallback } callback - The callback is used to return the RandomAccessFile object which has been created. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900015 - File exists - * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900017 - No such device * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device * @throws { BusinessError } 13900027 - Read-only file system - * @throws { BusinessError } 13900028 - Too many links - * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900029 - Resource deadlock would occur + * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ -function moveFile(src: string, dest: string, mode: number, callback: AsyncCallback): void; +function createRandomAccessFile(file: string | File, mode: number, callback: AsyncCallback): void; /** - * Move file with sync interface. + * Create class RandomAccessFile with sync interface. * - * @param { string } src - source file path. - * @param { string } dest - destination file path. - * @param { number } [mode = 0] - move mode when duplicate file name exists. + * @param { string | File } file - file path, object. + * @param { number } [mode = OpenMode.READ_ONLY] - mode. + * @param { RandomAccessFileOptions } [options] - RandomAccessFile options + * @returns { RandomAccessFile } Returns the RandomAccessFile object which has been created. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900015 - File exists - * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900017 - No such device * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device * @throws { BusinessError } 13900027 - Read-only file system - * @throws { BusinessError } 13900028 - Too many links - * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900029 - Resource deadlock would occur + * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ -function moveFileSync(src: string, dest: string, mode?: number): void; +function createRandomAccessFileSync(file: string | File, mode?: number, + options?: RandomAccessFileOptions): RandomAccessFile; /** - * Open file. + * Create watcher to listen for file changes. * * @param { string } path - path. - * @param { number } [mode = OpenMode.READ_ONLY] - mode. - * @returns { Promise } Returns the File object in Promise mode to record the file descriptor. - * @throws { BusinessError } 13900001 - Operation not permitted + * @param { number } events - listened events. + * @param { WatchEventListener } listener - Callback to invoke when an event of the specified type occurs. + * @returns { Watcher } Returns the Watcher object which has been created. * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900015 - File exists - * @throws { BusinessError } 13900017 - No such device * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900021 - File table overflow * @throws { BusinessError } 13900022 - Too many open files - * @throws { BusinessError } 13900023 - Text file busy - * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900027 - Read-only file system - * @throws { BusinessError } 13900029 - Resource deadlock would occur * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900034 - Operation would block - * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function createWatcher(path: string, events: number, listener: WatchEventListener): Watcher; + +/** + * Duplicate fd to File Object. + * + * @param { number } fd - fd. + * @returns { File } return File + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function dup(fd: number): File; + +/** + * Synchronize file metadata. + * + * @param { number } fd - fd. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform - * @atomicservice * @since 20 */ -function open(path: string, mode?: number): Promise; +function fdatasync(fd: number): Promise; /** - * Open file. + * Synchronize file metadata. * - * @param { string } path - path. - * @param { AsyncCallback } callback - The callback is used to return the File object to record the file descriptor. + * @param { number } fd - fd. + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ +function fdatasync(fd: number, callback: AsyncCallback): void; + +/** + * Synchronize file metadata with sync interface. + * + * @param { number } fd - fd. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ +function fdatasyncSync(fd: number): void; + +/** + * Create class Stream by using fd. + * + * @param { number } fd - fd. + * @param { string } mode - mode. + * @returns { Promise } Returns the Stream object in promise mode. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address @@ -889,23 +1069,22 @@ function open(path: string, mode?: number): Promise; * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function open(path: string, callback: AsyncCallback): void; +function fdopenStream(fd: number, mode: string): Promise; /** - * Open file. + * Create class Stream by using fd. * - * @param { string } path - path. - * @param { number } [mode = OpenMode.READ_ONLY] - mode. - * @param { AsyncCallback } callback - The callback is used to return the File object to record the file descriptor. + * @param { number } fd - fd. + * @param { string } mode - mode. + * @param { AsyncCallback } callback - The callback is used to return the Stream object. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address @@ -928,23 +1107,22 @@ function open(path: string, callback: AsyncCallback): void; * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function open(path: string, mode: number, callback: AsyncCallback): void; +function fdopenStream(fd: number, mode: string, callback: AsyncCallback): void; /** - * Open file with sync interface. + * Create class Stream by using fd with sync interface. * - * @param { string } path - path. - * @param { number } [mode = OpenMode.READ_ONLY] - mode. - * @returns { File } Returns the File object to record the file descriptor. + * @param { number } fd - fd. + * @param { string } mode - mode. + * @returns { Stream } Returns the Stream object. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900006 - No such device or address * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address @@ -966,827 +1144,2618 @@ function open(path: string, mode: number, callback: AsyncCallback): void; * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function openSync(path: string, mode?: number): File; +function fdopenStreamSync(fd: number, mode: string): Stream; /** - * Read file. + * Synchronize file. * - * @param { number } fd - file descriptor. - * @param { ArrayBuffer } buffer - buffer. - * @param { ReadOptions } [options] - options. - * @returns { Promise } Returns the number of file bytes read to buffer in promise mode. - * @throws { BusinessError } 13900004 - Interrupted system call + * @param { number } fd - fd. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform - * @atomicservice * @since 20 */ -function read( - fd: number, - buffer: ArrayBuffer, - options?: ReadOptions -): Promise; +function fsync(fd: number): Promise; /** - * Read file. + * Synchronize file. * - * @param { number } fd - file descriptor. - * @param { ArrayBuffer } buffer - buffer. - * @param { AsyncCallback } callback - The callback is used to return the number of file bytes read to buffer. - * @throws { BusinessError } 13900004 - Interrupted system call + * @param { number } fd - fd. + * @param { AsyncCallback } callback - Return the callback function. * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform - * @atomicservice * @since 20 */ -function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback): void; +function fsync(fd: number, callback: AsyncCallback): void; /** - * Read file. + * Synchronize file with sync interface. * - * @param { number } fd - file descriptor. - * @param { ArrayBuffer } buffer - buffer. - * @param { ReadOptions } [options] - options. - * @param { AsyncCallback } callback - The callback is used to return the number of file bytes read to buffer. - * @throws { BusinessError } 13900004 - Interrupted system call + * @param { number } fd - fd. * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform - * @atomicservice * @since 20 */ -function read( - fd: number, - buffer: ArrayBuffer, - options: ReadOptions, - callback: AsyncCallback -): void; +function fsyncSync(fd: number): void; /** - * Read file with sync interface. + * List file. * - * @param { number } fd - file descriptor. - * @param { ArrayBuffer } buffer - buffer. - * @param { ReadOptions } [options] - options. - * @returns { number } Returns the number of file bytes read to buffer. - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error + * @param { string } path - path. + * @param { ListFileOptions } [options] - options. + * @returns { Promise } Returns an Array containing the name of files or directories that meet the filter criteria. + * If present, Include the subdirectory structure. + * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900019 - Is a directory - * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function readSync( - fd: number, - buffer: ArrayBuffer, - options?: ReadOptions -): number; +function listFile( + path: string, + options?: ListFileOptions +): Promise; /** - * Read text. + * List file. * - * @param { string } filePath - file path. - * @param { ReadTextOptions } [options] - options. - * @returns { Promise } Returns the contents of the read file in promise mode. - * @throws { BusinessError } 13900001 - Operation not permitted - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error + * @param { string } path - path. + * @param { AsyncCallback } callback - The callback is used to return an Array containing the name of files or directories + * that meet the filter criteria in promise mode. If present, Include the subdirectory structure. + * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900019 - Is a directory - * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900024 - File too large - * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900034 - Operation would block - * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function readText( - filePath: string, - options?: ReadTextOptions -): Promise; +function listFile(path: string, callback: AsyncCallback): void; /** - * Read text. + * List file. * - * @param { string } filePath - file path. - * @param { AsyncCallback } callback - The callback is used to return the contents of the read file. - * @throws { BusinessError } 13900001 - Operation not permitted - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error + * @param { string } path - path. + * @param { ListFileOptions } [options] - options. + * @param { AsyncCallback } callback - The callback is used to return an Array containing the name of files or directories + * that meet the filter criteria in promise mode. If present, Include the subdirectory structure. + * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900019 - Is a directory - * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900024 - File too large - * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900034 - Operation would block - * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function readText(filePath: string, callback: AsyncCallback): void; +function listFile( + path: string, + options: ListFileOptions, + callback: AsyncCallback +): void; /** - * Read text. + * List file with sync interface. * - * @param { string } filePath - file path. - * @param { ReadTextOptions } [options] - options. - * @param { AsyncCallback } callback - The callback is used to return the contents of the read file. - * @throws { BusinessError } 13900001 - Operation not permitted - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error + * @param { string } path - path. + * @param { ListFileOptions } [options] - options. + * @returns { string[] } Returns an Array containing the name of files or directories that meet the filter criteria. + * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900019 - Is a directory - * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900024 - File too large - * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900034 - Operation would block - * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function readText( - filePath: string, - options: ReadTextOptions, - callback: AsyncCallback -): void; +function listFileSync( + path: string, + options?: ListFileOptions +): string[]; /** - * Read text with sync interface. + * Reposition file offset. * - * @param { string } filePath - file path. - * @param { ReadTextOptions } [options] - options. - * @returns { string } Returns the contents of the read file. - * @throws { BusinessError } 13900001 - Operation not permitted - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error + * @param { number } fd - file descriptor. + * @param { number } offset - file offset. + * @param { WhenceType } [whence = WhenceType.SEEK_SET] - directive whence. + * @returns { number } Returns the file offset relative to starting position of file. * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900024 - File too large - * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900034 - Operation would block - * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900026 - Illegal seek + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform - * @atomicservice * @since 20 */ -function readTextSync( - filePath: string, - options?: ReadTextOptions -): string; +function lseek(fd: number, offset: number, whence?: WhenceType): number; /** - * Delete dir. + * Stat link file. * * @param { string } path - path. - * @returns { Promise } The promise returned by the function. - * @throws { BusinessError } 13900001 - Operation not permitted + * @returns { Promise } Returns the Stat object in promise mode. * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900027 - Read-only file system1 * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function rmdir(path: string): Promise; +function lstat(path: string): Promise; /** - * Delete dir. + * Stat link file. * * @param { string } path - path. - * @param { AsyncCallback } callback - Return the callback function. - * @throws { BusinessError } 13900001 - Operation not permitted + * @param { AsyncCallback } callback - The callback is used to return the Stat object. * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900027 - Read-only file system1 * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function rmdir(path: string, callback: AsyncCallback): void; +function lstat(path: string, callback: AsyncCallback): void; /** - * Delete dir with sync interface. + * Stat link file with sync interface. * * @param { string } path - path. - * @throws { BusinessError } 13900001 - Operation not permitted + * @returns { Stat } Returns the Stat object. * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900014 - Device or resource busy * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900027 - Read-only file system1 * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function rmdirSync(path: string): void; +function lstatSync(path: string): Stat; /** - * Get file information. + * Make dir. * - * @param { string | number } file - path or file descriptor. - * @returns { Promise } Returns the Stat object in promise mode. + * @param { string } path - path. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900031 - Function not implemented * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function stat(file: string | number): Promise; +function mkdir(path: string): Promise; /** - * Get file information. + * Make dir. * - * @param { string | number } file - path or file descriptor. - * @param { AsyncCallback } callback - The callback is used to return the Stat object. + * @param { string } path - path. + * @param { boolean } recursion - whether to recursively make directory. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900031 - Function not implemented * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ -function stat(file: string | number, callback: AsyncCallback): void; +function mkdir(path: string, recursion: boolean): Promise; /** - * Get file information with sync interface. + * Make dir. * - * @param { string | number } file - path or file descriptor. - * @returns { Stat } Returns the Stat object. + * @param { string } path - path. + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900031 - Function not implemented * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function statSync(file: string | number): Stat; +function mkdir(path: string, callback: AsyncCallback): void; /** - * Truncate file. + * Make dir. * - * @param { string | number } file - path or file descriptor. - * @param { number } [len = 0] - len. - * @returns { Promise } The promise returned by the function. + * @param { string } path - path. + * @param { boolean } recursion - whether to recursively make directory. + * @param { AsyncCallback } callback - Return the callback function. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900023 - Text file busy - * @throws { BusinessError } 13900024 - File too large - * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ -function truncate(file: string | number, len?: number): Promise; +function mkdir(path: string, recursion: boolean, callback: AsyncCallback): void; /** - * Truncate file. + * Make dir with sync interface. * - * @param { string | number } file - path or file descriptor. - * @param { AsyncCallback } callback - Return the callback function. + * @param { string } path - path. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900023 - Text file busy - * @throws { BusinessError } 13900024 - File too large - * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform * @atomicservice * @since 20 */ -function truncate(file: string | number, callback: AsyncCallback): void; +function mkdirSync(path: string): void; /** - * Truncate file. + * Make dir with sync interface. * - * @param { string | number } file - path or file descriptor. - * @param { number } [len = 0] - len. - * @param { AsyncCallback } callback - Return the callback function. + * @param { string } path - path. + * @param { boolean } recursion - whether to recursively make directory. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900023 - Text file busy - * @throws { BusinessError } 13900024 - File too large - * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ -function truncate(file: string | number, len: number, callback: AsyncCallback): void; +function mkdirSync(path: string, recursion: boolean): void; /** - * Truncate file with sync interface. + * Make temp dir. * - * @param { string | number } file - path or file descriptor. - * @param { number } [len = 0] - len. + * @param { string } prefix - dir prefix. + * @returns { Promise } Returns the path to the new directory in promise mode. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900023 - Text file busy - * @throws { BusinessError } 13900024 - File too large - * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform - * @atomicservice * @since 20 */ -function truncateSync(file: string | number, len?: number): void; +function mkdtemp(prefix: string): Promise; /** - * Delete file. + * Make temp dir. * - * @param { string } path - path. - * @returns { Promise } The promise returned by the function. + * @param { string } prefix - dir prefix. + * @param { AsyncCallback } callback - The callback is used to return the path to the new directory. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform - * @atomicservice * @since 20 */ -function unlink(path: string): Promise; +function mkdtemp(prefix: string, callback: AsyncCallback): void; /** - * Delete file. + * Make temp dir with sync interface. * - * @param { string } path - path. - * @param { AsyncCallback } callback - Return the callback function. + * @param { string } prefix - dir prefix. + * @returns { string } Returns the path to the new directory. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900028 - Too many links * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform - * @atomicservice * @since 20 */ -function unlink(path: string, callback: AsyncCallback): void; +function mkdtempSync(prefix: string): string; /** - * Delete file with sync interface. + * Move directory. * - * @param { string } path - path. + * @param { string } src - source file path. + * @param { string } dest - destination file path. + * @param { number } [mode = 0] - move mode when duplicate file name exists. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor * @throws { BusinessError } 13900011 - Out of memory * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900016 - Cross-device link * @throws { BusinessError } 13900018 - Not a directory * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device * @throws { BusinessError } 13900027 - Read-only file system - * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function unlinkSync(path: string): void; +function moveDir(src: string, dest: string, mode?: number): Promise; /** - * Write file. + * Move directory. * - * @param { number } fd - file descriptor. - * @param { ArrayBuffer | string } buffer - buffer. - * @param { WriteOptions } [options] - options. - * @returns { Promise } Returns the number of bytes written to the file in promise mode. + * @param { string } src - source file path. + * @param { string } dest - destination file path. + * @param { AsyncCallback } callback - Return the callback function. * @throws { BusinessError } 13900001 - Operation not permitted - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function write( - fd: number, - buffer: ArrayBuffer | string, - options?: WriteOptions -): Promise; +function moveDir(src: string, dest: string, callback: AsyncCallback): void; /** - * Write file. + * Move directory. * - * @param { number } fd - file descriptor. - * @param { ArrayBuffer | string } buffer - buffer. - * @param { AsyncCallback } callback - The callback is used to return the number of bytes written to the file. + * @param { string } src - source file path. + * @param { string } dest - destination file path. + * @param { number } mode - move mode when duplicate file name exists. + * @param { AsyncCallback } callback - Return the callback function. * @throws { BusinessError } 13900001 - Operation not permitted - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function write(fd: number, buffer: ArrayBuffer | string, callback: AsyncCallback): void; +function moveDir(src: string, dest: string, mode: number, callback: AsyncCallback): void; /** - * Write file. + * Move directory with sync interface. * - * @param { number } fd - file descriptor. - * @param { ArrayBuffer | string } buffer - buffer. - * @param { WriteOptions } [options] - options. - * @param { AsyncCallback } callback - The callback is used to return the number of bytes written to the file. + * @param { string } src - source file path. + * @param { string } dest - destination file path. + * @param { number } [mode = 0] - move mode when duplicate file name exists. * @throws { BusinessError } 13900001 - Operation not permitted - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ -function write( - fd: number, - buffer: ArrayBuffer | string, - options: WriteOptions, - callback: AsyncCallback -): void; +function moveDirSync(src: string, dest: string, mode?: number): void; /** - * Write file with sync interface. + * Move file. * - * @param { number } fd - file descriptor. - * @param { ArrayBuffer | string } buffer - buffer. - * @param { WriteOptions } [options] - options. - * @returns { number } Returns the number of bytes written to the file. + * @param { string } src - source file path. + * @param { string } dest - destination file path. + * @param { number } [mode = 0] - move mode when duplicate file name exists. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 13900001 - Operation not permitted - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900002 - No such file or directory * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900024 - File too large * @throws { BusinessError } 13900025 - No space left on device - * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO * @crossplatform - * @atomicservice * @since 20 */ -function writeSync( - fd: number, - buffer: ArrayBuffer | string, - options?: WriteOptions -): number; +function moveFile(src: string, dest: string, mode?: number): Promise; /** - * File object. + * Move file. * - * @interface File - * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice - * @since 20 - */ -interface File { - + * @param { string } src - source file path. + * @param { string } dest - destination file path. + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ +function moveFile(src: string, dest: string, callback: AsyncCallback): void; + +/** + * Move file. + * + * @param { string } src - source file path. + * @param { string } dest - destination file path. + * @param { number } [mode = 0] - move mode when duplicate file name exists. + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ +function moveFile(src: string, dest: string, mode: number, callback: AsyncCallback): void; + +/** + * Move file with sync interface. + * + * @param { string } src - source file path. + * @param { string } dest - destination file path. + * @param { number } [mode = 0] - move mode when duplicate file name exists. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ +function moveFileSync(src: string, dest: string, mode?: number): void; + +/** + * Open file. + * + * @param { string } path - path. + * @param { number } [mode = OpenMode.READ_ONLY] - mode. + * @returns { Promise } Returns the File object in Promise mode to record the file descriptor. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900017 - No such device + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900029 - Resource deadlock would occur + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function open(path: string, mode?: number): Promise; + +/** + * Open file. + * + * @param { string } path - path. + * @param { AsyncCallback } callback - The callback is used to return the File object to record the file descriptor. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900017 - No such device + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900029 - Resource deadlock would occur + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function open(path: string, callback: AsyncCallback): void; + +/** + * Open file. + * + * @param { string } path - path. + * @param { number } [mode = OpenMode.READ_ONLY] - mode. + * @param { AsyncCallback } callback - The callback is used to return the File object to record the file descriptor. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900017 - No such device + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900029 - Resource deadlock would occur + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function open(path: string, mode: number, callback: AsyncCallback): void; + +/** + * Open file with sync interface. + * + * @param { string } path - path. + * @param { number } [mode = OpenMode.READ_ONLY] - mode. + * @returns { File } Returns the File object to record the file descriptor. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900017 - No such device + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900029 - Resource deadlock would occur + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function openSync(path: string, mode?: number): File; + +/** + * Read file. + * + * @param { number } fd - file descriptor. + * @param { ArrayBuffer } buffer - buffer. + * @param { ReadOptions } [options] - options. + * @returns { Promise } Returns the number of file bytes read to buffer in promise mode. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function read( + fd: number, + buffer: ArrayBuffer, + options?: ReadOptions +): Promise; + +/** + * Read file. + * + * @param { number } fd - file descriptor. + * @param { ArrayBuffer } buffer - buffer. + * @param { AsyncCallback } callback - The callback is used to return the number of file bytes read to buffer. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback): void; + +/** + * Read file. + * + * @param { number } fd - file descriptor. + * @param { ArrayBuffer } buffer - buffer. + * @param { ReadOptions } [options] - options. + * @param { AsyncCallback } callback - The callback is used to return the number of file bytes read to buffer. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function read( + fd: number, + buffer: ArrayBuffer, + options: ReadOptions, + callback: AsyncCallback +): void; + +/** + * Read file with sync interface. + * + * @param { number } fd - file descriptor. + * @param { ArrayBuffer } buffer - buffer. + * @param { ReadOptions } [options] - options. + * @returns { number } Returns the number of file bytes read to buffer. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function readSync( + fd: number, + buffer: ArrayBuffer, + options?: ReadOptions +): number; + +/** + * Read content line by line. + * + * @param { string } filePath - file path. + * @param { Options } [options] - optional parameters + * @returns { Promise } Returns the iterator object in promise mode. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function readLines(filePath: string, options?: Options): Promise; + +/** + * Read content line by line. + * + * @param { string } filePath - file path. + * @param { AsyncCallback } callback - The callback is used to return the iterator object. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function readLines(filePath: string, callback: AsyncCallback): void; + +/** + * Read content line by line. + * + * @param { string } filePath - file path. + * @param { Options } options - optional parameters + * @param { AsyncCallback } callback - The callback is used to return the iterator object. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function readLines(filePath: string, options: Options, callback: AsyncCallback): void; + +/** + * Read content line by line with sync interface. + * + * @param { string } filePath - file path. + * @param { Options } [options] - optional parameters + * @returns { ReaderIterator } Returns the iterator object. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function readLinesSync(filePath: string, options?: Options): ReaderIterator; + +/** + * Read text. + * + * @param { string } filePath - file path. + * @param { ReadTextOptions } [options] - options. + * @returns { Promise } Returns the contents of the read file in promise mode. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function readText( + filePath: string, + options?: ReadTextOptions +): Promise; + +/** + * Read text. + * + * @param { string } filePath - file path. + * @param { AsyncCallback } callback - The callback is used to return the contents of the read file. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function readText(filePath: string, callback: AsyncCallback): void; + +/** + * Read text. + * + * @param { string } filePath - file path. + * @param { ReadTextOptions } [options] - options. + * @param { AsyncCallback } callback - The callback is used to return the contents of the read file. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function readText( + filePath: string, + options: ReadTextOptions, + callback: AsyncCallback +): void; + +/** + * Read text with sync interface. + * + * @param { string } filePath - file path. + * @param { ReadTextOptions } [options] - options. + * @returns { string } Returns the contents of the read file. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function readTextSync( + filePath: string, + options?: ReadTextOptions +): string; + +/** + * Rename file. + * + * @param { string } oldPath - oldPath. + * @param { string } newPath - newPath. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function rename(oldPath: string, newPath: string): Promise; + +/** + * Rename file. + * + * @param { string } oldPath - oldPath. + * @param { string } newPath - newPath. + * @param { AsyncCallback } callback - Returns the callback function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function rename(oldPath: string, newPath: string, callback: AsyncCallback): void; + +/** + * Rename file with sync interface. + * + * @param { string } oldPath - oldPath. + * @param { string } newPath - newPath. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900016 - Cross-device link + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900028 - Too many links + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function renameSync(oldPath: string, newPath: string): void; + +/** + * Delete dir. + * + * @param { string } path - path. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900027 - Read-only file system1 + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function rmdir(path: string): Promise; + +/** + * Delete dir. + * + * @param { string } path - path. + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900027 - Read-only file system1 + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function rmdir(path: string, callback: AsyncCallback): void; + +/** + * Delete dir with sync interface. + * + * @param { string } path - path. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900027 - Read-only file system1 + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900032 - Directory not empty + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function rmdirSync(path: string): void; + +/** + * Get file information. + * + * @param { string | number } file - path or file descriptor. + * @returns { Promise } Returns the Stat object in promise mode. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function stat(file: string | number): Promise; + +/** + * Get file information. + * + * @param { string | number } file - path or file descriptor. + * @param { AsyncCallback } callback - The callback is used to return the Stat object. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function stat(file: string | number, callback: AsyncCallback): void; + +/** + * Get file information with sync interface. + * + * @param { string | number } file - path or file descriptor. + * @returns { Stat } Returns the Stat object. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function statSync(file: string | number): Stat; + +/** + * Link file. + * + * @param { string } target - target. + * @param { string } srcPath - srcPath. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function symlink(target: string, srcPath: string): Promise; + +/** + * Link file. + * + * @param { string } target - target. + * @param { string } srcPath - srcPath. + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function symlink(target: string, srcPath: string, callback: AsyncCallback): void; + +/** + * Link file with sync interface. + * + * @param { string } target - target. + * @param { string } srcPath - srcPath. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function symlinkSync(target: string, srcPath: string): void; + +/** + * Truncate file. + * + * @param { string | number } file - path or file descriptor. + * @param { number } [len = 0] - len. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function truncate(file: string | number, len?: number): Promise; + +/** + * Truncate file. + * + * @param { string | number } file - path or file descriptor. + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function truncate(file: string | number, callback: AsyncCallback): void; + +/** + * Truncate file. + * + * @param { string | number } file - path or file descriptor. + * @param { number } [len = 0] - len. + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function truncate(file: string | number, len: number, callback: AsyncCallback): void; + +/** + * Truncate file with sync interface. + * + * @param { string | number } file - path or file descriptor. + * @param { number } [len = 0] - len. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function truncateSync(file: string | number, len?: number): void; + +/** + * Delete file. + * + * @param { string } path - path. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function unlink(path: string): Promise; + +/** + * Delete file. + * + * @param { string } path - path. + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function unlink(path: string, callback: AsyncCallback): void; + +/** + * Delete file with sync interface. + * + * @param { string } path - path. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function unlinkSync(path: string): void; + +/** + * Change file mtime. + * + * @param { string } path - path. + * @param { number } mtime - last modification time + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ +function utimes(path: string, mtime: number): void; + +/** + * Write file. + * + * @param { number } fd - file descriptor. + * @param { ArrayBuffer | string } buffer - buffer. + * @param { WriteOptions } [options] - options. + * @returns { Promise } Returns the number of bytes written to the file in promise mode. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function write( + fd: number, + buffer: ArrayBuffer | string, + options?: WriteOptions +): Promise; + +/** + * Write file. + * + * @param { number } fd - file descriptor. + * @param { ArrayBuffer | string } buffer - buffer. + * @param { AsyncCallback } callback - The callback is used to return the number of bytes written to the file. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function write(fd: number, buffer: ArrayBuffer | string, callback: AsyncCallback): void; + +/** + * Write file. + * + * @param { number } fd - file descriptor. + * @param { ArrayBuffer | string } buffer - buffer. + * @param { WriteOptions } [options] - options. + * @param { AsyncCallback } callback - The callback is used to return the number of bytes written to the file. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function write( + fd: number, + buffer: ArrayBuffer | string, + options: WriteOptions, + callback: AsyncCallback +): void; + +/** + * Write file with sync interface. + * + * @param { number } fd - file descriptor. + * @param { ArrayBuffer | string } buffer - buffer. + * @param { WriteOptions } [options] - options. + * @returns { number } Returns the number of bytes written to the file. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +function writeSync( + fd: number, + buffer: ArrayBuffer | string, + options?: WriteOptions +): number; + +/** + * Connect Distributed File System. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param { string } networkId - The networkId of device. + * @param { DfsListeners } listeners - The listeners of Distributed File System. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameter types. + * @throws { BusinessError } 13900045 - Connection failed. + * @throws { BusinessError } 13900046 - Software caused connection abort. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function connectDfs(networkId: string, listeners: DfsListeners): Promise; + +/** + * Disconnect Distributed File System. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param { string } networkId - The networkId of device. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameter types. + * @throws { BusinessError } 13600004 - Unmount failed. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function disconnectDfs(networkId: string): Promise; + +/** + * Set extended attributes information of the file. + * + * @param { string } path - path. + * @param { string } key - the key of extended attribute. + * @param { string } value - the value of extended attribute. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameter types. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function setxattr(path: string, key: string, value: string): Promise; + +/** + * Set extended attributes information of the file. + * + * @param { string } path - path. + * @param { string } key - the key of extended attribute. + * @param { string } value - the value of extended attribute. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameter types. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + +function setxattrSync(path: string, key: string, value: string): void; + +/** + * Get extended attributes information of the file. + * + * @param { string } path - path. + * @param { string } key - the key of extended attribute. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameter types. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900007 - Arg list too long + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900037 - No data available + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function getxattr(path: string, key: string): Promise; + +/** + * Get extended attributes information of the file with sync interface. + * + * @param { string } path - path. + * @param { string } key - the key of extended attribute. + * @returns { string } Return the value of extended attribute. + * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified; + *
2.Incorrect parameter types. + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900007 - Arg list too long + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900037 - No data available + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +function getxattrSync(path: string, key: string): string; + +/** + * Progress data of copyFile + * + * @typedef Progress + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +interface Progress { + /** + * @type { number } + * @readonly + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly processedSize: number; + + /** + * @type { number } + * @readonly + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly totalSize: number; +} + +/** + * Task signal. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +class TaskSignal { + /** + * Cancel the copy task in progress. + * + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900012 - Permission denied by the file system + * @throws { BusinessError } 13900043 - No task can be canceled. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + cancel(): void; + + /** + * Subscribe the cancel event of current task. + * + * @returns { Promise } Return the result of the cancel event. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + onCancel(): Promise; +} + +/** + * Get options of copy + * + * @typedef CopyOptions + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +interface CopyOptions { + /** + * Listener of copy progress + * + * @type { ?ProgressListener } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + progressListener?: ProgressListener; + /** + * Cancel signal of copy. + * + * @type { ?TaskSignal } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + copySignal?: TaskSignal; +} + +/** + * Listener of copy progress. + * + * @typedef { function } ProgressListener + * @param { Progress } progress - indicates the progress data of copyFile + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +type ProgressListener = (progress: Progress) => void; + +/** + * File object. + * + * @interface File + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ +interface File { + + /** + * @type { number } + * @readonly + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ + readonly fd: number; + + /** + * File path + * + * @type { string } + * @readonly + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 14300002 - Invalid URI + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly path: string; + + /** + * File name + * + * @type { string } + * @readonly + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly name: string; + + /** + * Get parent path of file. + * + * @returns { string } Return the parent path of file. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 14300002 - Invalid URI + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + getParent(): string; + + /** + * Lock file with blocking method. + * + * @param { boolean } exclusive - whether lock is exclusive. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900043 - No record locks available + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + lock(exclusive?: boolean): Promise; + + /** + * Lock file with blocking method. + * + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900043 - No record locks available + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + lock(callback: AsyncCallback): void; + + /** + * Lock file with blocking method. + * + * @param { boolean } exclusive - whether lock is exclusive. + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900043 - No record locks available + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + lock(exclusive: boolean, callback: AsyncCallback): void; + + /** + * Try to lock file with returning results immediately. + * + * @param { boolean } exclusive - whether lock is exclusive. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900043 - No record locks available + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + tryLock(exclusive?: boolean): void; + + /** + * Unlock file. + * + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900043 - No record locks available + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + unlock(): void; +} + +/** + * RandomAccessFile object. + * + * @interface RandomAccessFile + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +interface RandomAccessFile { + /** + * File descriptor + * * @type { number } * @readonly * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ readonly fd: number; /** - * File path - * - * @type { string } + * File pointer + * + * @type { number } * @readonly + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly filePointer: number; + + /** + * Set file pointer. + * + * @param { number } filePointer - filePointer. + * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900020 - Invalid argument * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 14300002 - Invalid URI * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ - readonly path: string; + setFilePointer(filePointer: number): void; /** - * File name - * - * @type { string } - * @readonly + * Close randomAccessFile with sync interface. + * + * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ - readonly name: string; + close(): void; /** - * Get parent path of file. + * Write randomAccessFile. * - * @returns { string } Return the parent path of file. + * @param { ArrayBuffer | string } buffer - buffer. + * @param { WriteOptions } [options] - options. + * @returns { Promise } Returns the number of bytes written to the file in promise mode. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 14300002 - Invalid URI * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ - getParent(): string; + write( + buffer: ArrayBuffer | string, + options?: WriteOptions + ): Promise; /** - * Lock file with blocking method. + * Write randomAccessFile. * - * @param { boolean } exclusive - whether lock is exclusive. - * @returns { Promise } The promise returned by the function. + * @param { ArrayBuffer | string } buffer - buffer. + * @param { AsyncCallback } callback - The callback is used to return the number of bytes written to the file. + * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900043 - No record locks available * @syscap SystemCapability.FileManagement.File.FileIO * @since 20 */ - lock(exclusive?: boolean): Promise; + write(buffer: ArrayBuffer | string, callback: AsyncCallback): void; /** - * Lock file with blocking method. + * Write randomAccessFile. * - * @param { AsyncCallback } callback - Return the callback function. + * @param { ArrayBuffer | string } buffer - buffer. + * @param { WriteOptions } [options] - options. + * @param { AsyncCallback } callback - The callback is used to return the number of bytes written to the file. + * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900043 - No record locks available * @syscap SystemCapability.FileManagement.File.FileIO * @since 20 */ - lock(callback: AsyncCallback): void; + write( + buffer: ArrayBuffer | string, + options: WriteOptions, + callback: AsyncCallback + ): void; /** - * Lock file with blocking method. + * Write randomAccessFile with sync interface. * - * @param { boolean } exclusive - whether lock is exclusive. - * @param { AsyncCallback } callback - Return the callback function. + * @param { ArrayBuffer | string } buffer - buffer. + * @param { WriteOptions } [options] - options. + * @returns { number } Returns the number of bytes written to the file. + * @throws { BusinessError } 13900001 - Operation not permitted * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900043 - No record locks available * @syscap SystemCapability.FileManagement.File.FileIO * @since 20 */ - lock(exclusive: boolean, callback: AsyncCallback): void; + writeSync( + buffer: ArrayBuffer | string, + options?: WriteOptions + ): number; + + /** + * Read randomAccessFile. + * + * @param { ArrayBuffer } buffer - buffer. + * @param { ReadOptions } [options] - options. + * @returns { Promise } Returns the number of file bytes read to buffer in promise mode. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + read( + buffer: ArrayBuffer, + options?: ReadOptions + ): Promise; + + /** + * Read randomAccessFile. + * + * @param { ArrayBuffer } buffer - buffer. + * @param { AsyncCallback } callback - The callback is used to return the number of file bytes read to buffer. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + read(buffer: ArrayBuffer, callback: AsyncCallback): void; + + /** + * Read randomAccessFile. + * + * @param { ArrayBuffer } buffer - buffer. + * @param { ReadOptions } [options] - options. + * @param { AsyncCallback } callback - The callback is used to return the number of file bytes read to buffer. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + read( + buffer: ArrayBuffer, + options: ReadOptions, + callback: AsyncCallback + ): void; + + /** + * Read randomAccessFile with sync interface. + * + * @param { ArrayBuffer } buffer - buffer. + * @param { ReadOptions } [options] - options. + * @returns { number } Returns the number of file bytes read to buffer. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readSync( + buffer: ArrayBuffer, + options?: ReadOptions + ): number; +} + +/** + * File Read Stream. + * + * @extends stream.Readable + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +class ReadStream extends stream.Readable { + /** + * The ReadStream constructor. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + constructor(); + + /** + * The Number of bytes read in the stream. + * + * @type { number } + * @readonly + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly bytesRead: number; + + /** + * The path of the file being read. + * + * @type { string } + * @readonly + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly path: string; + + /** + * Set the file position indicator for the read stream. + * + * @param { number } offset - file offset. + * @param { WhenceType } [whence = WhenceType.SEEK_SET] - directive whence. + * @returns { number } Returns the offset relative to starting position of stream. + * @throws { BusinessError } 401 - Parameter error + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900026 - Illegal seek + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + seek(offset: number, whence?: WhenceType): number; + + /** + * Close ReadStream with sync interface. + * + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + close(): void; +} + +/** + * File Write Stream. + * + * @extends stream.Writable + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +class WriteStream extends stream.Writable { + /** + * The WriteStream constructor. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + constructor(); + + /** + * The Number of bytes written in the stream. + * + * @type { number } + * @readonly + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly bytesWritten: number; + + /** + * The path of the file being written. + * + * @type { string } + * @readonly + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly path: string; + + /** + * Set the file position indicator for the write stream. + * + * @param { number } offset - file offset. + * @param { WhenceType } [whence = WhenceType.SEEK_SET] - directive whence. + * @returns { number } Returns the offset relative to starting position of stream. + * @throws { BusinessError } 401 - Parameter error + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900026 - Illegal seek + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + seek(offset: number, whence?: WhenceType): number; + + /** + * Close WriteStream with sync interface. + * + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + close(): void; +} + +/** + * The AtomicFile class provides methods for performing atomic operations on files. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +export class AtomicFile { + /** + * The AtomicFile constructor. + * @param { string } path file path. + * @throws { BusinessError } 401 Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + constructor(path: string); + + /** + * Get the File object from AtomicFile object. + * @returns { File } Returns the file object. + * @throws { BusinessError } 13900002 No such file or directory + * @throws { BusinessError } 13900005 IO error + * @throws { BusinessError } 13900012 Permission denied + * @throws { BusinessError } 13900042 Internal error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + getBaseFile(): File; + + /** + * Read the entire contents of the file. + * @returns { ArrayBuffer } Returns the ArrayBuffer of the file contents. + * @throws { BusinessError } 13900005 I/O error + * @throws { BusinessError } 13900042 Internal error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readFully(): ArrayBuffer; + + /** + * If the file is written successfully, the file is closed. + * @throws { BusinessError } 13900042 Internal error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + finishWrite(): void; /** - * Try to lock file with returning results immediately. - * - * @param { boolean } exclusive - whether lock is exclusive. - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900034 - Operation would block - * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900043 - No record locks available + * If writing to the file fails, the file is rolled back. + * @throws { BusinessError } 13900042 Internal error * @syscap SystemCapability.FileManagement.File.FileIO * @since 20 */ - tryLock(exclusive?: boolean): void; + failWrite(): void; /** - * Unlock file. - * - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900020 - Invalid argument - * @throws { BusinessError } 13900034 - Operation would block - * @throws { BusinessError } 13900042 - Unknown error - * @throws { BusinessError } 13900043 - No record locks available + * Delete all file. + * @throws { BusinessError } 13900001 Operation not permitted + * @throws { BusinessError } 13900002 No such file or directory + * @throws { BusinessError } 13900012 Permission denied + * @throws { BusinessError } 13900027 Read-only file system + * @throws { BusinessError } 13900042 Internal error * @syscap SystemCapability.FileManagement.File.FileIO * @since 20 */ - unlock(): void; + delete(): void; } /** @@ -1932,96 +3901,486 @@ interface Stat { * @syscap SystemCapability.FileManagement.File.FileIO * @since 20 */ - readonly location: LocationType; + readonly location: LocationType; + + /** + * Whether path/fd is block device. + * + * @returns { boolean } Returns whether the path/fd point to a block device or not. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ + isBlockDevice(): boolean; + + /** + * Whether path/fd is character device. + * + * @returns { boolean } Returns whether the path/fd point to a character device or not. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ + isCharacterDevice(): boolean; + + /** + * Whether path/fd is directory. + * + * @returns { boolean } Returns whether the path/fd point to a directory or not. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ + isDirectory(): boolean; + + /** + * Whether path/fd is fifo. + * + * @returns { boolean } Returns whether the path/fd point to a fifo file or not. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ + isFIFO(): boolean; + + /** + * Whether path/fd is file. + * + * @returns { boolean } Returns whether the path/fd point to a normal file or not. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @atomicservice + * @since 20 + */ + isFile(): boolean; + + /** + * Whether path/fd is socket. + * + * @returns { boolean } Returns whether the path/fd point to a socket file or not. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ + isSocket(): boolean; + + /** + * Whether path/fd is symbolic link. + * + * @returns { boolean } Returns whether the path/fd point to a symbolic link or not. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @crossplatform + * @since 20 + */ + isSymbolicLink(): boolean; +} + +/** + * Stream object + * + * @interface Stream + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +interface Stream { + /** + * Close stream. + * + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + close(): Promise; + + /** + * Close stream. + * + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + close(callback: AsyncCallback): void; + + /** + * Close stream with sync interface. + * + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + closeSync(): void; + + /** + * Flush stream. + * + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + flush(): Promise; + + /** + * Flush stream. + * + * @param { AsyncCallback } callback - Return the callback function. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + flush(callback: AsyncCallback): void; + + /** + * Flush stream with sync interface. + * + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + flushSync(): void; + + /** + * Write stream. + * + * @param { ArrayBuffer | string } buffer - buffer. + * @param { WriteOptions } [options] - options. + * @returns { Promise } Returns the number of file bytes written to file in promise mode. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + write( + buffer: ArrayBuffer | string, + options?: WriteOptions + ): Promise; + + /** + * Write stream. + * + * @param { ArrayBuffer | string } buffer - buffer. + * @param { AsyncCallback } callback - The callback is used to return the number of file bytes written to file. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + write(buffer: ArrayBuffer | string, callback: AsyncCallback): void; + + /** + * Write stream. + * + * @param { ArrayBuffer | string } buffer - buffer. + * @param { WriteOptions } [options] - options. + * @param { AsyncCallback } callback - The callback is used to return the number of file bytes written to file. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + write( + buffer: ArrayBuffer | string, + options: WriteOptions, + callback: AsyncCallback + ): void; + + /** + * Write stream with sync interface. + * + * @param { ArrayBuffer | string } buffer - buffer. + * @param { WriteOptions } [options] - options. + * @returns { number } Returns the number of file bytes written to file. + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + writeSync( + buffer: ArrayBuffer | string, + options?: WriteOptions + ): number; + + /** + * Read stream. + * + * @param { ArrayBuffer } buffer - buffer. + * @param { ReadOptions } [options] - options. + * @returns { Promise } Returns the number of file bytes read to buffer in promise mode. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + read( + buffer: ArrayBuffer, + options?: ReadOptions + ): Promise; + + /** + * Read stream. + * + * @param { ArrayBuffer } buffer - buffer. + * @param { AsyncCallback } callback - The callback is used to return the number of file bytes read to buffer. + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + read(buffer: ArrayBuffer, callback: AsyncCallback): void; /** - * Whether path/fd is block device. + * Read stream. * - * @returns { boolean } Returns whether the path/fd point to a block device or not. + * @param { ArrayBuffer } buffer - buffer. + * @param { ReadOptions } [options] - options. + * @param { AsyncCallback } callback - The callback is used to return the number of file bytes read to buffer. + * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ - isBlockDevice(): boolean; + read( + buffer: ArrayBuffer, + options: ReadOptions, + callback: AsyncCallback + ): void; /** - * Whether path/fd is character device. + * Read stream with sync interface. * - * @returns { boolean } Returns whether the path/fd point to a character device or not. + * @param { ArrayBuffer } buffer - buffer. + * @param { ReadOptions } [options] - options. + * @returns { number } Returns the number of file bytes read to file. + * @throws { BusinessError } 13900004 - Interrupted system call * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block * @throws { BusinessError } 13900042 - Unknown error + * @throws { BusinessError } 13900044 - Network is unreachable * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ - isCharacterDevice(): boolean; + readSync( + buffer: ArrayBuffer, + options?: ReadOptions + ): number; +} +/** + * Watcher object + * + * @interface Watcher + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +interface Watcher { /** - * Whether path/fd is directory. + * Start watcher. * - * @returns { boolean } Returns whether the path/fd point to a directory or not. - * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900021 - File table overflow + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ - isDirectory(): boolean; + start(): void; /** - * Whether path/fd is fifo. + * Stop watcher. * - * @returns { boolean } Returns whether the path/fd point to a fifo file or not. - * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900021 - File table overflow + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900030 - File name too long * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ - isFIFO(): boolean; + stop(): void; +} +/** + * Enumeration of different types of whence. + * + * @enum { number } whence type + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +enum WhenceType { /** - * Whether path/fd is file. + * Starting position of the file offset. * - * @returns { boolean } Returns whether the path/fd point to a normal file or not. - * @throws { BusinessError } 13900005 - I/O error - * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @atomicservice * @since 20 */ - isFile(): boolean; + SEEK_SET = 0, /** - * Whether path/fd is socket. + * Current position of the file offset. * - * @returns { boolean } Returns whether the path/fd point to a socket file or not. - * @throws { BusinessError } 13900005 - I/O error - * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ - isSocket(): boolean; + SEEK_CUR = 1, /** - * Whether path/fd is symbolic link. + * Ending position of the file offset. * - * @returns { boolean } Returns whether the path/fd point to a symbolic link or not. - * @throws { BusinessError } 13900005 - I/O error - * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ - isSymbolicLink(): boolean; + SEEK_END = 2, } - /** * Enumeration of different types of file location. * @@ -2052,7 +4411,6 @@ enum LocationType { * * @enum { number } access mode type * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2061,7 +4419,6 @@ enum AccessModeType { * Check if the file exists. * * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2071,7 +4428,6 @@ enum AccessModeType { * Check if the file has write permission. * * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2081,7 +4437,6 @@ enum AccessModeType { * Check if the file has read permission. * * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2091,7 +4446,6 @@ enum AccessModeType { * Check if the file has read and write permission. * * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2115,6 +4469,103 @@ enum AccessFlagType { LOCAL = 0, } +/** + * ReaderIterator object + * + * @interface ReaderIterator + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +interface ReaderIterator { + /** + * Get next result from the iterator. + * + * @returns { ReaderIteratorResult } Returns the result of reader iterator. + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900037 - No data available + * @throws { BusinessError } 13900042 - Unknown error + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + next(): ReaderIteratorResult; +} + +} + +/** + * Implements watcher event listening. + * + * @typedef { function } WatchEventListener + * @param { WatchEvent } event - Event type for the callback to invoke. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +export type WatchEventListener = (event: WatchEvent) => void; + +/** + * Event Listening. + * + * @interface WatchEvent + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +export interface WatchEvent { + /** + * File name. + * + * @type { string } + * @readonly + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly fileName: string; + + /** + * Event happened. + * + * @type { number } + * @readonly + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly event: number; + + /** + * Associated rename event. + * + * @type { number } + * @readonly + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + readonly cookie: number; +} + +/** + * Reader Iterator Result + * + * @interface ReaderIteratorResult + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +export interface ReaderIteratorResult { + /** + * Whether reader iterator completes the traversal. + * + * @type { boolean } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + done: boolean; + + /** + * The value of reader iterator. + * + * @type { string } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + value: string; } /** @@ -2195,12 +4646,39 @@ export interface Filter { excludeMedia?: boolean; } +/** + * Conflict Files type + * + * @interface ConflictFiles + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +export interface ConflictFiles { + + /** + * The path of the source file. + * + * @type { string } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + srcFile: string; + + /** + * The path of the destination file. + * + * @type { string } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + destFile: string; +} + /** * Options type * * @interface Options * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ export interface Options { @@ -2209,7 +4687,6 @@ export interface Options { * * @type { ?string } * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @since 20 */ encoding?: string; @@ -2220,7 +4697,6 @@ export interface Options { * * @interface ReadOptions * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2230,7 +4706,6 @@ export interface ReadOptions { * * @type { ?number } * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2240,7 +4715,6 @@ export interface ReadOptions { * * @type { ?number } * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2253,7 +4727,6 @@ export interface ReadOptions { * @extends ReadOptions * @interface ReadTextOptions * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2263,7 +4736,6 @@ export interface ReadTextOptions extends ReadOptions { * * @type { ?string } * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2276,7 +4748,6 @@ export interface ReadTextOptions extends ReadOptions { * @extends Options * @interface WriteOptions * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2286,7 +4757,6 @@ export interface WriteOptions extends Options { * * @type { ?number } * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2296,7 +4766,6 @@ export interface WriteOptions extends Options { * * @type { ?number } * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform * @atomicservice * @since 20 */ @@ -2343,4 +4812,128 @@ export interface ListFileOptions { filter?: Filter; } +/** + * RandomAccessFileOptions type + * + * @interface RandomAccessFileOptions + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +export interface RandomAccessFileOptions { + /** + * The starting position of file offset. + * + * @type { ?number } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + start?: number; + + /** + * The ending position of file offset. + * + * @type { ?number } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + end?: number; +} + +/** + * ReadStreamOptions type + * + * @interface ReadStreamOptions + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +export interface ReadStreamOptions { + /** + * The starting range for reading a file by stream. + * + * @type { ?number } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + start?: number; + + /** + * The ending range for reading a file by stream. + * + * @type { ?number } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + end?: number; +} + +/** + * WriteStreamOptions type + * + * @interface WriteStreamOptions + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +export interface WriteStreamOptions { + /** + * The mode for creating write stream. + * + * @type { ?number } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + mode?: number; + /** + * The starting range for writing a file by stream. + * + * @type { ?number } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + start?: number; +} + +/** + * The listeners of Distributed File System. + * + * @typedef DfsListeners + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +export interface DfsListeners { + /** + * The Listener of Distributed File System status + * + * @param { string } networkId - The networkId of device. + * @param { number } status - The status code of Distributed File System. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ + onStatus(networkId: string, status: number): void; +} + +/** + * Task signal. + * @typedef { fileIo.TaskSignal } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +type TaskSignal = fileIo.TaskSignal; + +/** + * Watcher object + * @typedef { fileIo.Watcher } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +type Watcher = fileIo.Watcher; + +/** + * Watcher object + * @typedef { fileIo.AtomicFile } + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 20 + */ +type AtomicFile = fileIo.AtomicFile; + export default fileIo; +export {TaskSignal, Watcher, AtomicFile} diff --git a/api/@ohos.file.statvfs.d.ts b/api/@ohos.file.statvfs.d.ts index 870676443a1bb0be163bd94503ef369f5695de6f..6d88557ebe877c69c01b49e944fccf725064f58a 100644 --- a/api/@ohos.file.statvfs.d.ts +++ b/api/@ohos.file.statvfs.d.ts @@ -25,15 +25,8 @@ import type { AsyncCallback } from './@ohos.base'; * * @namespace statfs * @syscap SystemCapability.FileManagement.File.FileIO - * @since 9 - */ -/** - * Provides filesystem statistics APIs - * - * @namespace statfs - * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @since 20 + * @since arkts {'1.1':'9', '1.2':'20'} + * @arkts 1.1&1.2 */ declare namespace statfs { /** @@ -55,29 +48,8 @@ declare namespace statfs { * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @since 9 - */ - /** - * Get the number of free bytes on the specified path. - * - * @param { string } path - path - * @returns { Promise } return Promise - * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error - * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900011 - Out of memory - * @throws { BusinessError } 13900012 - Permission denied - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900031 - Function not implemented - * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900038 - Value too large for defined data type - * @throws { BusinessError } 13900042 - Unknown error - * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @since 20 + * @since arkts {'1.1':'9', '1.2':'20'} + * @arkts 1.1&1.2 */ function getFreeSize(path: string): Promise; @@ -100,29 +72,8 @@ declare namespace statfs { * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @since 9 - */ - /** - * Get the number of free bytes on the specified path. - * - * @param { string } path - path - * @param { AsyncCallback } [callback] - callback - * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error - * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900011 - Out of memory - * @throws { BusinessError } 13900012 - Permission denied - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900031 - Function not implemented - * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900038 - Value too large for defined data type - * @throws { BusinessError } 13900042 - Unknown error - * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @since 20 + * @since arkts {'1.1':'9', '1.2':'20'} + * @arkts 1.1&1.2 */ function getFreeSize(path: string, callback: AsyncCallback): void; @@ -145,29 +96,8 @@ declare namespace statfs { * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @since 10 - */ - /** - * Get the number of free bytes on the specified path with sync interface. - * - * @param { string } path - path - * @returns { number } return the number of free bytes on the specified path - * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error - * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900011 - Out of memory - * @throws { BusinessError } 13900012 - Permission denied - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900031 - Function not implemented - * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900038 - Value too large for defined data type - * @throws { BusinessError } 13900042 - Unknown error - * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @since 20 + * @since arkts {'1.1':'10', '1.2':'20'} + * @arkts 1.1&1.2 */ function getFreeSizeSync(path: string): number; @@ -190,29 +120,8 @@ declare namespace statfs { * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @since 9 - */ - /** - * Get the number of total bytes on the specified path. - * - * @param { string } path - path - * @returns { Promise } return Promise - * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error - * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900011 - Out of memory - * @throws { BusinessError } 13900012 - Permission denied - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900031 - Function not implemented - * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900038 - Value too large for defined data type - * @throws { BusinessError } 13900042 - Unknown error - * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @since 20 + * @since arkts {'1.1':'9', '1.2':'20'} + * @arkts 1.1&1.2 */ function getTotalSize(path: string): Promise; @@ -235,29 +144,8 @@ declare namespace statfs { * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @since 9 - */ - /** - * Get the number of total bytes on the specified path. - * - * @param { string } path - path - * @param { AsyncCallback } [callback] - callback - * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error - * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900011 - Out of memory - * @throws { BusinessError } 13900012 - Permission denied - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900031 - Function not implemented - * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900038 - Value too large for defined data type - * @throws { BusinessError } 13900042 - Unknown error - * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @since 20 + * @since arkts {'1.1':'9', '1.2':'20'} + * @arkts 1.1&1.2 */ function getTotalSize(path: string, callback: AsyncCallback): void; @@ -280,29 +168,8 @@ declare namespace statfs { * @throws { BusinessError } 13900038 - Value too large for defined data type * @throws { BusinessError } 13900042 - Unknown error * @syscap SystemCapability.FileManagement.File.FileIO - * @since 10 - */ - /** - * Get the number of total bytes on the specified path with sync interface. - * - * @param { string } path - path - * @returns { number } return the number of total bytes - * @throws { BusinessError } 13900002 - No such file or directory - * @throws { BusinessError } 13900004 - Interrupted system call - * @throws { BusinessError } 13900005 - I/O error - * @throws { BusinessError } 13900008 - Bad file descriptor - * @throws { BusinessError } 13900011 - Out of memory - * @throws { BusinessError } 13900012 - Permission denied - * @throws { BusinessError } 13900013 - Bad address - * @throws { BusinessError } 13900018 - Not a directory - * @throws { BusinessError } 13900030 - File name too long - * @throws { BusinessError } 13900031 - Function not implemented - * @throws { BusinessError } 13900033 - Too many symbolic links encountered - * @throws { BusinessError } 13900038 - Value too large for defined data type - * @throws { BusinessError } 13900042 - Unknown error - * @syscap SystemCapability.FileManagement.File.FileIO - * @crossplatform - * @since 20 + * @since arkts {'1.1':'10', '1.2':'20'} + * @arkts 1.1&1.2 */ function getTotalSizeSync(path: string): number; } diff --git a/build-tools/package-lock.json b/build-tools/package-lock.json index 516ab7e28b6ab25777655be86fdd9260ba727a28..aeb4e8fbe8e7636c036cdbe87190606ee5d8813e 100644 --- a/build-tools/package-lock.json +++ b/build-tools/package-lock.json @@ -4,6 +4,11 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "commander": { + "version": "13.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/commander/-/commander-13.1.0.tgz", + "integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==" + }, "fs": { "version": "0.0.1-security", "resolved": "https://repo.huaweicloud.com/repository/npm/fs/-/fs-0.0.1-security.tgz", @@ -34,11 +39,11 @@ "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==" }, "typescript": { - "version": "npm:ohos-typescript@4.2.3-r5", - "resolved": "https://repo.huaweicloud.com/repository/npm/ohos-typescript/-/ohos-typescript-4.2.3-r5.tgz", - "integrity": "sha512-9l72RIvrz8RMpU8j1uK7cIL5/gpNR11nelIFOmMDDOA3LJf70NlMgVIXOIg7MjCgjPb+U9PDwYBpalvb+rd2LA==", + "version": "npm:ohos-typescript@4.9.5-r5", + "resolved": "https://repo.huaweicloud.com/repository/npm/ohos-typescript/-/ohos-typescript-4.9.5-r5.tgz", + "integrity": "sha512-jaavgk6VJBs/Dwllj6y97+b4ve3CZPjl7uWAOqTsGM+2uaA6XIxxVgZZJdo811bccKhDkjvuqkUcHfSDidV8gw==", "requires": { - "json5": "^2.2.3" + "json5": "2.2.3" } }, "util": {