1 /*
2 * Copyright (C) 2021 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 FILE_UTILS_H
16 #define FILE_UTILS_H
17 #include <string>
18 #include "dump_utils.h"
19 #include "singleton.h"
20 #include "string_utils.h"
21 namespace OHOS {
22 namespace HiviewDFX {
23 class FileUtils : public Singleton<FileUtils> {
24 public:
25     FileUtils();
26     ~FileUtils();
27     FileUtils(FileUtils const &) = delete;
28     void operator=(FileUtils const &) = delete;
29 
30     bool CreateFolder(const std::string &path);
31     using DataHandler = std::function<void(const std::string& content)>;
32     bool LoadStringFromProcCb(const std::string& path, bool oneLine, bool lineEndWithN, const DataHandler& func);
33     std::string GetProcValue(const int32_t &pid, const std::string& path, const std::string& key);
34 private:
35 };
36 } // namespace HiviewDFX
37 } // namespace OHOS
38 
39 #endif