/* * Copyright (c) 2022-2023 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type { AsyncCallback, Callback } from './@ohos.base'; import Want from './@ohos.app.ability.Want'; import Context from './application/Context'; import { Filter } from './@ohos.file.fs'; /** * This module provides the capability to access user public files. * * @namespace fileAccess * @syscap SystemCapability.FileManagement.UserFileService * @since 9 */ declare namespace fileAccess { /** * Query the want information of HAP configured with fileaccess. * * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @param { AsyncCallback> } callback - The callback is used to return a Array 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 } 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 } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ function getFileAccessAbilityInfo(callback: AsyncCallback>): void; /** * Query the want information of HAP configured with fileaccess. * * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @returns { Promise> } Returns the wants. * @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 } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ function getFileAccessAbilityInfo(): Promise>; /** * Obtains the fileAccessHelper that connects all fileaccess servers in the system. * * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @param { Context } context Indicates the application context. * @returns { FileAccessHelper } Returns the fileAccessHelper. * @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 } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ function createFileAccessHelper(context: Context): FileAccessHelper; /** * Obtains the fileAccessHelper that connects some specified fileaccess servers in the system. * * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @param { Context } context Indicates the application context. * @param { Array } wants Represents the connected data provider. * @returns { FileAccessHelper } Returns the fileAccessHelper. * @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 } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ function createFileAccessHelper(context: Context, wants: Array): FileAccessHelper; /** * File Object * * @interface FileInfo * @permission ohos.permission.FILE_ACCESS_MANAGER * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ interface FileInfo { /** * Indicates the path of the file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { string } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ uri: string; /** * Indicates the relativePath of the file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { string } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ relativePath: string; /** * Indicates the name of the file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { string } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ fileName: string; /** * Indicates the mode of the file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { number } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ mode: number; /** * Indicates the size of the file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { number } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ size: number; /** * Indicates the mtime of the file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { number } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ mtime: number; /** * Indicates the mimeType of the file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { string } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ mimeType: string; /** * List files in the current directory. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { Filter } filter Indicates the filter of file. * @returns { FileIterator } Returns the FileIterator 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 } 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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ listFile(filter?: Filter): FileIterator; /** * Recursively list all files in the current directory. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { Filter } filter Indicates the filter of file. * @returns { FileIterator } Returns the FileIterator 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 } 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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ scanFile(filter?: Filter): FileIterator; } /** * FileIterator Object * * @interface FileIterator * @permission ohos.permission.FILE_ACCESS_MANAGER * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ interface FileIterator { /** * Get the next fileInfo. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @returns { { value: FileInfo, done: boolean } } Returns FileInfo Object and boolean flag. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ next(): { value: FileInfo, done: boolean }; } /** * Root Object * * @interface RootInfo * @permission ohos.permission.FILE_ACCESS_MANAGER * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ interface RootInfo { /** * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { number } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ deviceType: number; /** * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { string } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ uri: string; /** * File or directory relative path * * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { string } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ relativePath: string; /** * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { string } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ displayName: string; /** * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { number } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ deviceFlags: number; /** * List files in the current directory. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { Filter } filter Indicates the filter of file. * @returns { FileIterator } Returns the FileIterator 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 } 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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ listFile(filter?: Filter): FileIterator; /** * Recursively list all files in the current directory. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { Filter } filter Indicates the filter of file. * @returns { FileIterator } Returns the RootIterator 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 } 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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ scanFile(filter?: Filter): FileIterator; } /** * RootIterator Object * * @interface RootIterator * @permission ohos.permission.FILE_ACCESS_MANAGER * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ interface RootIterator { /** * Get a next RootInfo. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @returns { { value: RootInfo, done: boolean } } Returns RootInfo Object and boolean flag. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ next(): { value: RootInfo, done: boolean }; } /** * Describes the return information of the copy operation. * * @interface CopyResult * @permission ohos.permission.FILE_ACCESS_MANAGER * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ interface CopyResult { sourceUri: string; destUri: string; errCode: number; errMsg: string; } /** * OPENFLAGS represents the way to open the file. * * @enum { number } OPENFLAGS * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ enum OPENFLAGS { /** * Open the file by Read-only mode. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ READ = 0o0, /** * Open the file by Write-only mode. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ WRITE = 0o1, /** * Open the file by Write-Read mode. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 9 */ WRITE_READ = 0o2 } /** * Property elements that support the file queries. * * @enum { string } FileKey * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ enum FileKey { /** * The key represents the file name. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ DISPLAY_NAME = 'display_name', /** * The key represents the date of the file creation. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ DATE_ADDED = 'date_added', /** * The key represents the modify date of the file. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ DATE_MODIFIED = 'date_modified', /** * The key represents the relative path. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ RELATIVE_PATH = 'relative_path', /** * The key represents the file size. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ FILE_SIZE = 'size' } /** * Describes the notifyType. * * @enum { number } NotifyType * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ enum NotifyType { /** * Type for add notification * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ NOTIFY_ADD, /** * Type for delete notification * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ NOTIFY_DELETE, /** * The file was moved into the monitored directory. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ NOTIFY_MOVED_TO, /** * The file in the monitored directory was moved. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ NOTIFY_MOVED_FROM, /** * The monitored file or directory was moved. * * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ NOTIFY_MOVE_SELF } /** * The value of the notify callback function * * @interface NotifyMessage * @permission ohos.permission.FILE_ACCESS_MANAGER * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ interface NotifyMessage { /** * Indicates the change type. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { NotifyType } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ type: NotifyType; /** * Indicates the uris generated the change event. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @type { Array } * @readonly * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @StageModelOnly * @since 10 */ uris: Array; } /** * FileAccessHelper Object * * @interface FileAccessHelper * @permission ohos.permission.FILE_ACCESS_MANAGER * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ interface FileAccessHelper { /** * Open a file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri Indicates the path of the file to open. * @param { OPENFLAGS } flags Indicate options of opening a file. The default value is read-only. * @returns { Promise } Returns 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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ openFile(uri: string, flags: OPENFLAGS): Promise; /** * Open a file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri Indicates the path of the file to open. * @param { OPENFLAGS } flags Indicate options of opening a file. The default value is read-only. * @param { AsyncCallback } callback - The callback is used to return 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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ openFile(uri: string, flags: OPENFLAGS, callback: AsyncCallback): void; /** * Create a file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri Represents a specific parent directory. * @param { string } displayName Indicates the new file name, and supports with suffix. * @returns { Promise } Returns the new file's URI. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ createFile(uri: string, displayName: string): Promise; /** * Create a file. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri Represents a specific parent directory. * @param { string } displayName Indicates the new file name, and supports with suffix. * @param { AsyncCallback } callback - The callback is used to return the new file's URI. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ createFile(uri: string, displayName: string, callback: AsyncCallback): void; /** * Create a Directory. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } parentUri Represents a specific parent directory. * @param { string } displayName Indicates the new directory name. * @returns { Promise } Returns the new directory's URI. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ mkDir(parentUri: string, displayName: string): Promise; /** * Create a Directory. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } parentUri Represents a specific parent directory. * @param { string } displayName Indicates the new directory name. * @param { AsyncCallback } callback - The callback is used to return the new directory's URI. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ mkDir(parentUri: string, displayName: string, callback: AsyncCallback): void; /** * Delete a file or delete a directory recursively. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri Indicates the file or directory to be deleted. * @returns { 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 } 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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ delete(uri: string): Promise; /** * Delete a file or delete a directory recursively. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri Indicates the file or directory to be deleted. * @param { AsyncCallback } 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 } 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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ delete(uri: string, callback: AsyncCallback): void; /** * Move a file or move a directory recursively. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } sourceFile Indicates the file or directory to be moved. * @param { string } destFile Represents the destination folder. * @returns { Promise } Returns the generated new file or directory. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ move(sourceFile: string, destFile: string): Promise; /** * Move a file or move a directory recursively. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } sourceFile Indicates the file or directory to be moved. * @param { string } destFile Represents the destination folder. * @param { AsyncCallback } callback - The callback is used to return the generated new file or directory. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ move(sourceFile: string, destFile: string, callback: AsyncCallback): void; /** * Copy file or directory in the promise way. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } sourceUri - Indicates the file or directory to be copied. * @param { string } destUri - Represents the destination directory. * @param { boolean } force - Optional parameter that determines whether to forcibly copy files. * @returns { Promise> } Returns the file information where the error occurred. * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ copy(sourceUri: string, destUri: string, force?: boolean): Promise>; /** * Copy file or directory in the asyncCallback way. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } sourceUri - Indicates the file or directory to be copied. * @param { string } destUri - Represents the destination directory. * @param { AsyncCallback> } callback - The callback is used to return the file information where the error occurred. * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ copy(sourceUri: string, destUri: string, callback: AsyncCallback>): void; /** * Copy file or directory in the asyncCallback way. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } sourceUri - Indicates the file or directory to be copied. * @param { string } destUri - Represents the destination directory. * @param { boolean } force - Determines whether to forcibly copy files. * @param { AsyncCallback> } callback - The callback is used to return the file information where the error occurred. * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ copy(sourceUri: string, destUri: string, force: boolean, callback: AsyncCallback>): void; /** * Rename the selected file or directory. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri Indicates the selected file or directory. * @param { string } displayName Indicates the new directory or file name. * @returns { Promise } Returns a URI representing the new file or directory. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ rename(uri: string, displayName: string): Promise; /** * Rename the selected file or directory. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri Indicates the selected file or directory. * @param { string } displayName Indicates the new directory or file name. * @param { AsyncCallback } callback - The callback is used to return a URI representing the new file or directory. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ rename(uri: string, displayName: string, callback: AsyncCallback): void; /** * Obtain the status of a file or directory. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } sourceFileUri Indicates the selected file or directory. * @returns { Promise } Returns whether it exists. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ access(sourceFileUri: string): Promise; /** * Obtain the status of a file or directory. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } sourceFileUri Indicates the selected file or directory. * @param { AsyncCallback } callback - The callback is used to return whether it exists. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ access(sourceFileUri: string, callback: AsyncCallback): void; /** * Query file related information by the uri in the promise way. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri - Indicates the selected file or directory. * @param { string } metaJson The json string includes query property. * @returns { Promise } Returns the json string, includes query property and value. * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ query(uri: string, metaJson: string): Promise; /** * Query file related information by the uri in the asyncCallback way. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri - Indicates the selected file or directory. * @param { string } metaJson The json string includes query property. * @param { AsyncCallback } callback - Returns the json string, includes query property and value. * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ query(uri: string, metaJson: string, callback: AsyncCallback): void; /** * Get a FileInfo by the uri in the promise way. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri - Indicates the selected file or directory. * @returns { Promise } Returns a FileInfo. * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ getFileInfoFromUri(uri: string): Promise; /** * Get a FileInfo by the uri in the asyncCallback way. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri - Indicates the selected file or directory. * @param { AsyncCallback } callback - The callback is used to return a fileinfo object. * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ getFileInfoFromUri(uri: string, callback: AsyncCallback): void; /** * Get a FileInfo by the relative path in the promise way. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } relativePath - Indicates the selected file or directory. * @returns { Promise } Returns a FileInfo. * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ getFileInfoFromRelativePath(relativePath: string): Promise; /** * Get a FileInfo by the relative path in the asyncCallback way. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } relativePath - Indicates the selected file or directory. * @param { AsyncCallback } callback - The callback is used to return a fileinfo object. * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ getFileInfoFromRelativePath(relativePath: string, callback: AsyncCallback): void; /** * Get a RootIterator. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @returns { Promise } Returns a RootIterator. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ getRoots(): Promise; /** * Get a RootIterator. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { AsyncCallback } callback - The callback is used to return a RootIterator. * @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 } 14000001 - Invalid display name * @throws { BusinessError } 14000002 - Invalid uri * @throws { BusinessError } 14000003 - Invalid file extension * @throws { BusinessError } 14000004 - File has been put into trash bin * @throws { BusinessError } 14300001 - IPC error * @throws { BusinessError } 14300002 - Invalid uri * @throws { BusinessError } 14300003 - Fail to get fileextension info * @throws { BusinessError } 14300004 - Get wrong result * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 9 */ getRoots(callback: AsyncCallback): void; /** * Turn on monitor the specified uri. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri - Indicates the file or directory to be monitored. * @param { boolean } notifyForDescendants - Indicates Whether to monitor changes in descendants. * @param { Callback } callback - The callback is used to return the notify message. * @throws { BusinessError } 14300002 - Invalid uri * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ registerObserver(uri: string, notifyForDescendants: boolean, callback: Callback): void; /** * Turn off monitor the specified uri. * * @permission ohos.permission.FILE_ACCESS_MANAGER * @param { string } uri - Indicates the file or directory the file that will cancel monitored. * @param { Callback } callback - The object bound to the uri. * @throws { BusinessError } 14300002 - Invalid uri * @syscap SystemCapability.FileManagement.UserFileService * @systemapi * @since 10 */ unregisterObserver(uri: string, callback?: Callback): void; } } export default fileAccess;