• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifndef LOGLIBRARY_ANI_UTIL_H
17 #define LOGLIBRARY_ANI_UTIL_H
18 
19 #include <ani.h>
20 #include "hilog/log.h"
21 #include "hilog/log_cpp.h"
22 #include "hiview_file_info.h"
23 #include "hiview_err_code.h"
24 #include "hiview_logger.h"
25 #include "string_util.h"
26 #include "loglibrary_ani_parameter_name.h"
27 
28 namespace OHOS {
29 namespace HiviewDFX {
30 class LogLibraryAniUtil {
31 public:
32     static std::string ParseStringValue(ani_env *env, ani_string aniStrRef);
33     static bool CreateLogEntryArray(ani_env *env,
34         const std::vector<HiviewFileInfo>& fileInfos, ani_array_ref &logEntryArray);
35     static ani_object CreateLogEntryObject(ani_env *env);
36     static ani_ref ListResult(ani_env *env, const std::vector<HiviewFileInfo>& fileInfos);
37     static bool IsSystemAppCall();
38     static void ThrowAniError(ani_env *env, int32_t code, const std::string &message);
39     static std::pair<int32_t, std::string> GetErrorDetailByRet(const int32_t retCode);
40     static ani_object CopyOrMoveFile(ani_env *env,
41         ani_string logType, ani_string logName, ani_string dest, bool isMove);
42     static bool CheckDirPath(const std::string& path);
43     static ani_object CopyOrMoveResult(ani_env *env, std::pair<int32_t, std::string> result);
44     static ani_ref GetAniUndefined(ani_env *env);
45 };
46 } // namespace HiviewDFX
47 } // namespace OHOS
48 
49 #endif // LOGLIBRARY_ANI_UTIL_H
50