fix for folders in demo browser

This commit is contained in:
Choupom 2010-06-07 17:27:16 +08:00 committed by Magnus Auvinen
parent 22f11d6839
commit 8e8cbdb562
3 changed files with 7 additions and 12 deletions

View file

@ -863,7 +863,8 @@ int fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, void *user)
/* add all the entries */
do
{
cb(finddata.cFileName, 0, user);
if(finddata.cFileName[0] != '.')
cb(finddata.cFileName, 0, user);
} while (FindNextFileA(handle, &finddata));
FindClose(handle);

View file

@ -165,7 +165,6 @@ class CMenus : public CComponent
void DemolistPopulate();
static void DemolistCountCallback(const char *pName, int IsDir, void *pUser);
static void DemolistFetchCallback(const char *pName, int IsDir, void *pUser);
static void IsDirCallback(const char *pName, int IsDir, void *pUser);
void DemoSetParentDirectory();
// found in menus.cpp

View file

@ -380,9 +380,9 @@ struct FETCH_CALLBACKINFO
void CMenus::DemolistFetchCallback(const char *pName, int IsDir, void *pUser)
{
if(IsDir || pName[0] == '.')
if(pName[0] == '.')
return;
FETCH_CALLBACKINFO *pInfo = (FETCH_CALLBACKINFO *)pUser;
CDemoItem Item;
@ -391,11 +391,6 @@ void CMenus::DemolistFetchCallback(const char *pName, int IsDir, void *pUser)
pInfo->m_pSelf->m_lDemos.add(Item);
}
void CMenus::IsDirCallback(const char *pName, int IsDir, void *pUser)
{
*((bool *)pUser) = true;
}
void CMenus::DemolistPopulate()
{
m_lDemos.clear();
@ -413,7 +408,7 @@ void CMenus::DemolistPopulate()
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "%s/%s", Client()->UserDirectory(), m_aCurrentDemoFolder);
FETCH_CALLBACKINFO Info = {this, aBuf, 0};
FETCH_CALLBACKINFO Info = {this, aBuf, m_aCurrentDemoFolder[6]}; //skip "demos/"
fs_listdir(aBuf, DemolistFetchCallback, &Info);
Info.m_pPrefix = m_aCurrentDemoFolder;
fs_listdir(m_aCurrentDemoFolder, DemolistFetchCallback, &Info);
@ -459,8 +454,8 @@ void CMenus::RenderDemoList(CUIRect MainView)
bool IsDir = false;
if(!strncmp(m_lDemos[s_SelectedItem].m_aName, "..", 256)) //parent folder
IsDir = true;
else
fs_listdir(m_lDemos[s_SelectedItem].m_aFilename, IsDirCallback, &IsDir);
else if(fs_is_dir(m_lDemos[s_SelectedItem].m_aFilename))
IsDir = true;
static int s_RefreshButton = 0;