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 HIVIEW_BASE_EVENT_STORE_UTILITY_DB_FILE_UTIL_H 17 #define HIVIEW_BASE_EVENT_STORE_UTILITY_DB_FILE_UTIL_H 18 19 #include <cstdint> 20 #include <string> 21 22 namespace OHOS { 23 namespace HiviewDFX { 24 using ParseType = uint8_t; 25 constexpr ParseType ALL_INFO = 0x0F; 26 constexpr ParseType NAME_ONLY = 0x01; 27 constexpr ParseType TYPE_ONLY = 0x02; 28 constexpr ParseType LEVEL_ONLY = 0x04; 29 constexpr ParseType SEQ_ONLY = 0x08; 30 31 struct SplitedEventInfo { 32 std::string name; 33 uint8_t type = 0; 34 std::string level; 35 int64_t seq = 0; 36 }; 37 38 class EventDbFileUtil { 39 public: 40 static bool IsValidDbDir(const std::string& dir); 41 static bool IsValidDbFilePath(const std::string& filePath); 42 static bool ParseEventInfoFromDbFileName(const std::string& fileName, SplitedEventInfo& info, 43 ParseType tag = ALL_INFO); 44 }; 45 } 46 } 47 48 #endif // HIVIEW_BASE_EVENT_STORE_UTILITY_DB_FILE_UTIL_H