diff options
author | bigbiff bigbiff <bigbiff@teamw.in> | 2013-02-19 16:09:21 +0100 |
---|---|---|
committer | Dees_Troy <dees_troy@teamw.in> | 2013-02-19 19:08:03 +0100 |
commit | 2c57d789df1e23f3c311036dc5de240867142be5 (patch) | |
tree | 7fc5220eeef70f33b74ffeaf6fddf561b17e3d8f | |
parent | Add MTK6575/6577 EMMC partitions backup support (diff) | |
download | android_bootable_recovery-2c57d789df1e23f3c311036dc5de240867142be5.tar android_bootable_recovery-2c57d789df1e23f3c311036dc5de240867142be5.tar.gz android_bootable_recovery-2c57d789df1e23f3c311036dc5de240867142be5.tar.bz2 android_bootable_recovery-2c57d789df1e23f3c311036dc5de240867142be5.tar.lz android_bootable_recovery-2c57d789df1e23f3c311036dc5de240867142be5.tar.xz android_bootable_recovery-2c57d789df1e23f3c311036dc5de240867142be5.tar.zst android_bootable_recovery-2c57d789df1e23f3c311036dc5de240867142be5.zip |
-rw-r--r-- | data.cpp | 18 | ||||
-rw-r--r-- | data.hpp | 6 | ||||
-rw-r--r-- | partitionmanager.cpp | 13 |
3 files changed, 31 insertions, 6 deletions
@@ -358,6 +358,17 @@ int DataManager::GetValue(const string varName, int& value) return 0; } +unsigned long long DataManager::GetValue(const string varName, unsigned long long& value) +{ + string data; + + if (GetValue(varName,data) != 0) + return -1; + + value = strtoull(data.c_str(), NULL, 10); + return 0; +} + // This is a dangerous function. It will create the value if it doesn't exist so it has a valid c_str string& DataManager::GetValueRef(const string varName) { @@ -458,6 +469,13 @@ int DataManager::SetValue(const string varName, float value, int persist /* = 0 return SetValue(varName, valStr.str(), persist);; } +int DataManager::SetValue(const string varName, unsigned long long value, int persist /* = 0 */) +{ + ostringstream valStr; + valStr << value; + return SetValue(varName, valStr.str(), persist);; +} + void DataManager::DumpValues() { map<string, TStrIntPair>::iterator iter; @@ -33,6 +33,7 @@ public: // Core get routines static int GetValue(const string varName, string& value); static int GetValue(const string varName, int& value); + static unsigned long long GetValue(const string varName, unsigned long long& value); // This is a dangerous function. It will create the value if it doesn't exist so it has a valid c_str static string& GetValueRef(const string varName); @@ -45,6 +46,7 @@ public: static int SetValue(const string varName, string value, int persist = 0); static int SetValue(const string varName, int value, int persist = 0); static int SetValue(const string varName, float value, int persist = 0); + static int SetValue(const string varName, unsigned long long value, int persist = 0); static void DumpValues(); static void update_tz_environment_variables(); @@ -52,7 +54,7 @@ public: static void SetDefaultValues(); static void Output_Version(void); // Outputs the version to a file in the TWRP folder static void ReadSettingsFile(void); - + static string GetCurrentStoragePath(void); static string& CGetCurrentStoragePath(); static string GetCurrentStorageMount(void); @@ -64,8 +66,10 @@ public: protected: typedef pair<string, int> TStrIntPair; + typedef pair<string, unsigned long long> TStrULLPair; typedef pair<string, TStrIntPair> TNameValuePair; static map<string, TStrIntPair> mValues; + static map<string, TStrULLPair> mULLValues; static string mBackingFile; static int mInitialized; diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 19efd424a..bcabb1ca4 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -521,7 +521,8 @@ bool TWPartitionManager::Make_MD5(bool generate_md5, string Backup_Folder, strin bool TWPartitionManager::Backup_Partition(TWPartition* Part, string Backup_Folder, bool generate_md5, unsigned long long* img_bytes_remaining, unsigned long long* file_bytes_remaining, unsigned long *img_time, unsigned long *file_time, unsigned long long *img_bytes, unsigned long long *file_bytes) { time_t start, stop; - int img_bps, file_bps; + int img_bps; + unsigned long long file_bps; unsigned long total_time, remain_time, section_time; int use_compression, backup_time; float pos; @@ -644,8 +645,9 @@ int TWPartitionManager::Run_Backup(void) { backup_sys = Find_Partition_By_Path("/system"); if (backup_sys != NULL) { partition_count++; - if (backup_sys->Backup_Method == 1) + if (backup_sys->Backup_Method == 1) { file_bytes += backup_sys->Backup_Size; + } else img_bytes += backup_sys->Backup_Size; } else { @@ -852,9 +854,9 @@ int TWPartitionManager::Run_Backup(void) { if (file_time == 0) file_time = 1; int img_bps = (int)img_bytes / (int)img_time; - int file_bps = (int)file_bytes / (int)file_time; + unsigned long long file_bps = file_bytes / (int)file_time; - ui_print("Average backup rate for file systems: %lu MB/sec\n", (file_bps / (1024 * 1024))); + ui_print("Average backup rate for file systems: %llu MB/sec\n", (file_bps / (1024 * 1024))); ui_print("Average backup rate for imaged drives: %lu MB/sec\n", (img_bps / (1024 * 1024))); time(&total_stop); @@ -862,7 +864,8 @@ int TWPartitionManager::Run_Backup(void) { unsigned long long actual_backup_size = TWFunc::Get_Folder_Size(Full_Backup_Path, true); actual_backup_size /= (1024LLU * 1024LLU); - int prev_img_bps, prev_file_bps, use_compression; + int prev_img_bps, use_compression; + unsigned long long prev_file_bps; DataManager::GetValue(TW_BACKUP_AVG_IMG_RATE, prev_img_bps); img_bps += (prev_img_bps * 4); img_bps /= 5; |