• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2021-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 type { AsyncCallback } from './@ohos.base';
22
23/**
24 * Provides Environment APIs.
25 *
26 * @namespace Environment
27 * @syscap SystemCapability.FileManagement.File.Environment
28 * @since arkts {'1.1':'11', '1.2':'20'}
29 * @arkts 1.1&1.2
30 */
31declare namespace Environment {
32  /**
33   * Get the user data path.
34   *
35   * @returns { Promise<string> } return Promise
36   * @throws { BusinessError } 202 - The caller is not a system application
37   * @throws { BusinessError } 13900020 - Invalid argument
38   * @throws { BusinessError } 13900042 - Unknown error
39   * @syscap SystemCapability.FileManagement.File.Environment
40   * @systemapi
41   * @since arkts {'1.1':'8', '1.2':'20'}
42   * @arkts 1.1&1.2
43   */
44  function getStorageDataDir(): Promise<string>;
45
46  /**
47   * Get the user data path.
48   *
49   * @param { AsyncCallback<string> } [callback] - callback
50   * @throws { BusinessError } 202 - The caller is not a system application
51   * @throws { BusinessError } 13900020 - Invalid argument
52   * @throws { BusinessError } 13900042 - Unknown error
53   * @syscap SystemCapability.FileManagement.File.Environment
54   * @systemapi
55   * @since arkts {'1.1':'8', '1.2':'20'}
56   * @arkts 1.1&1.2
57   */
58  function getStorageDataDir(callback: AsyncCallback<string>): void;
59
60  /**
61   * Get the User storage path.
62   *
63   * @returns { Promise<string> } return Promise
64   * @throws { BusinessError } 202 - The caller is not a system application
65   * @throws { BusinessError } 13900020 - Invalid argument
66   * @throws { BusinessError } 13900042 - Unknown error
67   * @syscap SystemCapability.FileManagement.File.Environment
68   * @systemapi
69   * @since arkts {'1.1':'8', '1.2':'20'}
70   * @arkts 1.1&1.2
71   */
72  function getUserDataDir(): Promise<string>;
73
74  /**
75   * Get the User storage path.
76   *
77   * @param { AsyncCallback<string> } [callback] - callback
78   * @throws { BusinessError } 202 - The caller is not a system application
79   * @throws { BusinessError } 13900020 - Invalid argument
80   * @throws { BusinessError } 13900042 - Unknown error
81   * @syscap SystemCapability.FileManagement.File.Environment
82   * @systemapi
83   * @since arkts {'1.1':'8', '1.2':'20'}
84   * @arkts 1.1&1.2
85   */
86  function getUserDataDir(callback: AsyncCallback<string>): void;
87
88  /**
89   * Get the public download directory.
90   *
91   * @permission ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY
92   * @returns { string } Return the public download directory.
93   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
94   * @throws { BusinessError } 801 - Capability not supported.
95   * @throws { BusinessError } 13900042 - Unknown error.
96   * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain
97   * @since 11
98   */
99  /**
100   * Get the public download directory.
101   *
102   * @returns { string } Return the public download directory.
103   * @throws { BusinessError } 801 - Capability not supported.
104   * @throws { BusinessError } 13900042 - Unknown error.
105   * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain
106   * @since arkts {'1.1':'12', '1.2':'20'}
107   * @arkts 1.1&1.2
108   */
109  function getUserDownloadDir(): string;
110
111  /**
112   * Get the public desktop directory.
113   *
114   * @permission ohos.permission.READ_WRITE_DESKTOP_DIRECTORY
115   * @returns { string } Return the public desktop directory.
116   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
117   * @throws { BusinessError } 801 - Capability not supported.
118   * @throws { BusinessError } 13900042 - Unknown error.
119   * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain
120   * @since 11
121   */
122  /**
123   * Get the public desktop directory.
124   *
125   * @returns { string } Return the public desktop directory.
126   * @throws { BusinessError } 801 - Capability not supported.
127   * @throws { BusinessError } 13900042 - Unknown error.
128   * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain
129   * @since arkts {'1.1':'12', '1.2':'20'}
130   * @arkts 1.1&1.2
131   */
132  function getUserDesktopDir(): string;
133
134  /**
135   * Get the public document directory.
136   *
137   * @permission ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY
138   * @returns { string } Return the public document directory.
139   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
140   * @throws { BusinessError } 801 - Capability not supported.
141   * @throws { BusinessError } 13900042 - Unknown error.
142   * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain
143   * @since 11
144   */
145  /**
146   * Get the public document directory.
147   *
148   * @returns { string } Return the public document directory.
149   * @throws { BusinessError } 801 - Capability not supported.
150   * @throws { BusinessError } 13900042 - Unknown error.
151   * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain
152   * @since arkts {'1.1':'12', '1.2':'20'}
153   * @arkts 1.1&1.2
154   */
155  function getUserDocumentDir(): string;
156
157  /**
158   * Get external storage directory.
159   *
160   * @permission ohos.permission.FILE_ACCESS_MANAGER
161   * @returns { string } Return external storage directory.
162   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
163   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
164   * @throws { BusinessError } 801 - Capability not supported.
165   * @throws { BusinessError } 13900042 - Unknown error.
166   * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain
167   * @systemapi Hide this for inner system use.
168   * @since arkts {'1.1':'11', '1.2':'20'}
169   * @arkts 1.1&1.2
170   */
171  function getExternalStorageDir(): string;
172
173  /**
174   * Get home directory of the application sandbox path for the current user.
175   *
176   * @permission ohos.permission.FILE_ACCESS_MANAGER
177   * @returns { string } Return home directory of the application sandbox path for the current user.
178   * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken.
179   * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API.
180   * @throws { BusinessError } 801 - Capability not supported.
181   * @throws { BusinessError } 13900042 - Unknown error.
182   * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain
183   * @systemapi Hide this for inner system use.
184   * @since arkts {'1.1':'11', '1.2':'20'}
185   * @arkts 1.1&1.2
186   */
187  function getUserHomeDir(): string;
188}
189
190export default Environment;
191