diff options
Diffstat (limited to 'runtime/base/file_utils.cc')
| -rw-r--r-- | runtime/base/file_utils.cc | 57 | 
1 files changed, 2 insertions, 55 deletions
diff --git a/runtime/base/file_utils.cc b/runtime/base/file_utils.cc index 09a9b97cca4..7b0796cf37e 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"); @@ -306,8 +253,8 @@ std::string GetSystemImageFilename(const char* location, const InstructionSet is  }  std::string ReplaceFileExtension(const std::string& filename, const std::string& new_extension) { -  const size_t last_ext = filename.find_last_of('.'); -  if (last_ext == std::string::npos) { +  const size_t last_ext = filename.find_last_of("./"); +  if (last_ext == std::string::npos || filename[last_ext] != '.') {      return filename + "." + new_extension;    } else {      return filename.substr(0, last_ext + 1) + new_extension;  | 
