From 2c57d789df1e23f3c311036dc5de240867142be5 Mon Sep 17 00:00:00 2001 From: bigbiff bigbiff Date: Tue, 19 Feb 2013 10:09:21 -0500 Subject: convert file_bps to be unsigned long long Change-Id: Ib5d9ca8f9a2a4e27d9798665b312376a7d9c571c --- data.cpp | 18 ++++++++++++++++++ data.hpp | 6 +++++- partitionmanager.cpp | 13 ++++++++----- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/data.cpp b/data.cpp index 9e9120cb8..6566bcd22 100644 --- a/data.cpp +++ b/data.cpp @@ -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::iterator iter; diff --git a/data.hpp b/data.hpp index 42c722033..55966a1c3 100644 --- a/data.hpp +++ b/data.hpp @@ -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 TStrIntPair; + typedef pair TStrULLPair; typedef pair TNameValuePair; static map mValues; + static map 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; -- cgit v1.2.3