about summary refs log tree commit diff
path: root/src/engine/shared/storage.cpp
diff options
context:
space:
mode:
authorTeetime <TeetimeTW@yahoo.de>2012-02-17 19:31:43 +0100
committerTeetime <TeetimeTW@yahoo.de>2012-02-17 19:31:43 +0100
commitfc99167e687ba688ce9306bbec7e801450c917be (patch)
treeb440f2568a98b4b6a8db17925a299142adead7fa /src/engine/shared/storage.cpp
parent206e9adb9140c3c8963661f534703de33f8abe05 (diff)
parent44a47d4253a829abcf50dac5586fd9a351f0c66b (diff)
downloadzcatch-fc99167e687ba688ce9306bbec7e801450c917be.tar.gz
zcatch-fc99167e687ba688ce9306bbec7e801450c917be.zip
Merge branch 'master' into zCatch-Exp
Conflicts:
	src/engine/server.h
	src/engine/server/server.cpp
	src/engine/server/server.h
	src/engine/shared/network.h
	src/engine/shared/network_server.cpp
	src/game/server/player.h
Diffstat (limited to 'src/engine/shared/storage.cpp')
-rw-r--r--src/engine/shared/storage.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp
index d6f83dc8..a9ccdc49 100644
--- a/src/engine/shared/storage.cpp
+++ b/src/engine/shared/storage.cpp
@@ -30,7 +30,7 @@ public:
 		m_aUserdir[0] = 0;
 	}
 
-	int Init(const char *pApplicationName, int NumArgs, const char **ppArguments)
+	int Init(const char *pApplicationName, int StorageType, int NumArgs, const char **ppArguments)
 	{
 		// get userdir
 		fs_storage_path(pApplicationName, m_aUserdir, sizeof(m_aUserdir));
@@ -52,14 +52,17 @@ public:
 		}
 
 		// add save directories
-		if(m_NumPaths && (!m_aaStoragePaths[TYPE_SAVE][0] || !fs_makedir(m_aaStoragePaths[TYPE_SAVE])))
+		if(StorageType != STORAGETYPE_BASIC && m_NumPaths && (!m_aaStoragePaths[TYPE_SAVE][0] || !fs_makedir(m_aaStoragePaths[TYPE_SAVE])))
 		{
 			char aPath[MAX_PATH_LENGTH];
-			fs_makedir(GetPath(TYPE_SAVE, "screenshots", aPath, sizeof(aPath)));
-			fs_makedir(GetPath(TYPE_SAVE, "screenshots/auto", aPath, sizeof(aPath)));
-			fs_makedir(GetPath(TYPE_SAVE, "maps", aPath, sizeof(aPath)));
+			if(StorageType == STORAGETYPE_CLIENT)
+			{
+				fs_makedir(GetPath(TYPE_SAVE, "screenshots", aPath, sizeof(aPath)));
+				fs_makedir(GetPath(TYPE_SAVE, "screenshots/auto", aPath, sizeof(aPath)));
+				fs_makedir(GetPath(TYPE_SAVE, "maps", aPath, sizeof(aPath)));
+				fs_makedir(GetPath(TYPE_SAVE, "downloadedmaps", aPath, sizeof(aPath)));
+			}
 			fs_makedir(GetPath(TYPE_SAVE, "dumps", aPath, sizeof(aPath)));
-			fs_makedir(GetPath(TYPE_SAVE, "downloadedmaps", aPath, sizeof(aPath)));
 			fs_makedir(GetPath(TYPE_SAVE, "demos", aPath, sizeof(aPath)));
 			fs_makedir(GetPath(TYPE_SAVE, "demos/auto", aPath, sizeof(aPath)));
 		}
@@ -377,10 +380,22 @@ public:
 		return !fs_makedir(GetPath(Type, pFoldername, aBuffer, sizeof(aBuffer)));
 	}
 
-	static IStorage *Create(const char *pApplicationName, int NumArgs, const char **ppArguments)
+	virtual void GetCompletePath(int Type, const char *pDir, char *pBuffer, unsigned BufferSize)
+	{
+		if(Type < 0 || Type >= m_NumPaths)
+		{
+			if(BufferSize > 0)
+				pBuffer[0] = 0;
+			return;
+		}
+
+		GetPath(Type, pDir, pBuffer, BufferSize);
+	}
+
+	static IStorage *Create(const char *pApplicationName, int StorageType, int NumArgs, const char **ppArguments)
 	{
 		CStorage *p = new CStorage();
-		if(p && p->Init(pApplicationName, NumArgs, ppArguments))
+		if(p && p->Init(pApplicationName, StorageType, NumArgs, ppArguments))
 		{
 			dbg_msg("storage", "initialisation failed");
 			delete p;
@@ -390,4 +405,4 @@ public:
 	}
 };
 
-IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments) { return CStorage::Create(pApplicationName, NumArgs, ppArguments); }
+IStorage *CreateStorage(const char *pApplicationName, int StorageType, int NumArgs, const char **ppArguments) { return CStorage::Create(pApplicationName, StorageType, NumArgs, ppArguments); }