// --------------------------------------------------------------------------- // CCache::Create //--------------------------------------------------------------------------- HRESULT CCache::Create(CCache **ppCache, IApplicationContext *pAppCtx) { HRESULT hr=S_OK; CCache *pCache = NULL; DWORD cb = 0; // Check to see if an instance of CCache is in pAppCtx. // Assume, if it is present, it means if a custom path is // also present, that the CCache pointer points to a // CCache with the custom path as specified by // ACTAG_APP_CUSTOM_CACHE_PATH in pAppCtx. // (assumes the custom cache path cannot be not modified) if (pAppCtx) { cb = sizeof(void*); hr = pAppCtx->Get(ACTAG_APP_CACHE, (void*)&pCache, &cb, APP_CTX_FLAGS_INTERFACE); if (hr != HRESULT_FROM_WIN32(ERROR_NOT_FOUND)) { if (SUCCEEDED(hr)) { *ppCache = pCache; (*ppCache)->AddRef(); //Already AddRef-ed in pAppCtx->Get() } goto exit; } } // Not found, create a new CCache pCache = NEW(CCache(pAppCtx)); if (!pCache) { hr = E_OUTOFMEMORY; goto exit; } hr = pCache->_hr; if (SUCCEEDED(hr)) { *ppCache = pCache; (*ppCache)->AddRef(); } else { goto exit; } if (pAppCtx) { // Set the new CCache to the AppCtx hr = pAppCtx->Set(ACTAG_APP_CACHE, (void*)pCache, sizeof(void*), APP_CTX_FLAGS_INTERFACE); } exit: SAFERELEASE(pCache); return hr; }
void ListGenerator::createSFList(u8 maxBtns, Config &m_sourceMenuCfg, bool show_homebrew, bool show_channel, bool show_plugin, bool show_gc, const string& sourceDir, const string& DBName, bool UpdateCache) { if(!DBName.empty()) { if(UpdateCache) fsop_deleteFile(DBName.c_str()); else { CCache(*this, DBName, LOAD); if(!this->empty()) return; fsop_deleteFile(DBName.c_str()); } } char btn_selected[256]; for(u8 i = 0; i < maxBtns; i++) { memset(btn_selected, 0, 256); strncpy(btn_selected, fmt("BUTTON_%i", i), 255); string source = m_sourceMenuCfg.getString(btn_selected, "source",""); if(source == "") continue; if(source == "dml" && !show_gc) continue; else if(source == "emunand" && !show_channel) continue; else if(source == "homebrew" && (!show_homebrew)) continue; else if((source == "plugin" || source == "allplugins") && !show_plugin) continue; const char *path = fmt("%s/%s", sourceDir.c_str(), m_sourceMenuCfg.getString(btn_selected, "image", "").c_str()); memset((void*)&ListElement, 0, sizeof(dir_discHdr)); ListElement.index = m_gameList.size(); strncpy(ListElement.id, "SOURCE", 6); strncpy(ListElement.path, path, sizeof(ListElement.path) - 1); ListElement.casecolor = 0xFFFFFF; ListElement.type = TYPE_SOURCE; ListElement.settings[0] = i; const char *title = m_sourceMenuCfg.getString(btn_selected, "title", fmt("title_%i", i)).c_str(); mbstowcs(ListElement.title, title, 63); Asciify(ListElement.title); m_gameList.push_back(ListElement); } if(!this->empty() && !DBName.empty()) /* Write a new Cache */ CCache(*this, DBName, SAVE); }
void ListGenerator::CreateList(u32 Flow, u32 Device, const string& Path, const vector<string>& FileTypes, const string& DBName, bool UpdateCache) { if(!DBName.empty()) { if(UpdateCache) fsop_deleteFile(DBName.c_str()); else { CCache(*this, DBName, LOAD); if(!this->empty()) return; fsop_deleteFile(DBName.c_str()); } } //if(Flow != COVERFLOW_PLUGIN) OpenConfigs(); if(Flow == COVERFLOW_WII) { if(DeviceHandle.GetFSType(Device) == PART_FS_WBFS) Create_Wii_WBFS_List(DeviceHandle.GetWbfsHandle(Device)); else GetFiles(Path.c_str(), FileTypes, Create_Wii_EXT_List, false); } else if(Flow == COVERFLOW_CHANNEL) { ChannelHandle.Init(gameTDB_Language); Create_Channel_List(); } else if(DeviceHandle.GetFSType(Device) != PART_FS_WBFS) { if(Flow == COVERFLOW_GAMECUBE) GetFiles(Path.c_str(), FileTypes, Create_GC_List, true);//the only one that looks for a folder (/root) else if(Flow == COVERFLOW_PLUGIN) GetFiles(Path.c_str(), FileTypes, Create_Plugin_List, false, 30);//wow 30 subfolders! really? else if(Flow == COVERFLOW_HOMEBREW) GetFiles(Path.c_str(), FileTypes, Create_Homebrew_List, false); } CloseConfigs(); if(!this->empty() && !DBName.empty()) /* Write a new Cache */ CCache(*this, DBName, SAVE); }