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

Function LoadCascStorage

src/External/CascLib/src/CascOpenStorage.cpp:1092–1264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1090}
1091
1092static DWORD LoadCascStorage(TCascStorage * hs, PCASC_OPEN_STORAGE_ARGS pArgs, LPCTSTR szMainFile, CBLD_TYPE BuildFileType, DWORD dwFeatures)
1093{
1094 LPCTSTR szCdnHostUrl = NULL;
1095 LPCTSTR szCodeName = NULL;
1096 LPCTSTR szRegion = NULL;
1097 LPCTSTR szBuildKey = NULL;
1098 DWORD dwLocaleMask = 0;
1099 DWORD dwErrCode = ERROR_SUCCESS;
1100
1101 // Pass the argument array to the storage
1102 hs->pArgs = pArgs;
1103
1104 // Extract optional arguments
1105 ExtractVersionedArgument(pArgs, FIELD_OFFSET(CASC_OPEN_STORAGE_ARGS, dwLocaleMask), &dwLocaleMask);
1106
1107 // Extract the CDN host URL
1108 if(ExtractVersionedArgument(pArgs, FIELD_OFFSET(CASC_OPEN_STORAGE_ARGS, szCdnHostUrl), &szCdnHostUrl) && szCdnHostUrl != NULL)
1109 hs->szCdnHostUrl = CascNewStr(szCdnHostUrl);
1110
1111 // Extract the product code name
1112 if(ExtractVersionedArgument(pArgs, FIELD_OFFSET(CASC_OPEN_STORAGE_ARGS, szCodeName), &szCodeName) && szCodeName != NULL)
1113 hs->szCodeName = CascNewStr(szCodeName);
1114
1115 // Extract the region (optional)
1116 if(ExtractVersionedArgument(pArgs, FIELD_OFFSET(CASC_OPEN_STORAGE_ARGS, szRegion), &szRegion) && szRegion != NULL)
1117 hs->szRegion = CascNewStrT2A(szRegion);
1118
1119 // Extract the build key (optional)
1120 if(ExtractVersionedArgument(pArgs, FIELD_OFFSET(CASC_OPEN_STORAGE_ARGS, szBuildKey), &szBuildKey) && szBuildKey != NULL)
1121 hs->szBuildKey = CascNewStrT2A(szBuildKey);
1122
1123 // Merge features
1124 hs->dwFeatures |= (dwFeatures & (CASC_FEATURE_DATA_ARCHIVES | CASC_FEATURE_DATA_FILES | CASC_FEATURE_ONLINE));
1125 hs->dwFeatures |= (pArgs->dwFlags & CASC_FEATURE_FORCE_DOWNLOAD);
1126 hs->dwFeatures |= (BuildFileType == CascVersions) ? CASC_FEATURE_ONLINE : 0;
1127 hs->BuildFileType = BuildFileType;
1128
1129 // Copy the name of the build file
1130 hs->szMainFile = CascNewStr(szMainFile);
1131
1132 // Construct the root path from the name of the build file
1133 CASC_PATH<TCHAR> RootPath(szMainFile, NULL);
1134 hs->szRootPath = RootPath.New(true);
1135
1136 // If either of the root path or build file is known, it's an error
1137 if(hs->szRootPath == NULL || hs->szMainFile == NULL)
1138 {
1139 dwErrCode = ERROR_NOT_ENOUGH_MEMORY;
1140 }
1141
1142 // Initialize variables for local CASC storages
1143 if(dwErrCode == ERROR_SUCCESS)
1144 {
1145 // For local (game) storages, we need the data and indices subdirectory
1146 if(hs->dwFeatures & CASC_FEATURE_DATA_ARCHIVES)
1147 {
1148 if(CheckArchiveFilesDirectories(hs) != ERROR_SUCCESS)
1149 hs->dwFeatures &= ~CASC_FEATURE_DATA_ARCHIVES;

Callers 1

CascOpenStorageExFunction · 0.85

Calls 15

ExtractVersionedArgumentFunction · 0.85
CascNewStrFunction · 0.85
CascNewStrT2AFunction · 0.85
CheckDataFilesDirectoryFunction · 0.85
sockets_set_cachingFunction · 0.85
LoadMainFileFunction · 0.85
LoadCdnConfigFileFunction · 0.85
LoadCdnBuildFileFunction · 0.85
InitCKeyArrayFunction · 0.85
LoadIndexFilesFunction · 0.85
LoadEncodingManifestFunction · 0.85

Tested by

no test coverage detected