aboutsummaryrefslogtreecommitdiff
path: root/dep/CascLib/src/CascOpenStorage.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-06-27 20:20:51 +0200
committerShauren <shauren.trinity@gmail.com>2021-06-27 20:20:51 +0200
commitb70f34b696c75dee9af1387d2e1536cd9edffa4b (patch)
treec53d89e5c84264d183cea463f6a214f5c0963911 /dep/CascLib/src/CascOpenStorage.cpp
parent0bbf3f7300895008a37796f3d5be7e8f23c9a143 (diff)
Dep/CascLib: Update to ladislav-zezula/CascLib@37a948bdb5f493b6a0959489baa07e1636002c3b
Diffstat (limited to 'dep/CascLib/src/CascOpenStorage.cpp')
-rw-r--r--dep/CascLib/src/CascOpenStorage.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/dep/CascLib/src/CascOpenStorage.cpp b/dep/CascLib/src/CascOpenStorage.cpp
index 00b3797eb68..584b79a38a1 100644
--- a/dep/CascLib/src/CascOpenStorage.cpp
+++ b/dep/CascLib/src/CascOpenStorage.cpp
@@ -135,6 +135,11 @@ TCascStorage * TCascStorage::Release()
// Need this to be atomic to make multi-threaded file opens work
if(CascInterlockedDecrement(&dwRefCount) == 0)
{
+ // Release all references in the socket cache
+ if(dwFeatures & CASC_FEATURE_ONLINE)
+ sockets_set_caching(false);
+
+ // Delete the object and return NULL
delete this;
return NULL;
}
@@ -162,16 +167,16 @@ void * ProbeOutputBuffer(void * pvBuffer, size_t cbLength, size_t cbMinLength, s
static LPTSTR CheckForIndexDirectory(TCascStorage * hs, LPCTSTR szSubDir)
{
- LPTSTR szIndexPath;
+ TCHAR szIndexPath[MAX_PATH];
// Combine the index path
- szIndexPath = CombinePath(hs->szDataPath, szSubDir);
- if (!DirectoryExists(szIndexPath))
- {
- CASC_FREE(szIndexPath);
- }
+ CombinePath(szIndexPath, _countof(szIndexPath), hs->szDataPath, szSubDir, NULL);
- return szIndexPath;
+ // Check whether the path exists
+ if(!DirectoryExists(szIndexPath))
+ return NULL;
+
+ return CascNewStr(szIndexPath);
}
// Inserts an entry from the text build file
@@ -1168,9 +1173,14 @@ static DWORD LoadCascStorage(TCascStorage * hs, PCASC_OPEN_STORAGE_ARGS pArgs)
if(ExtractVersionedArgument(pArgs, FIELD_OFFSET(CASC_OPEN_STORAGE_ARGS, szBuildKey), &szBuildKey) && szBuildKey != NULL)
hs->szBuildKey = CascNewStrT2A(szBuildKey);
- // For online storages, we need to load CDN servers
- if ((dwErrCode == ERROR_SUCCESS) && (hs->dwFeatures & CASC_FEATURE_ONLINE))
+ // Special handling to online storages
+ if(hs->dwFeatures & CASC_FEATURE_ONLINE)
{
+ // Enable caching of the sockets. This will add references
+ // to all existing and all future sockets
+ sockets_set_caching(true);
+
+ // For online storages, we need to load CDN servers
dwErrCode = LoadCdnsFile(hs);
}