161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (C) 2021-2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit CoreFileKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport type { AsyncCallback } from './@ohos.base'; 2261847f8eSopenharmony_ci 2361847f8eSopenharmony_ci/** 2461847f8eSopenharmony_ci * Provides Environment APIs. 2561847f8eSopenharmony_ci * 2661847f8eSopenharmony_ci * @namespace Environment 2761847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment 2861847f8eSopenharmony_ci * @since 11 2961847f8eSopenharmony_ci */ 3061847f8eSopenharmony_cideclare namespace Environment { 3161847f8eSopenharmony_ci /** 3261847f8eSopenharmony_ci * Get the user data path. 3361847f8eSopenharmony_ci * 3461847f8eSopenharmony_ci * @returns { Promise<string> } return Promise 3561847f8eSopenharmony_ci * @throws { BusinessError } 202 - The caller is not a system application 3661847f8eSopenharmony_ci * @throws { BusinessError } 13900020 - Invalid argument 3761847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error 3861847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment 3961847f8eSopenharmony_ci * @systemapi 4061847f8eSopenharmony_ci * @since 8 4161847f8eSopenharmony_ci */ 4261847f8eSopenharmony_ci function getStorageDataDir(): Promise<string>; 4361847f8eSopenharmony_ci 4461847f8eSopenharmony_ci /** 4561847f8eSopenharmony_ci * Get the user data path. 4661847f8eSopenharmony_ci * 4761847f8eSopenharmony_ci * @param { AsyncCallback<string> } [callback] - callback 4861847f8eSopenharmony_ci * @throws { BusinessError } 202 - The caller is not a system application 4961847f8eSopenharmony_ci * @throws { BusinessError } 13900020 - Invalid argument 5061847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error 5161847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment 5261847f8eSopenharmony_ci * @systemapi 5361847f8eSopenharmony_ci * @since 8 5461847f8eSopenharmony_ci */ 5561847f8eSopenharmony_ci function getStorageDataDir(callback: AsyncCallback<string>): void; 5661847f8eSopenharmony_ci 5761847f8eSopenharmony_ci /** 5861847f8eSopenharmony_ci * Get the User storage path. 5961847f8eSopenharmony_ci * 6061847f8eSopenharmony_ci * @returns { Promise<string> } return Promise 6161847f8eSopenharmony_ci * @throws { BusinessError } 202 - The caller is not a system application 6261847f8eSopenharmony_ci * @throws { BusinessError } 13900020 - Invalid argument 6361847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error 6461847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment 6561847f8eSopenharmony_ci * @systemapi 6661847f8eSopenharmony_ci * @since 8 6761847f8eSopenharmony_ci */ 6861847f8eSopenharmony_ci function getUserDataDir(): Promise<string>; 6961847f8eSopenharmony_ci 7061847f8eSopenharmony_ci /** 7161847f8eSopenharmony_ci * Get the User storage path. 7261847f8eSopenharmony_ci * 7361847f8eSopenharmony_ci * @param { AsyncCallback<string> } [callback] - callback 7461847f8eSopenharmony_ci * @throws { BusinessError } 202 - The caller is not a system application 7561847f8eSopenharmony_ci * @throws { BusinessError } 13900020 - Invalid argument 7661847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error 7761847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment 7861847f8eSopenharmony_ci * @systemapi 7961847f8eSopenharmony_ci * @since 8 8061847f8eSopenharmony_ci */ 8161847f8eSopenharmony_ci function getUserDataDir(callback: AsyncCallback<string>): void; 8261847f8eSopenharmony_ci 8361847f8eSopenharmony_ci /** 8461847f8eSopenharmony_ci * Get the public download directory. 8561847f8eSopenharmony_ci * 8661847f8eSopenharmony_ci * @permission ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY 8761847f8eSopenharmony_ci * @returns { string } Return the public download directory. 8861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 8961847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 9061847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error. 9161847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain 9261847f8eSopenharmony_ci * @since 11 9361847f8eSopenharmony_ci */ 9461847f8eSopenharmony_ci /** 9561847f8eSopenharmony_ci * Get the public download directory. 9661847f8eSopenharmony_ci * 9761847f8eSopenharmony_ci * @returns { string } Return the public download directory. 9861847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 9961847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error. 10061847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain 10161847f8eSopenharmony_ci * @since 12 10261847f8eSopenharmony_ci */ 10361847f8eSopenharmony_ci function getUserDownloadDir(): string; 10461847f8eSopenharmony_ci 10561847f8eSopenharmony_ci /** 10661847f8eSopenharmony_ci * Get the public desktop directory. 10761847f8eSopenharmony_ci * 10861847f8eSopenharmony_ci * @permission ohos.permission.READ_WRITE_DESKTOP_DIRECTORY 10961847f8eSopenharmony_ci * @returns { string } Return the public desktop directory. 11061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 11161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 11261847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error. 11361847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain 11461847f8eSopenharmony_ci * @since 11 11561847f8eSopenharmony_ci */ 11661847f8eSopenharmony_ci /** 11761847f8eSopenharmony_ci * Get the public desktop directory. 11861847f8eSopenharmony_ci * 11961847f8eSopenharmony_ci * @returns { string } Return the public desktop directory. 12061847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 12161847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error. 12261847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain 12361847f8eSopenharmony_ci * @since 12 12461847f8eSopenharmony_ci */ 12561847f8eSopenharmony_ci function getUserDesktopDir(): string; 12661847f8eSopenharmony_ci 12761847f8eSopenharmony_ci /** 12861847f8eSopenharmony_ci * Get the public document directory. 12961847f8eSopenharmony_ci * 13061847f8eSopenharmony_ci * @permission ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY 13161847f8eSopenharmony_ci * @returns { string } Return the public document directory. 13261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 13361847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 13461847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error. 13561847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain 13661847f8eSopenharmony_ci * @since 11 13761847f8eSopenharmony_ci */ 13861847f8eSopenharmony_ci /** 13961847f8eSopenharmony_ci * Get the public document directory. 14061847f8eSopenharmony_ci * 14161847f8eSopenharmony_ci * @returns { string } Return the public document directory. 14261847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 14361847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error. 14461847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain 14561847f8eSopenharmony_ci * @since 12 14661847f8eSopenharmony_ci */ 14761847f8eSopenharmony_ci function getUserDocumentDir(): string; 14861847f8eSopenharmony_ci 14961847f8eSopenharmony_ci /** 15061847f8eSopenharmony_ci * Get external storage directory. 15161847f8eSopenharmony_ci * 15261847f8eSopenharmony_ci * @permission ohos.permission.FILE_ACCESS_MANAGER 15361847f8eSopenharmony_ci * @returns { string } Return external storage directory. 15461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 15561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 15661847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 15761847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error. 15861847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain 15961847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 16061847f8eSopenharmony_ci * @since 11 16161847f8eSopenharmony_ci */ 16261847f8eSopenharmony_ci function getExternalStorageDir(): string; 16361847f8eSopenharmony_ci 16461847f8eSopenharmony_ci /** 16561847f8eSopenharmony_ci * Get home directory of the application sandbox path for the current user. 16661847f8eSopenharmony_ci * 16761847f8eSopenharmony_ci * @permission ohos.permission.FILE_ACCESS_MANAGER 16861847f8eSopenharmony_ci * @returns { string } Return home directory of the application sandbox path for the current user. 16961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 17061847f8eSopenharmony_ci * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 17161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 17261847f8eSopenharmony_ci * @throws { BusinessError } 13900042 - Unknown error. 17361847f8eSopenharmony_ci * @syscap SystemCapability.FileManagement.File.Environment.FolderObtain 17461847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 17561847f8eSopenharmony_ci * @since 11 17661847f8eSopenharmony_ci */ 17761847f8eSopenharmony_ci function getUserHomeDir(): string; 17861847f8eSopenharmony_ci} 17961847f8eSopenharmony_ci 18061847f8eSopenharmony_ciexport default Environment; 181