-changed that list code yet again a bit, possibly fixed a

slowdown in reload cache
This commit is contained in:
fix94.1 2012-10-07 19:59:50 +00:00
parent b2fa9f672f
commit 85da1d31d9
3 changed files with 32 additions and 33 deletions

View File

@ -240,7 +240,7 @@ wchar_t * Channels::GetName(int index)
return channels.at(index).name; return channels.at(index).name;
} }
int Channels::Count() u32 Channels::Count()
{ {
return channels.size(); return channels.size();
} }

View File

@ -48,36 +48,35 @@ typedef struct
class Channels class Channels
{ {
public: public:
Channels(); Channels();
~Channels(); ~Channels();
void Init(u32 channelType, string lang, bool reload = false); void Init(u32 channelType, string lang, bool reload = false);
u32 Load(u64 title); u32 Load(u64 title);
u8 GetRequestedIOS(u64 title); u8 GetRequestedIOS(u64 title);
int Count(); u32 Count();
wchar_t *GetName(int index); wchar_t *GetName(int index);
char *GetId(int index); char *GetId(int index);
u64 GetTitle(int index); u64 GetTitle(int index);
Channel *GetChannel(int index); Channel *GetChannel(int index);
static Banner * GetBanner(u64 title, bool imetOnly = false); static Banner * GetBanner(u64 title, bool imetOnly = false);
private: private:
bool init; bool init;
u32 channelType; u32 channelType;
string langCode; string langCode;
vector<Channel> channels; vector<Channel> channels;
static int GetLanguage(const char *lang);
u64* GetChannelList(u32* count);
static bool GetAppNameFromTmd(u64 title, char* app, bool dol = false, u32* bootcontent = NULL);
static bool GetChannelNameFromApp(u64 title, wchar_t* name, int language);
void Search(u32 channelType, string lang); static int GetLanguage(const char *lang);
u64* GetChannelList(u32* count);
static bool GetAppNameFromTmd(u64 title, char* app, bool dol = false, u32* bootcontent = NULL);
static bool GetChannelNameFromApp(u64 title, wchar_t* name, int language);
void Search(u32 channelType, string lang);
}; };
extern Channels ChannelHandle; extern Channels ChannelHandle;

View File

@ -116,15 +116,15 @@ static void Create_Wii_EXT_List(char *FullPath)
} }
} }
static const char *FST_APPEND = "sys/boot.bin";
static const u8 FST_APPEND_SIZE = strlen(FST_APPEND);
static void Create_GC_List(char *FullPath) static void Create_GC_List(char *FullPath)
{ {
static const char *FST_APPEND = "sys/boot.bin";
FILE *fp = fopen(FullPath, "rb"); FILE *fp = fopen(FullPath, "rb");
if(!fp && strstr(FullPath, "/root") != NULL) //fst folder if(!fp && strstr(FullPath, "/root") != NULL) //fst folder
{ {
*(strstr(FullPath, "/root") + 1) = '\0'; *(strstr(FullPath, "/root") + 1) = '\0';
if(strlen(FullPath) + strlen(FST_APPEND) < 255) strcat(FullPath, FST_APPEND); if(strlen(FullPath) + FST_APPEND_SIZE < 256) strcat(FullPath, FST_APPEND);
fp = fopen(FullPath, "rb"); fp = fopen(FullPath, "rb");
} }
if(fp) if(fp)
@ -176,11 +176,12 @@ static void Create_Homebrew_List(char *FullPath)
m_gameList.push_back(ListElement); m_gameList.push_back(ListElement);
} }
static Channel *chan = NULL;
static void Create_Channel_List() static void Create_Channel_List()
{ {
for(int i = 0; i < ChannelHandle.Count(); i++) for(u32 i = 0; i < ChannelHandle.Count(); i++)
{ {
Channel *chan = ChannelHandle.GetChannel(i); chan = ChannelHandle.GetChannel(i);
if(chan->id == NULL) if(chan->id == NULL)
continue; // Skip invalid channels continue; // Skip invalid channels
memset((void*)&ListElement, 0, sizeof(dir_discHdr)); memset((void*)&ListElement, 0, sizeof(dir_discHdr));
@ -272,14 +273,14 @@ void GetFiles(const char *Path, const vector<string>& FileTypes,
pdir = opendir(Path); pdir = opendir(Path);
if(pdir == NULL) if(pdir == NULL)
return; return;
char *FullPathChar = (char*)MEM2_alloc(256); char FullPathChar[256];
if(FullPathChar == NULL) if(FullPathChar == NULL)
return; return;
memset(FullPathChar, 0, 256);
while((pent = readdir(pdir)) != NULL) while((pent = readdir(pdir)) != NULL)
{ {
if(pent->d_name[0] == '.') if(pent->d_name[0] == '.')
continue; continue;
memset(FullPathChar, 0, 256);
strncpy(FullPathChar, fmt("%s/%s", Path, pent->d_name), 255); strncpy(FullPathChar, fmt("%s/%s", Path, pent->d_name), 255);
if(pent->d_type == DT_DIR) if(pent->d_type == DT_DIR)
{ {
@ -308,6 +309,5 @@ void GetFiles(const char *Path, const vector<string>& FileTypes,
} }
} }
} }
MEM2_free(FullPathChar);
closedir(pdir); closedir(pdir);
} }