blob: 5926dfc8778509c4aa081c7841376125521b0c93 [file] [log] [blame]
Adam Shih4b68f5f2022-10-18 11:45:37 +08001/*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <stdio.h>
17#include <string>
18#include <android-base/file.h>
19
20// Format title and content output.
21void dumpFileContent(const char* title, const char* file_path) {
22 std::string content;
23 printf("------ %s (%s) ------\n", title, file_path);
24 if (android::base::ReadFileToString(file_path, &content)) {
25 printf("%s\n", content.c_str());
26 } else {
27 printf("Unable to read %s\n", file_path);
28 }
29 return;
30}
31
32// Format title and command output.
33void runCommand(const char* title, const char* cmd) {
34 printf("------ %s (%s)------\n", title, cmd);
35 system(cmd);
36 return;
37}