diff options
| author | oy <Tom_Adams@web.de> | 2010-08-05 20:26:03 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-08-05 20:26:03 +0200 |
| commit | 665205327d0db5765de4b6d7576f7dad0be305a9 (patch) | |
| tree | 1f726f552908e5b3d57665b5c591266a8c0abd58 /src/engine/shared | |
| parent | e79bfb243cd24f2b97467d2d087782d61e985753 (diff) | |
| download | zcatch-665205327d0db5765de4b6d7576f7dad0be305a9.tar.gz zcatch-665205327d0db5765de4b6d7576f7dad0be305a9.zip | |
added lost datadir override feature
Diffstat (limited to 'src/engine/shared')
| -rw-r--r-- | src/engine/shared/storage.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp index 1d0e2f78..6f2399d7 100644 --- a/src/engine/shared/storage.cpp +++ b/src/engine/shared/storage.cpp @@ -18,7 +18,7 @@ public: m_aDatadir[0] = 0; } - int Init(const char *pApplicationName, const char *pArgv0) + int Init(const char *pApplicationName, int NumArgs, const char **ppArguments) { char aPath[1024] = {0}; fs_storage_path(pApplicationName, m_aApplicationSavePath, sizeof(m_aApplicationSavePath)); @@ -39,8 +39,18 @@ public: str_format(aPath, sizeof(aPath), "%s/demos", m_aApplicationSavePath); fs_makedir(aPath); } + + // check for datadir override + for(int i = 1; i < NumArgs; i++) + { + if(ppArguments[i][0] == '-' && ppArguments[i][1] == 'd' && ppArguments[i][2] == 0 && NumArgs - i > 1) + { + str_copy(m_aDatadir, ppArguments[i+1], sizeof(m_aDatadir)); + break; + } + } - return FindDatadir(pArgv0); + return FindDatadir(ppArguments[0]); } int FindDatadir(const char *pArgv0) @@ -184,10 +194,10 @@ public: return 0; } - static IStorage *Create(const char *pApplicationName, const char *pArgv0) + static IStorage *Create(const char *pApplicationName, int NumArgs, const char **ppArguments) { CStorage *p = new CStorage(); - if(p->Init(pApplicationName, pArgv0)) + if(p->Init(pApplicationName, NumArgs, ppArguments)) { delete p; p = 0; @@ -196,4 +206,4 @@ public: } }; -IStorage *CreateStorage(const char *pApplicationName, const char *pArgv0) { return CStorage::Create(pApplicationName, pArgv0); } +IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments) { return CStorage::Create(pApplicationName, NumArgs, ppArguments); } |