diff --git a/out/boot.dol b/out/boot.dol index e8c44a5b..ecd8165b 100644 Binary files a/out/boot.dol and b/out/boot.dol differ diff --git a/source/devicemounter/DeviceHandler.cpp b/source/devicemounter/DeviceHandler.cpp index aa267a12..d02af13a 100644 --- a/source/devicemounter/DeviceHandler.cpp +++ b/source/devicemounter/DeviceHandler.cpp @@ -48,7 +48,6 @@ void DeviceHandler::Init() OGC_Device.Init();// used for Devolution gamecube iso launcher } -bool mount_usb = false; void DeviceHandler::SetMountUSB(bool using_usb) { mount_usb = using_usb; @@ -57,8 +56,7 @@ void DeviceHandler::SetMountUSB(bool using_usb) void DeviceHandler::MountAll() { MountSD(); - if(!Sys_DolphinMode() && mount_usb) - MountAllUSB(); + MountAllUSB(); } void DeviceHandler::UnMountAll() @@ -147,6 +145,9 @@ bool DeviceHandler::MountUSB(int pos) bool DeviceHandler::MountAllUSB() { + if(!mount_usb) + return false; + /* Kill possible USB thread */ KillUSBKeepAliveThread(); /* Wait for our slowass HDD */ diff --git a/source/devicemounter/DeviceHandler.hpp b/source/devicemounter/DeviceHandler.hpp index 9ef8977f..32b54a06 100644 --- a/source/devicemounter/DeviceHandler.hpp +++ b/source/devicemounter/DeviceHandler.hpp @@ -104,6 +104,7 @@ public: void UnMountDevolution(); private: bool MountUSB(int part); + bool mount_usb; PartitionHandle sd; PartitionHandle usb; diff --git a/source/list/cache.cpp b/source/list/cache.cpp index 9cbc4b52..5f81cc18 100644 --- a/source/list/cache.cpp +++ b/source/list/cache.cpp @@ -1,27 +1,6 @@ #include "cache.hpp" -CCache::CCache(dir_discHdr &tmp, string path, u32 index, CMode mode) /* Load/Save One */ -{ - filename = path; - //gprintf("Openning DB: %s\n", filename.c_str()); - - cache = fopen(filename.c_str(), io[mode]); - if(!cache) return; - - switch(mode) - { - case LOAD: - LoadOne(tmp, index); - break; - case SAVE: - SaveOne(tmp, index); - break; - default: - return; - } -} - -CCache::CCache(vector &list, string path , CMode mode) /* Load/Save All */ +CCache::CCache(vector &list, string path, CMode mode) { filename = path; //gprintf("Opening DB: %s\n", filename.c_str()); @@ -42,42 +21,6 @@ CCache::CCache(vector &list, string path , CMode mode) /* Load/Save } } -CCache::CCache(vector &list, string path, dir_discHdr tmp, CMode mode) /* Add One */ -{ - filename = path; - //gprintf("Openning DB: %s\n", filename.c_str()); - - cache = fopen(filename.c_str(), io[mode]); - if(!cache) return; - - switch(mode) - { - case ADD: - AddOne(list, tmp); - break; - default: - return; - } -} - -CCache::CCache(vector &list, string path, u32 index, CMode mode) /* Remove One */ -{ - filename = path; - //gprintf("Openning DB: %s\n", filename.c_str()); - - cache = fopen(filename.c_str(), io[mode]); - if(!cache) return; - - switch(mode) - { - case REMOVE: - RemoveOne(list, index); - break; - default: - return; - } -} - CCache::~CCache() { //gprintf("Closing DB: %s\n", filename.c_str()); @@ -92,14 +35,6 @@ void CCache::SaveAll(vector list) fwrite((void *)&list[0], 1, list.size() * sizeof(dir_discHdr), cache); } -void CCache::SaveOne(dir_discHdr tmp, u32 index) -{ - //gprintf("Updating Item number %u in DB: %s\n", index, filename.c_str()); - if(!cache) return; - fseek(cache, index * sizeof(dir_discHdr), SEEK_SET); - fwrite((void *)&tmp, 1, sizeof(dir_discHdr), cache); -} - void CCache::LoadAll(vector &list) { if(!cache) return; @@ -116,33 +51,10 @@ void CCache::LoadAll(vector &list) list.reserve(count + list.size()); for(u32 i = 0; i < count; i++) { - LoadOne(tmp, i); + //gprintf("Fetching Item number %u in DB: %s\n", index, filename.c_str()); + fseek(cache, i * sizeof(dir_discHdr), SEEK_SET); + fread((void *)&tmp, 1, sizeof(dir_discHdr), cache); + //gprintf("Path %s\n", tmp.path); list.push_back(tmp); } } - -void CCache::LoadOne(dir_discHdr &tmp, u32 index) -{ - if(!cache) return; - - //gprintf("Fetching Item number %u in DB: %s\n", index, filename.c_str()); - fseek(cache, index * sizeof(dir_discHdr), SEEK_SET); - fread((void *)&tmp, 1, sizeof(dir_discHdr), cache); - //gprintf("Path %s\n", tmp.path); -} - -void CCache::AddOne(vector &list, dir_discHdr tmp) -{ - //gprintf("Adding Item number %u in DB: %s\n", list.size()+1, filename.c_str()); - list.push_back(tmp); - - if(!cache) return; - fwrite((void *)&tmp, 1, sizeof(dir_discHdr), cache); // FILE* is opened as "ab+" so its always written to the EOF. -} - -void CCache::RemoveOne(vector &list, u32 index) -{ - //gprintf("Removing Item number %u in DB: %s\n", index, filename.c_str()); - list.erase(list.begin() + index); - SaveAll(list); -} diff --git a/source/list/cache.hpp b/source/list/cache.hpp index 07b58d15..6ae1dbe1 100644 --- a/source/list/cache.hpp +++ b/source/list/cache.hpp @@ -10,37 +10,25 @@ //#include "gecko.hpp" using namespace std; -const char io[4][5] = { +const char io[2][3] = { "wb", "rb", - "ab", - "wb", }; enum CMode { SAVE, LOAD, - ADD, - REMOVE }; class CCache { public: - CCache(dir_discHdr &tmp, string path, u32 index, CMode mode); /* Load/Save One */ - CCache(vector &list, string path, CMode mode); /* Load/Save All */ - CCache(vector &list, string path, dir_discHdr tmp, CMode mode); /* Add One */ - CCache(vector &list, string path, u32 index, CMode mode); /* Remove One */ + CCache(vector &list, string path, CMode mode); ~CCache(); private: void SaveAll(vector list); - void SaveOne(dir_discHdr tmp, u32 index); void LoadAll(vector &list); - void LoadOne(dir_discHdr &tmp, u32 index); - - void AddOne(vector &list, dir_discHdr tmp); - void RemoveOne(vector &list, u32 index); FILE *cache; string filename; diff --git a/source/main.cpp b/source/main.cpp index c95c127b..d257f56f 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,6 +1,7 @@ #include #include +#include #include "const_str.hpp" #include "booter/external_booter.hpp" @@ -157,8 +158,9 @@ int main(int argc, char **argv) Sys_ExitTo(EXIT_TO_HBC);// set exit to in case of failed launch /* mount Devices */ - DeviceHandle.SetMountUSB(isUsingUSB()); - DeviceHandle.MountAll(); + DeviceHandle.MountSD();// mount SD before calling isUsingUSB() duh! + DeviceHandle.SetMountUSB(isUsingUSB() && !Sys_DolphinMode()); + DeviceHandle.MountAllUSB();// only mounts any USB if isUsingUSB() /* init wait images and show wait animation */ m_vid.setCustomWaitImgs(wait_dir, wait_loop);