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