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