MCPcopy Create free account
hub / github.com/Scobalula/Greyhound / CascOpenStorageEx

Function CascOpenStorageEx

src/External/CascLib/src/CascOpenStorage.cpp:1363–1446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361// Public functions
1362
1363bool WINAPI CascOpenStorageEx(LPCTSTR szParams, PCASC_OPEN_STORAGE_ARGS pArgs, bool bOnlineStorage, HANDLE * phStorage)
1364{
1365 CASC_OPEN_STORAGE_ARGS LocalArgs = {sizeof(CASC_OPEN_STORAGE_ARGS)};
1366 TCascStorage * hs = NULL;
1367 LPTSTR szParamsCopy = NULL;
1368 DWORD dwErrCode = ERROR_SUCCESS;
1369
1370 // Supply the local args if not given by the caller
1371 pArgs = (pArgs != NULL) ? pArgs : &LocalArgs;
1372
1373 //
1374 // Parse the parameter string and put the parts into CASC_OPEN_STORAGE_ARGS
1375 //
1376 // Note that the parameter string is optional - is it possible
1377 // to enter all params purely in CASC_OPEN_STORAGE_ARGS structure.
1378 //
1379
1380 if(szParams != NULL)
1381 {
1382 // Make a copy of the parameters so we can tamper with them
1383 if((szParamsCopy = CascNewStr(szParams)) == NULL)
1384 {
1385 SetCascError(ERROR_NOT_ENOUGH_MEMORY);
1386 return false;
1387 }
1388
1389 // Parse the parameter string and put the corresponding parts
1390 // into the CASC_OPEN_STORAGE_ARGS structure.
1391 dwErrCode = ParseOpenParams(szParamsCopy, pArgs);
1392 }
1393
1394 // Verify the minimum arguments
1395 if(dwErrCode == ERROR_SUCCESS)
1396 {
1397 if(pArgs->szLocalPath == NULL || pArgs->szLocalPath[0] == 0)
1398 {
1399 dwErrCode = ERROR_INVALID_PARAMETER;
1400 }
1401 }
1402
1403 // Now we need to get the CASC main file, which is either
1404 // [*] .build.info - for current local storages
1405 // [*] .build.db - for older local storages
1406 // [*] versions - for cached online storages
1407 // If there is none of these and `bOnlineStorage` is specified,
1408 // CascLib will download it, as long as the product code was specified
1409 if(dwErrCode == ERROR_SUCCESS)
1410 {
1411 if((hs = new TCascStorage()) != NULL)
1412 {
1413 CASC_BUILD_FILE BuildFile = {NULL};
1414
1415 // Check for one of the supported main files (.build.info, .build.db, versions)
1416 if((dwErrCode = CheckCascBuildFileExact(BuildFile, pArgs->szLocalPath)) == ERROR_SUCCESS)
1417 {
1418 dwErrCode = LoadCascStorage(hs, pArgs, BuildFile.szFullPath, BuildFile.BuildFileType, CASC_FEATURE_DATA_ARCHIVES | CASC_FEATURE_DATA_FILES);
1419 }
1420

Callers 4

OnlineStorage_TestFunction · 0.85
mainFunction · 0.85
CascOpenStorageFunction · 0.85
CascOpenOnlineStorageFunction · 0.85

Calls 9

CascNewStrFunction · 0.85
SetCascErrorFunction · 0.85
ParseOpenParamsFunction · 0.85
CheckCascBuildFileExactFunction · 0.85
LoadCascStorageFunction · 0.85
CheckCascBuildFileDirsFunction · 0.85
CheckOnlineStorageFunction · 0.85
CASC_FREEFunction · 0.85
ReleaseMethod · 0.45

Tested by 2

OnlineStorage_TestFunction · 0.68
mainFunction · 0.68