diff options
Diffstat (limited to 'dep/CascLib/src/CascFiles.cpp')
-rw-r--r-- | dep/CascLib/src/CascFiles.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/dep/CascLib/src/CascFiles.cpp b/dep/CascLib/src/CascFiles.cpp index f2546e1befa..550b558f7da 100644 --- a/dep/CascLib/src/CascFiles.cpp +++ b/dep/CascLib/src/CascFiles.cpp @@ -1410,6 +1410,23 @@ static LPTSTR CheckForDirectory(LPCTSTR szParentFolder, LPCTSTR szSubFolder) return szLocalPath; } +static LPTSTR CheckForDirectories(LPCTSTR szParentFolder, ...) +{ + LPCTSTR szSubDir; + va_list argList; + LPTSTR szFolder = NULL; + + va_start(argList, szParentFolder); + while((szSubDir = va_arg(argList, LPCTSTR)) != NULL) + { + if((szFolder = CheckForDirectory(szParentFolder, szSubDir)) != NULL) + break; + } + va_end(argList); + + return szFolder; +} + //----------------------------------------------------------------------------- // Public functions @@ -1522,10 +1539,10 @@ DWORD CheckCascBuildFileDirs(CASC_BUILD_FILE & BuildFile, LPCTSTR szLocalPath) return dwErrCode; } -DWORD CheckOnlineStorage(PCASC_OPEN_STORAGE_ARGS pArgs, CASC_BUILD_FILE & BuildFile, DWORD dwFeatures) +DWORD CheckOnlineStorage(PCASC_OPEN_STORAGE_ARGS pArgs, CASC_BUILD_FILE & BuildFile, bool bOnlineStorage) { // If the online storage is required, we try to extract the product code - if((dwFeatures & CASC_FEATURE_ONLINE) && (pArgs->szCodeName != NULL)) + if((bOnlineStorage) && (pArgs->szCodeName != NULL)) { CASC_PATH<TCHAR> FilePath(pArgs->szLocalPath, _T("versions"), NULL); @@ -1554,31 +1571,22 @@ DWORD CheckArchiveFilesDirectories(TCascStorage * hs) { if((szDataPath = CheckForDirectory(hs->szRootPath, DataDirs[i])) != NULL) { - // If we found the data path, we also need to initialize the index path - // Check the config folder if((szConfigPath = CheckForDirectory(szDataPath, _T("config"))) != NULL) { // First, check for more common "data" subdirectory - if((szIndexPath = CheckForDirectory(szDataPath, _T("data"))) == NULL) - { - // Second, try the "darch" subdirectory (older builds of HOTS - Alpha) - szIndexPath = CheckForDirectory(szDataPath, _T("darch")); - } - - if(szIndexPath != NULL) + // Second, try the "darch" subdirectory (older builds of HOTS - Alpha) + if((szIndexPath = CheckForDirectories(szDataPath, _T("data"), _T("darch"), NULL)) != NULL) { hs->szDataPath = szDataPath; hs->szConfigPath = szConfigPath; hs->szIndexPath = szIndexPath; return ERROR_SUCCESS; } + CASC_FREE(szConfigPath); } + CASC_FREE(szDataPath); } - - CASC_FREE(szDataPath); - CASC_FREE(szConfigPath); - CASC_FREE(szIndexPath); } // One of the paths was not found |