about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2010-09-24 13:38:03 +0200
committeroy <Tom_Adams@web.de>2010-09-24 13:38:03 +0200
commit7e0b37e06c71dc96d68f3352ecd2c799caaaf8ec (patch)
treeb76100af28ae1fecb480ff02ae42f24507e92d06 /src
parent1cbf731fc0c3cbc5a1d2be6f1af51cb93d9739e2 (diff)
downloadzcatch-7e0b37e06c71dc96d68f3352ecd2c799caaaf8ec.tar.gz
zcatch-7e0b37e06c71dc96d68f3352ecd2c799caaaf8ec.zip
fixed that it checks the current dir for demos too
Diffstat (limited to 'src')
-rw-r--r--src/base/system.c6
-rw-r--r--src/base/system.h5
-rw-r--r--src/engine/shared/storage.cpp16
-rw-r--r--src/engine/storage.h1
-rw-r--r--src/game/client/components/menus.h3
-rw-r--r--src/game/client/components/menus_demo.cpp7
-rw-r--r--src/game/client/components/skins.cpp2
-rw-r--r--src/game/client/components/skins.h2
-rw-r--r--src/game/editor/ed_editor.cpp4
9 files changed, 29 insertions, 17 deletions
diff --git a/src/base/system.c b/src/base/system.c
index 5312a705..9788e625 100644
--- a/src/base/system.c
+++ b/src/base/system.c
@@ -863,7 +863,7 @@ int net_init()
 	return 0;
 }
 
-int fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, void *user)
+int fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, int type, void *user)
 {
 #if defined(CONF_FAMILY_WINDOWS)
 	WIN32_FIND_DATA finddata;
@@ -880,7 +880,7 @@ int fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, void *user)
 	do
 	{
 		if(finddata.cFileName[0] != '.')
-			cb(finddata.cFileName, 0, user);
+			cb(finddata.cFileName, 0, type, user);
 	} while (FindNextFileA(handle, &finddata));
 
 	FindClose(handle);
@@ -893,7 +893,7 @@ int fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, void *user)
 		return 0;
 		
 	while((entry = readdir(d)) != NULL)
-		cb(entry->d_name, 0, user);
+		cb(entry->d_name, 0, type, user);
 
 	/* close the directory and return */
 	closedir(d);
diff --git a/src/base/system.h b/src/base/system.h
index a5b549bc..2ef7a9f3 100644
--- a/src/base/system.h
+++ b/src/base/system.h
@@ -888,13 +888,14 @@ void str_hex(char *dst, int dst_size, const void *data, int data_size);
 	Parameters:
 		dir - Directory to list
 		cb - Callback function to call for each entry
+		type - Type of the directory
 		user - Pointer to give to the callback
 	
 	Returns:
 		Always returns 0.
 */
-typedef void (*FS_LISTDIR_CALLBACK)(const char *name, int is_dir, void *user);
-int fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, void *user);
+typedef void (*FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user);
+int fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, int type, void *user);
 
 /*
 	Function: fs_makedir
diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp
index 74f7cd3f..8785a5bf 100644
--- a/src/engine/shared/storage.cpp
+++ b/src/engine/shared/storage.cpp
@@ -137,23 +137,33 @@ public:
 		// list current directory
 		if(Types&TYPE_CURRENT)
 		{
-			fs_listdir(pPath, pfnCallback, pUser);
+			fs_listdir(pPath, pfnCallback, TYPE_CURRENT, pUser);
 		}
 		
 		// list users directory
 		if(Types&TYPE_SAVE)
 		{
 			str_format(aBuffer, sizeof(aBuffer), "%s/%s", m_aApplicationSavePath, pPath);
-			fs_listdir(aBuffer, pfnCallback, pUser);
+			fs_listdir(aBuffer, pfnCallback, TYPE_SAVE, pUser);
 		}
 		
 		// list datadir directory
 		if(Types&TYPE_DATA)
 		{
 			str_format(aBuffer, sizeof(aBuffer), "%s/%s", m_aDatadir, pPath);
-			fs_listdir(aBuffer, pfnCallback, pUser);
+			fs_listdir(aBuffer, pfnCallback, TYPE_DATA, pUser);
 		}		
 	}
+
+	virtual const char *GetDirectory(int Type) const
+	{
+		switch(Type)
+		{
+		case TYPE_SAVE: return m_aApplicationSavePath;
+		case TYPE_DATA: return m_aDatadir;
+		default: return "";
+		}
+	}
 	
 	virtual IOHANDLE OpenFile(const char *pFilename, int Flags, char *pBuffer = 0, int BufferSize = 0)
 	{
diff --git a/src/engine/storage.h b/src/engine/storage.h
index c79f16a8..b9b02239 100644
--- a/src/engine/storage.h
+++ b/src/engine/storage.h
@@ -16,6 +16,7 @@ public:
 	};
 	
 	virtual void ListDirectory(int Types, const char *pPath, FS_LISTDIR_CALLBACK pfnCallback, void *pUser) = 0;
+	virtual const char *GetDirectory(int Type) const = 0;
 	virtual IOHANDLE OpenFile(const char *pFilename, int Flags, char *pBuffer = 0, int BufferSize = 0) = 0;
 	virtual bool RemoveFile(const char *pFilename) = 0;
 };
diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h
index 1d9591bd..2fb53d13 100644
--- a/src/game/client/components/menus.h
+++ b/src/game/client/components/menus.h
@@ -167,8 +167,7 @@ class CMenus : public CComponent
 	bool m_DemolistDelEntry;
 	
 	void DemolistPopulate();
-	static void DemolistCountCallback(const char *pName, int IsDir, void *pUser);
-	static void DemolistFetchCallback(const char *pName, int IsDir, void *pUser);
+	static void DemolistFetchCallback(const char *pName, int IsDir, int DirType, void *pUser);
 	
 	// found in menus.cpp
 	int Render();
diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp
index b64936ec..abe59094 100644
--- a/src/game/client/components/menus_demo.cpp
+++ b/src/game/client/components/menus_demo.cpp
@@ -408,7 +408,7 @@ int CMenus::UiDoListboxEnd(float *pScrollValue, bool *pItemActivated)
 	return gs_ListBoxNewSelected;
 }
 
-void CMenus::DemolistFetchCallback(const char *pName, int IsDir, void *pUser)
+void CMenus::DemolistFetchCallback(const char *pName, int IsDir, int DirType, void *pUser)
 {
 	if(pName[0] == '.')
 		return;
@@ -416,7 +416,8 @@ void CMenus::DemolistFetchCallback(const char *pName, int IsDir, void *pUser)
 	CMenus *pSelf = (CMenus *)pUser;
 	
 	CDemoItem Item;
-	str_format(Item.m_aFilename, sizeof(Item.m_aFilename), "%s/%s/%s", pSelf->Client()->UserDirectory(), pSelf->m_aCurrentDemoFolder, pName);
+	str_format(Item.m_aFilename, sizeof(Item.m_aFilename), "%s%s%s/%s", pSelf->Storage()->GetDirectory(DirType),
+		pSelf->Storage()->GetDirectory(DirType)[0] ? "/" : "", pSelf->m_aCurrentDemoFolder, pName);
 	str_copy(Item.m_aName, pName, sizeof(Item.m_aName));
 	pSelf->m_lDemos.add(Item);
 }
@@ -433,7 +434,7 @@ void CMenus::DemolistPopulate()
 		m_lDemos.add(Item);
 	}
 	
-	Storage()->ListDirectory(IStorage::TYPE_SAVE, m_aCurrentDemoFolder, DemolistFetchCallback, this);
+	Storage()->ListDirectory(IStorage::TYPE_SAVE|IStorage::TYPE_CURRENT, m_aCurrentDemoFolder, DemolistFetchCallback, this);
 }
 
 
diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp
index 757c2008..098111ee 100644
--- a/src/game/client/components/skins.cpp
+++ b/src/game/client/components/skins.cpp
@@ -10,7 +10,7 @@
 
 #include "skins.h"
 
-void CSkins::SkinScan(const char *pName, int IsDir, void *pUser)
+void CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
 {
 	CSkins *pSelf = (CSkins *)pUser;
 	int l = str_length(pName);
diff --git a/src/game/client/components/skins.h b/src/game/client/components/skins.h
index e1000e3a..9568e793 100644
--- a/src/game/client/components/skins.h
+++ b/src/game/client/components/skins.h
@@ -28,6 +28,6 @@ public:
 private:
 	sorted_array<CSkin> m_aSkins;
 
-	static void SkinScan(const char *pName, int IsDir, void *pUser);
+	static void SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
 };
 #endif
diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp
index a8e3b832..4b1a10cc 100644
--- a/src/game/editor/ed_editor.cpp
+++ b/src/game/editor/ed_editor.cpp
@@ -2146,9 +2146,9 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
 }
 
 
-static void EditorListdirCallback(const char *pName, int IsDir, void *pUser)
+static void EditorListdirCallback(const char *pName, int IsDir, int DirType, void *pUser)
 {
-	if(pName[0] == '.' && pName[1] == 0)

+	if(pName[0] == '.' && pName[1] == 0)
 		return;
 
 	CEditor *pEditor = (CEditor*)pUser;