diff options
-rw-r--r-- | data.cpp | 11 | ||||
-rw-r--r-- | partitionmanager.cpp | 16 | ||||
-rw-r--r-- | partitions.hpp | 1 |
3 files changed, 26 insertions, 2 deletions
@@ -280,7 +280,9 @@ error: fclose(in); string current = GetCurrentStoragePath(); TWPartition* Part = PartitionManager.Find_Partition_By_Path(current); - if (current != Part->Storage_Path && Part->Mount(false)) { + if(!Part) + Part = PartitionManager.Get_Default_Storage_Partition(); + if (Part && current != Part->Storage_Path && Part->Mount(false)) { LOGINFO("LoadValues setting storage path to '%s'\n", Part->Storage_Path.c_str()); SetValue("tw_storage_path", Part->Storage_Path); } else { @@ -586,11 +588,16 @@ void DataManager::SetDefaultValues() mConstValues.insert(make_pair("false", "0")); mConstValues.insert(make_pair(TW_VERSION_VAR, TW_VERSION_STR)); - mValues.insert(make_pair("tw_storage_path", make_pair("/", 1))); mValues.insert(make_pair("tw_button_vibrate", make_pair("80", 1))); mValues.insert(make_pair("tw_keyboard_vibrate", make_pair("40", 1))); mValues.insert(make_pair("tw_action_vibrate", make_pair("160", 1))); + TWPartition *store = PartitionManager.Get_Default_Storage_Partition(); + if(store) + mValues.insert(make_pair("tw_storage_path", make_pair(store->Storage_Path.c_str(), 1))); + else + mValues.insert(make_pair("tw_storage_path", make_pair("/", 1))); + #ifdef TW_FORCE_CPUINFO_FOR_DEVICE_ID printf("TW_FORCE_CPUINFO_FOR_DEVICE_ID := true\n"); #endif diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 9d8c27305..be4ba6359 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -1955,3 +1955,19 @@ void TWPartitionManager::Output_Storage_Fstab(void) { } fclose(fp); } + +TWPartition *TWPartitionManager::Get_Default_Storage_Partition() +{ + TWPartition *res = NULL; + for (std::vector<TWPartition*>::iterator iter = Partitions.begin(); iter != Partitions.end(); ++iter) { + if(!(*iter)->Is_Storage) + continue; + + if((*iter)->Is_Settings_Storage) + return *iter; + + if(!res) + res = *iter; + } + return res; +} diff --git a/partitions.hpp b/partitions.hpp index cdb4f79b9..7341fe0b5 100644 --- a/partitions.hpp +++ b/partitions.hpp @@ -206,6 +206,7 @@ public: void Mount_All_Storage(void); // Mounts all storage locations void UnMount_Main_Partitions(void); // Unmounts system and data if not data/media and boot if boot is mountable int Partition_SDCard(void); // Repartitions the sdcard + TWPartition *Get_Default_Storage_Partition(); // Returns a pointer to a default storage partition int Fix_Permissions(); void Get_Partition_List(string ListType, std::vector<PartitionList> *Partition_List); |