diff options
author | Dees_Troy <dees_troy@teamw.in> | 2012-10-01 15:01:03 +0200 |
---|---|---|
committer | Dees_Troy <dees_troy@teamw.in> | 2012-10-01 15:01:03 +0200 |
commit | 01a9b7a7f88696d579eed5e55831267a6cb4220f (patch) | |
tree | b11e5b808df1851830d5288b075d5c2d70fb3906 /data.cpp | |
parent | Fix some derps (diff) | |
download | android_bootable_recovery-01a9b7a7f88696d579eed5e55831267a6cb4220f.tar android_bootable_recovery-01a9b7a7f88696d579eed5e55831267a6cb4220f.tar.gz android_bootable_recovery-01a9b7a7f88696d579eed5e55831267a6cb4220f.tar.bz2 android_bootable_recovery-01a9b7a7f88696d579eed5e55831267a6cb4220f.tar.lz android_bootable_recovery-01a9b7a7f88696d579eed5e55831267a6cb4220f.tar.xz android_bootable_recovery-01a9b7a7f88696d579eed5e55831267a6cb4220f.tar.zst android_bootable_recovery-01a9b7a7f88696d579eed5e55831267a6cb4220f.zip |
Diffstat (limited to 'data.cpp')
-rw-r--r-- | data.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -39,6 +39,7 @@ #include "variables.h" #include "data.hpp" #include "partitions.hpp" +#include "twrp-functions.hpp" extern "C" { @@ -814,6 +815,32 @@ int DataManager::GetMagicValue(const string varName, string& value) return -1; } +void DataManager::Output_Version(void) { + string Path, Command; + char version[255]; + + Path = DataManager::GetSettingsStoragePath(); + if (!PartitionManager.Mount_By_Path(Path, false)) { + LOGI("Unable to mount '%s' to write version number.\n", Path.c_str()); + return; + } + Path += "/TWRP/.version"; + if (TWFunc::Path_Exists(Path)) { + Command = "rm -f " + Path; + system(Command.c_str()); + } + FILE *fp = fopen(Path.c_str(), "w"); + if (fp == NULL) { + LOGE("Unable to open '%s'.\n", Path.c_str()); + return; + } + strcpy(version, TW_VERSION_STR); + fwrite(version, sizeof(version[0]), strlen(version) / sizeof(version[0]), fp); + fclose(fp); + sync(); + LOGI("Version number saved to '%s'\n", Path.c_str()); +} + void DataManager::ReadSettingsFile(void) { // Load up the values for TWRP - Sleep to let the card be ready @@ -843,11 +870,12 @@ void DataManager::ReadSettingsFile(void) LOGI("Attempt to load settings from settings file...\n"); LoadValues(settings_file); + Output_Version(); GetValue(TW_HAS_DUAL_STORAGE, has_dual); GetValue(TW_USE_EXTERNAL_STORAGE, use_ext); GetValue(TW_HAS_EXTERNAL, has_ext); if (has_dual != 0 && use_ext == 1) { - // Attempt to sdcard using external storage + // Attempt to switch to using external storage if (!PartitionManager.Mount_Current_Storage(false)) { LOGE("Failed to mount external storage, using internal storage.\n"); // Remount failed, default back to internal storage |