summaryrefslogtreecommitdiff
path: root/cmds/dumpstate/utils.cpp
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2016-09-15 20:59:56 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-09-15 20:59:56 +0000
commit023394a9a3ad6ec0c8540b81d8d181e5c7e4a7e5 (patch)
treeeec430a293b41a1280a7a0e0ac97b1a5c900de75 /cmds/dumpstate/utils.cpp
parent25de1530c65096a422734a234fc657adf65f6064 (diff)
parent0bcc7caad03eed6190255591edc09a7ab3e5a7f3 (diff)
Merge "Refactored dump_file() into dumpFile()."
Diffstat (limited to 'cmds/dumpstate/utils.cpp')
-rw-r--r--cmds/dumpstate/utils.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index 5c59baea39..ff66bf3357 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -553,17 +553,20 @@ static int _dump_file_from_fd(const char *title, const char *path, int fd) {
return 0;
}
-/* prints the contents of a file */
int dump_file(const char *title, const char *path) {
- DurationReporter duration_reporter(title);
- int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC));
+ return dumpFile(title, path);
+}
+
+int dumpFile(const char* title, const std::string& path) {
+ DurationReporter durationReporter(title);
+ int fd = TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC));
if (fd < 0) {
int err = errno;
- printf("*** %s: %s\n", path, strerror(err));
- if (title) printf("\n");
+ printf("*** %s: %s\n", path.c_str(), strerror(err));
+ if (title != nullptr) printf("\n");
return -1;
}
- return _dump_file_from_fd(title, path, fd);
+ return _dump_file_from_fd(title, path.c_str(), fd);
}
int read_file_as_long(const char *path, long int *output) {