1 /*
2  * Copyright (C) 2021-2022 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 HIVIEWDFX_UTILS_NATIVE_FILE_UTILS_H_
16 #define HIVIEWDFX_UTILS_NATIVE_FILE_UTILS_H_
17 #include <cstdio>
18 #include <cstdlib>
19 #include <cstring>
20 #include <string>
21 #include <fstream>
22 #include <sstream>
23 #include <iostream>
24 #include <chrono>
25 #include <unistd.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <dirent.h>
29 #include <vector>
30 
31 bool CheckInfo(std::vector<std::string> &para, std::string eventinfo);
32 int ExecCmdWithRet(std::string cmd, std::vector<std::string> &resvec);
33 std::string ReadFile(std::string filename);
34 void RedirecthiLog(std::string &hilogredirect, std::string &timeout);
35 void ExeCmd(std::string cmd);
36 void CmdRun(std::string cmd, std::string &result);
37 std::string ExecuteCmd(std::string cmd);
38 bool CompareString(const std::string& x, const std::string& y);
39 int GetTxtLine(std::string filename);
40 std::string ReadFile(std::string filename);
41 void CleanCmd();
42 std::string ReadOneLine(std::string m_path, char* rBuf, int n);
43 void SaveCmdOutput(std::string cmd, std::string saveFile);
44 std::vector<std::string> getfileinpath(std::string path);
45 #endif // HIVIEWDFX_UTILS_NATIVE_FILE_UTILS_H_
46