diff options
| author | 2016-09-13 16:45:56 -0700 | |
|---|---|---|
| committer | 2016-09-14 13:20:55 -0700 | |
| commit | 0bcc7caad03eed6190255591edc09a7ab3e5a7f3 (patch) | |
| tree | c90bffdb8b3791f17c4df077b259f514b4d09abf /cmds/dumpstate/utils.cpp | |
| parent | 30dbfa1c5fac2d8cbd5bc2e41616be9353c81733 (diff) | |
Refactored dump_file() into dumpFile().
Also added a duration report for dumpstate_board().
BUG: 26379932
Test: manual
Change-Id: If80bb9699162ecb80715ef46c6ee039eb22ba6b7
Diffstat (limited to 'cmds/dumpstate/utils.cpp')
| -rw-r--r-- | cmds/dumpstate/utils.cpp | 15 |
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) { |