summaryrefslogtreecommitdiff
path: root/runtime/base/file_utils.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/base/file_utils.cc')
-rw-r--r--runtime/base/file_utils.cc53
1 files changed, 0 insertions, 53 deletions
diff --git a/runtime/base/file_utils.cc b/runtime/base/file_utils.cc
index 2b3e360650..7b0796cf37 100644
--- a/runtime/base/file_utils.cc
+++ b/runtime/base/file_utils.cc
@@ -83,59 +83,6 @@ bool ReadFileToString(const std::string& file_name, std::string* result) {
}
}
-bool PrintFileToLog(const std::string& file_name, android::base::LogSeverity level) {
- File file(file_name, O_RDONLY, false);
- if (!file.IsOpened()) {
- return false;
- }
-
- constexpr size_t kBufSize = 256; // Small buffer. Avoid stack overflow and stack size warnings.
- char buf[kBufSize + 1]; // +1 for terminator.
- size_t filled_to = 0;
- while (true) {
- DCHECK_LT(filled_to, kBufSize);
- int64_t n = TEMP_FAILURE_RETRY(read(file.Fd(), &buf[filled_to], kBufSize - filled_to));
- if (n <= 0) {
- // Print the rest of the buffer, if it exists.
- if (filled_to > 0) {
- buf[filled_to] = 0;
- LOG(level) << buf;
- }
- return n == 0;
- }
- // Scan for '\n'.
- size_t i = filled_to;
- bool found_newline = false;
- for (; i < filled_to + n; ++i) {
- if (buf[i] == '\n') {
- // Found a line break, that's something to print now.
- buf[i] = 0;
- LOG(level) << buf;
- // Copy the rest to the front.
- if (i + 1 < filled_to + n) {
- memmove(&buf[0], &buf[i + 1], filled_to + n - i - 1);
- filled_to = filled_to + n - i - 1;
- } else {
- filled_to = 0;
- }
- found_newline = true;
- break;
- }
- }
- if (found_newline) {
- continue;
- } else {
- filled_to += n;
- // Check if we must flush now.
- if (filled_to == kBufSize) {
- buf[kBufSize] = 0;
- LOG(level) << buf;
- filled_to = 0;
- }
- }
- }
-}
-
std::string GetAndroidRootSafe(std::string* error_msg) {
// Prefer ANDROID_ROOT if it's set.
const char* android_dir = getenv("ANDROID_ROOT");