1 /* 2 * Copyright (c) 2024 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 #include "environment.h" 17 18 #include <stdio.h> 19 20 #include "environment_native.h" 21 #include "../common/error_code.h" 22 OH_Environment_GetUserDownloadDir(char ** result)23int OH_Environment_GetUserDownloadDir(char **result) 24 { 25 if (result == NULL) { 26 return GetErrorCode(-PARAMETER_ERROR); 27 } 28 int ret = GetUserDir("/Download", result); 29 if (ret < 0) { 30 return GetErrorCode(ret); 31 } 32 return ret; 33 } 34 OH_Environment_GetUserDocumentDir(char ** result)35int OH_Environment_GetUserDocumentDir(char **result) 36 { 37 if (result == NULL) { 38 return GetErrorCode(-PARAMETER_ERROR); 39 } 40 int ret = GetUserDir("/Documents", result); 41 if (ret < 0) { 42 return GetErrorCode(ret); 43 } 44 return ret; 45 } 46 OH_Environment_GetUserDesktopDir(char ** result)47int OH_Environment_GetUserDesktopDir(char **result) 48 { 49 if (result == NULL) { 50 return GetErrorCode(-PARAMETER_ERROR); 51 } 52 int ret = GetUserDir("/Desktop", result); 53 if (ret < 0) { 54 return GetErrorCode(ret); 55 } 56 return ret; 57 } 58