• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 #ifndef FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_FILE_UTILS_H
16 #define FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_FILE_UTILS_H
17 
18 #include <map>
19 #include <string>
20 #include <contrib/minizip/zip.h>
21 
22 #include "hitrace_dump.h"
23 #include "trace_collector.h"
24 
25 using OHOS::HiviewDFX::UCollectUtil::TraceCollector;
26 using OHOS::HiviewDFX::Hitrace::TraceErrorCode;
27 using OHOS::HiviewDFX::Hitrace::TraceRetInfo;
28 using OHOS::HiviewDFX::UCollect::UcError;
29 
30 namespace OHOS {
31 namespace HiviewDFX {
32 namespace {
33 const std::map<TraceErrorCode, UcError> CODE_MAP = {
34     {TraceErrorCode::SUCCESS, UcError::SUCCESS},
35     {TraceErrorCode::TRACE_NOT_SUPPORTED, UcError::UNSUPPORT},
36     {TraceErrorCode::TRACE_IS_OCCUPIED, UcError::TRACE_IS_OCCUPIED},
37     {TraceErrorCode::TAG_ERROR, UcError::TRACE_TAG_ERROR},
38     {TraceErrorCode::FILE_ERROR, UcError::TRACE_FILE_ERROR},
39     {TraceErrorCode::WRITE_TRACE_INFO_ERROR, UcError::TRACE_WRITE_ERROR},
40     {TraceErrorCode::CALL_ERROR, UcError::TRACE_CALL_ERROR},
41 };
42 }
43 
44 UcError TransCodeToUcError(TraceErrorCode ret);
45 void FileRemove(UCollect::TraceCaller &caller);
46 void CheckAndCreateDirectory(const std::string &tmpDirPath);
47 bool CreateMultiDirectory(const std::string &dirPath);
48 const std::string EnumToString(UCollect::TraceCaller &caller);
49 std::vector<std::string> GetUnifiedFiles(Hitrace::TraceRetInfo ret, UCollect::TraceCaller &caller);
50 void CopyFile(const std::string &src, const std::string &dst);
51 std::vector<std::string> GetUnifiedShareFiles(Hitrace::TraceRetInfo ret, UCollect::TraceCaller &caller);
52 std::vector<std::string> GetUnifiedSpecialFiles(Hitrace::TraceRetInfo ret,
53     UCollect::TraceCaller &caller);
54 void ZipTraceFile(const std::string &srcSysPath, const std::string &destZipPath);
55 std::string AddVersionInfoToZipName(const std::string &srcZipPath);
56 void CheckCurrentCpuLoad();
57 } // HiViewDFX
58 } // OHOS
59 #endif // FRAMEWORK_NATIVE_UNIFIED_COLLECTION_COLLECTOR_FILE_UTILS_H
60