1/* 2 * Copyright (C) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit CoreFileKit 19 */ 20 21import uri from './@ohos.uri'; 22 23/** 24 * Provides fileUri APIS 25 * 26 * @namespace fileUri 27 * @syscap SystemCapability.FileManagement.AppFileService 28 * @since 9 29 */ 30declare namespace fileUri { 31 /** 32 * FileUri represents the uri of the file. 33 * 34 * @extends uri.URI 35 * @syscap SystemCapability.FileManagement.AppFileService 36 * @since 10 37 */ 38 class FileUri extends uri.URI { 39 /** 40 * Constructor for obtaining the instance of the FileUri class. 41 * 42 * @param { string } uriOrPath - Uri or Path. 43 * @throws { BusinessError } 13900005 - I/O error 44 * @throws { BusinessError } 13900020 - Invalid argument 45 * @throws { BusinessError } 13900042 - Unknown error 46 * @throws { BusinessError } 14300002 - Invalid uri 47 * @syscap SystemCapability.FileManagement.AppFileService 48 * @since 10 49 */ 50 constructor(uriOrPath: string); 51 52 /** 53 * Obtains the file name of uri. 54 * 55 * @type { string } 56 * @readonly 57 * @throws { BusinessError } 13900005 - I/O error 58 * @throws { BusinessError } 13900042 - Unknown error 59 * @syscap SystemCapability.FileManagement.AppFileService 60 * @since 10 61 */ 62 readonly name: string; 63 64 /** 65 * Get the full directory uri where the file URI is located 66 * 67 * @returns { string } Return the directory uri 68 * @throws { BusinessError } 13900002 - No such file or directory 69 * @throws { BusinessError } 13900012 - Permission denied 70 * @throws { BusinessError } 13900042 - Unknown error 71 * @syscap SystemCapability.FileManagement.AppFileService 72 * @since 11 73 */ 74 getFullDirectoryUri(): string; 75 76 /** 77 * Check whether the incoming URI is a remote URI 78 * 79 * @returns { boolean } Return true or false 80 * @throws { BusinessError } 13900042 - Unknown error 81 * @syscap SystemCapability.FileManagement.AppFileService 82 * @since 12 83 */ 84 isRemoteUri(): boolean; 85 } 86 87 /** 88 * Get the uri from the path of file in app sandbox 89 * 90 * @param { string } path the path of file in app sandbox 91 * @returns { string } Return the file uri 92 * @throws { BusinessError } 401 - The input parameter is invalidPossible causes:1.Mandatory parameters are left unspecified; 93 * <br>2.Incorrect parameter types. 94 * @syscap SystemCapability.FileManagement.AppFileService 95 * @since 9 96 */ 97 function getUriFromPath(path: string): string; 98} 99 100export default fileUri; 101