summaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-05-02 23:28:19 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-05-02 23:28:19 +0200
commit738a4258d82445d4915d31d915449779a7e128bf (patch)
treea687cef952fe46ec15e4d9ea511a67c3bbb4fc5a /screen_ui.cpp
parentMerge "Add ScreenRecoveryUI::ShowMenu()." (diff)
parentscreen_ui: Drop the dependency on common.h. (diff)
downloadandroid_bootable_recovery-738a4258d82445d4915d31d915449779a7e128bf.tar
android_bootable_recovery-738a4258d82445d4915d31d915449779a7e128bf.tar.gz
android_bootable_recovery-738a4258d82445d4915d31d915449779a7e128bf.tar.bz2
android_bootable_recovery-738a4258d82445d4915d31d915449779a7e128bf.tar.lz
android_bootable_recovery-738a4258d82445d4915d31d915449779a7e128bf.tar.xz
android_bootable_recovery-738a4258d82445d4915d31d915449779a7e128bf.tar.zst
android_bootable_recovery-738a4258d82445d4915d31d915449779a7e128bf.zip
Diffstat (limited to 'screen_ui.cpp')
-rw-r--r--screen_ui.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index aaeb18c7f..00ed45d3e 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -42,7 +42,6 @@
#include <android-base/strings.h>
#include <minui/minui.h>
-#include "common.h"
#include "device.h"
#include "ui.h"
@@ -951,10 +950,10 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) {
}
}
-void ScreenRecoveryUI::ShowFile(const char* filename) {
- FILE* fp = fopen_path(filename, "re");
- if (fp == nullptr) {
- Print(" Unable to open %s: %s\n", filename, strerror(errno));
+void ScreenRecoveryUI::ShowFile(const std::string& filename) {
+ std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(filename.c_str(), "re"), fclose);
+ if (!fp) {
+ Print(" Unable to open %s: %s\n", filename.c_str(), strerror(errno));
return;
}
@@ -966,8 +965,7 @@ void ScreenRecoveryUI::ShowFile(const char* filename) {
text_ = file_viewer_text_;
ClearText();
- ShowFile(fp);
- fclose(fp);
+ ShowFile(fp.get());
text_ = old_text;
text_col_ = old_text_col;