2022-12-17 06:49:03 +00:00
|
|
|
/*
|
2023-07-17 14:42:54 +00:00
|
|
|
* Copyright (C) 2022-2023 Huawei Device Co., Ltd.
|
2023-04-11 07:54:18 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2023-12-11 09:08:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
2024-01-08 07:25:39 +00:00
|
|
|
* @kit CoreFileKit
|
2023-12-11 09:08:03 +00:00
|
|
|
*/
|
|
|
|
|
2023-07-17 14:42:54 +00:00
|
|
|
import uri from './@ohos.uri';
|
2022-12-17 06:49:03 +00:00
|
|
|
|
|
|
|
/**
|
2023-04-11 07:54:18 +00:00
|
|
|
* Provides fileUri APIS
|
2022-12-17 06:49:03 +00:00
|
|
|
*
|
2023-04-11 07:54:18 +00:00
|
|
|
* @namespace fileUri
|
2022-12-17 06:49:03 +00:00
|
|
|
* @syscap SystemCapability.FileManagement.AppFileService
|
2023-04-11 07:54:18 +00:00
|
|
|
* @since 9
|
2022-12-17 06:49:03 +00:00
|
|
|
*/
|
|
|
|
declare namespace fileUri {
|
2023-07-17 14:42:54 +00:00
|
|
|
/**
|
|
|
|
* FileUri represents the uri of the file.
|
|
|
|
*
|
|
|
|
* @extends uri.URI
|
|
|
|
* @syscap SystemCapability.FileManagement.AppFileService
|
|
|
|
* @since 10
|
|
|
|
*/
|
|
|
|
class FileUri extends uri.URI {
|
|
|
|
/**
|
|
|
|
* Constructor for obtaining the instance of the FileUri class.
|
|
|
|
*
|
|
|
|
* @param { string } uriOrPath - Uri or Path.
|
|
|
|
* @throws { BusinessError } 13900005 - I/O error
|
|
|
|
* @throws { BusinessError } 13900020 - Invalid argument
|
|
|
|
* @throws { BusinessError } 13900042 - Unknown error
|
|
|
|
* @throws { BusinessError } 14300002 - Invalid uri
|
|
|
|
* @syscap SystemCapability.FileManagement.AppFileService
|
|
|
|
* @since 10
|
|
|
|
*/
|
|
|
|
constructor(uriOrPath: string);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtains the file name of uri.
|
|
|
|
*
|
|
|
|
* @type { string }
|
|
|
|
* @readonly
|
|
|
|
* @throws { BusinessError } 13900005 - I/O error
|
|
|
|
* @throws { BusinessError } 13900042 - Unknown error
|
|
|
|
* @syscap SystemCapability.FileManagement.AppFileService
|
|
|
|
* @since 10
|
|
|
|
*/
|
|
|
|
readonly name: string;
|
2023-11-03 02:34:38 +00:00
|
|
|
|
|
|
|
/**
|
2023-11-11 08:29:27 +00:00
|
|
|
* Get the full directory uri where the file URI is located
|
2023-11-03 02:34:38 +00:00
|
|
|
*
|
2023-11-09 07:51:07 +00:00
|
|
|
* @returns { string } Return the directory uri
|
2023-11-03 02:34:38 +00:00
|
|
|
* @throws { BusinessError } 13900002 - No such file or directory
|
|
|
|
* @throws { BusinessError } 13900012 - Permission denied
|
|
|
|
* @throws { BusinessError } 13900042 - Unknown error
|
|
|
|
* @syscap SystemCapability.FileManagement.AppFileService
|
|
|
|
* @since 11
|
|
|
|
*/
|
2023-11-11 08:29:27 +00:00
|
|
|
getFullDirectoryUri(): string;
|
2024-01-30 13:23:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether the incoming URI is a remote URI
|
|
|
|
*
|
|
|
|
* @returns { boolean } Return true or false
|
|
|
|
* @throws { BusinessError } 13900042 - Unknown error
|
|
|
|
* @syscap SystemCapability.FileManagement.AppFileService
|
|
|
|
* @since 12
|
|
|
|
*/
|
|
|
|
isRemoteUri(): boolean;
|
2023-07-17 14:42:54 +00:00
|
|
|
}
|
|
|
|
|
2023-04-11 07:54:18 +00:00
|
|
|
/**
|
|
|
|
* Get the uri from the path of file in app sandbox
|
|
|
|
*
|
|
|
|
* @param { string } path the path of file in app sandbox
|
|
|
|
* @returns { string } Return the file uri
|
2024-05-15 05:54:26 +00:00
|
|
|
* @throws { BusinessError } 401 - The input parameter is invalidPossible causes:1.Mandatory parameters are left unspecified;
|
2024-05-16 01:07:36 +00:00
|
|
|
* <br>2.Incorrect parameter types.
|
2023-04-11 07:54:18 +00:00
|
|
|
* @syscap SystemCapability.FileManagement.AppFileService
|
|
|
|
* @since 9
|
|
|
|
*/
|
|
|
|
function getUriFromPath(path: string): string;
|
2022-12-17 06:49:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default fileUri;
|