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

Function FetchCascFile

src/External/CascLib/src/CascFiles.cpp:1278–1329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1276}
1277
1278DWORD FetchCascFile(
1279 TCascStorage * hs,
1280 LPCTSTR szRootPath,
1281 CPATH_TYPE PathType,
1282 LPBYTE pbEKey,
1283 LPCTSTR szExtension,
1284 CASC_PATH<TCHAR> & LocalPath)
1285{
1286 LPCTSTR szCdnServers = hs->szCdnServers;
1287 DWORD dwErrCode = ERROR_SUCCESS;
1288 TCHAR szCdnServer[MAX_PATH] = _T("");
1289
1290 // First, construct the local path
1291 LocalPath.Create(szRootPath, GetSubFolder(PathType), NULL);
1292 LocalPath.AppendEKey(pbEKey);
1293 LocalPath.AppendString(szExtension, false);
1294
1295 // Check whether the file already exists
1296 if(!FileAlreadyExists(LocalPath))
1297 {
1298 // If this is not an online version, do nothing and return error
1299 if(!(hs->dwFeatures & CASC_FEATURE_ONLINE))
1300 return ERROR_FILE_NOT_FOUND;
1301
1302 // Force-create the local path
1303 if((dwErrCode = ForcePathExist(LocalPath, true)) != ERROR_SUCCESS)
1304 return dwErrCode;
1305
1306 // Try all download servers
1307 while((szCdnServers = ExtractCdnServerName(szCdnServer, _countof(szCdnServer), szCdnServers)) != NULL)
1308 {
1309 CASC_PATH<TCHAR> RemotePath(URL_SEP_CHAR);
1310
1311 // Construct the full remote URL path
1312 RemotePath.Create(szCdnServer, hs->szCdnPath, GetSubFolder(PathType), NULL);
1313 RemotePath.AppendEKey(pbEKey);
1314 RemotePath.AppendString(szExtension, false);
1315
1316 // Attempt to download the file
1317 dwErrCode = HttpDownloadFile(RemotePath, LocalPath, NULL, 0, 0);
1318
1319 // Stop on low memory condition, as it will most likely
1320 // end up with low memory on next download
1321 if(dwErrCode == ERROR_SUCCESS || dwErrCode == ERROR_NOT_ENOUGH_MEMORY)
1322 return dwErrCode;
1323 }
1324
1325 // Sorry, the file was not found
1326 dwErrCode = ERROR_FILE_NOT_FOUND;
1327 }
1328 return dwErrCode;
1329}
1330
1331DWORD FetchCascFile(TCascStorage * hs, CPATH_TYPE PathType, LPBYTE pbEKey, LPCTSTR szExtension, CASC_PATH<TCHAR> & LocalPath, PCASC_ARCHIVE_INFO pArchiveInfo)
1332{

Callers 3

FetchAndLoadConfigFileFunction · 0.85
OpenDataStreamFunction · 0.85
LoadArchiveIndexFilesFunction · 0.85

Calls 9

GetSubFolderFunction · 0.85
FileAlreadyExistsFunction · 0.85
ForcePathExistFunction · 0.85
ExtractCdnServerNameFunction · 0.85
HttpDownloadFileFunction · 0.85
AppendEKeyMethod · 0.80
AppendStringMethod · 0.80
CreateMethod · 0.45
FindObjectMethod · 0.45

Tested by

no test coverage detected