• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
30
31/**
32 * Provides fileUri APIS
33 *
34 * @namespace fileUri
35 * @syscap SystemCapability.FileManagement.AppFileService
36 * @atomicservice
37 * @since 15
38 */
39declare namespace fileUri {
40  /**
41   * FileUri represents the uri of the file.
42   *
43   * @extends uri.URI
44   * @syscap SystemCapability.FileManagement.AppFileService
45   * @since 10
46   */
47  /**
48   * FileUri represents the uri of the file.
49   *
50   * @extends uri.URI
51   * @syscap SystemCapability.FileManagement.AppFileService
52   * @atomicservice
53   * @since 15
54   */
55  class FileUri extends uri.URI {
56    /**
57     * Constructor for obtaining the instance of the FileUri class.
58     *
59     * @param { string } uriOrPath - Uri or Path.
60     * @throws { BusinessError } 13900005 - I/O error
61     * @throws { BusinessError } 13900020 - Invalid argument
62     * @throws { BusinessError } 13900042 - Unknown error
63     * @throws { BusinessError } 14300002 - Invalid uri
64     * @syscap SystemCapability.FileManagement.AppFileService
65     * @since 10
66     */
67    /**
68     * Constructor for obtaining the instance of the FileUri class.
69     *
70     * @param { string } uriOrPath - Uri or Path.
71     * @throws { BusinessError } 13900005 - I/O error
72     * @throws { BusinessError } 13900020 - Invalid argument
73     * @throws { BusinessError } 13900042 - Unknown error
74     * @throws { BusinessError } 14300002 - Invalid uri
75     * @syscap SystemCapability.FileManagement.AppFileService
76     * @atomicservice
77     * @since 15
78     */
79    constructor(uriOrPath: string);
80
81    /**
82     * Obtains the file name of uri.
83     *
84     * @type { string }
85     * @readonly
86     * @throws { BusinessError } 13900005 - I/O error
87     * @throws { BusinessError } 13900042 - Unknown error
88     * @syscap SystemCapability.FileManagement.AppFileService
89     * @since 10
90     */
91    /**
92     * Obtains the file name of uri.
93     *
94     * @type { string }
95     * @readonly
96     * @throws { BusinessError } 13900005 - I/O error
97     * @throws { BusinessError } 13900042 - Unknown error
98     * @syscap SystemCapability.FileManagement.AppFileService
99     * @atomicservice
100     * @since 15
101     */
102    readonly name: string;
103
104    /**
105     * Get the full directory uri where the file URI is located
106     *
107     * @returns { string } Return the directory uri
108     * @throws { BusinessError } 13900002 - No such file or directory
109     * @throws { BusinessError } 13900012 - Permission denied
110     * @throws { BusinessError } 13900042 - Unknown error
111     * @syscap SystemCapability.FileManagement.AppFileService
112     * @since 11
113     */
114    /**
115     * Get the full directory uri where the file URI is located
116     *
117     * @returns { string } Return the directory uri
118     * @throws { BusinessError } 13900002 - No such file or directory
119     * @throws { BusinessError } 13900012 - Permission denied
120     * @throws { BusinessError } 13900042 - Unknown error
121     * @syscap SystemCapability.FileManagement.AppFileService
122     * @atomicservice
123     * @since 15
124     */
125    getFullDirectoryUri(): string;
126
127    /**
128     * Check whether the incoming URI is a remote URI
129     *
130     * @returns { boolean } Return true or false
131     * @throws { BusinessError } 13900042 - Unknown error
132     * @syscap SystemCapability.FileManagement.AppFileService
133     * @since 12
134     */
135    /**
136     * Check whether the incoming URI is a remote URI
137     *
138     * @returns { boolean } Return true or false
139     * @throws { BusinessError } 13900042 - Unknown error
140     * @syscap SystemCapability.FileManagement.AppFileService
141     * @atomicservice
142     * @since 15
143     */
144    isRemoteUri(): boolean;
145  }
146
147  /**
148   * Get the uri from the path of file in app sandbox
149   *
150   * @param { string } path the path of file in app sandbox
151   * @returns { string } Return the file uri
152   * @throws { BusinessError } 401 - The input parameter is invalidPossible causes:1.Mandatory parameters are left unspecified;
153   * <br>2.Incorrect parameter types.
154   * @syscap SystemCapability.FileManagement.AppFileService
155   * @since 9
156   */
157  /**
158   * Get the uri from the path of file in app sandbox
159   *
160   * @param { string } path the path of file in app sandbox
161   * @returns { string } Return the file uri
162   * @throws { BusinessError } 401 - The input parameter is invalidPossible causes:1.Mandatory parameters are left unspecified;
163   * <br>2.Incorrect parameter types.
164   * @syscap SystemCapability.FileManagement.AppFileService
165   * @atomicservice
166   * @since 15
167   */
168  function getUriFromPath(path: string): string;
169}
170
171export default fileUri;
172