2020// Limit for "orphaned" items - those that are in index files, but are not in ENCODING manifest
2121#define CASC_MAX_ORPHANED_ITEMS 0x100
2222
23+ // -----------------------------------------------------------------------------
24+ // Local variables
25+
26+ static PFNPROGRESSCALLBACK PfnProgressCallback = NULL ;
27+ static void * PtrProgressParam = NULL ;
28+
2329// -----------------------------------------------------------------------------
2430// TCascStorage service functions
2531
@@ -32,7 +38,7 @@ TCascStorage::TCascStorage()
3238 dwRefCount = 1 ;
3339
3440 szRootPath = szDataPath = szIndexPath = szBuildFile = szCdnServers = szCdnPath = szCodeName = NULL ;
35- szProductName = szErrorMsg = NULL ;
41+ szProductName = NULL ;
3642 szIndexFormat = NULL ;
3743 szRegion = NULL ;
3844
@@ -44,6 +50,12 @@ TCascStorage::TCascStorage()
4450 BuildFileType = CascBuildNone;
4551
4652 LocalFiles = TotalFiles = EKeyEntries = OrphanItems = SkippedItems = EKeyLength = FileOffsetBits = 0 ;
53+
54+ // Take the callback param and data. Zero the global pointers
55+ PfnCallback = PfnProgressCallback;
56+ PtrCallbackParam = PtrProgressParam;
57+ PfnProgressCallback = NULL ;
58+ PtrProgressParam = NULL ;
4759}
4860
4961TCascStorage::~TCascStorage ()
@@ -401,6 +413,10 @@ static int LoadEncodingManifest(TCascStorage * hs)
401413 DWORD cbEncodingFile = 0 ;
402414 int nError = ERROR_SUCCESS;
403415
416+ // Inform the user about what we are doing
417+ if (hs->PfnCallback && hs->PfnCallback (hs->PtrCallbackParam , " Loading ENCODING manifest" , NULL , 0 , 0 ))
418+ return ERROR_CANCELLED;
419+
404420 // Load the entire encoding file to memory
405421 pbEncodingFile = LoadInternalFileToMemory (hs, &hs->EncodingCKey , &cbEncodingFile);
406422 if (pbEncodingFile != NULL && cbEncodingFile != 0 )
@@ -728,6 +744,10 @@ static int LoadDownloadManifest(TCascStorage * hs)
728744 DWORD cbDownloadFile = 0 ;
729745 int nError = ERROR_SUCCESS;
730746
747+ // Inform the user about what we are doing
748+ if (hs->PfnCallback && hs->PfnCallback (hs->PtrCallbackParam , " Loading DOWNLOAD manifest" , NULL , 0 , 0 ))
749+ return ERROR_CANCELLED;
750+
731751 // Load the entire DOWNLOAD file to memory
732752 pbDownloadFile = LoadInternalFileToMemory (hs, pCKeyEntry, &cbDownloadFile);
733753 if (pbDownloadFile != NULL && cbDownloadFile != 0 )
@@ -761,6 +781,10 @@ static int LoadInstallManifest(TCascStorage * hs)
761781 DWORD cbInstallFile = 0 ;
762782 int nError = ERROR_SUCCESS;
763783
784+ // Inform the user about what we are doing
785+ if (hs->PfnCallback && hs->PfnCallback (hs->PtrCallbackParam , " Loading INSTALL manifest" , NULL , 0 , 0 ))
786+ return ERROR_CANCELLED;
787+
764788 // Load the entire DOWNLOAD file to memory
765789 pbInstallFile = LoadInternalFileToMemory (hs, pCKeyEntry, &cbInstallFile);
766790 if (pbInstallFile != NULL && cbInstallFile != 0 )
@@ -818,7 +842,11 @@ static int LoadBuildManifest(TCascStorage * hs, DWORD dwLocaleMask)
818842 pCKeyEntry = (hs->VfsRoot .ContentSize != CASC_INVALID_SIZE) ? &hs->VfsRoot : &hs->RootFile ;
819843 pCKeyEntry = FindCKeyEntry_CKey (hs, pCKeyEntry->CKey );
820844
821- // Load the entire ROOT file to memory. Ignore
845+ // Inform the user about what we are doing
846+ if (hs->PfnCallback && hs->PfnCallback (hs->PtrCallbackParam , " Loading ROOT manifest" , NULL , 0 , 0 ))
847+ return ERROR_CANCELLED;
848+
849+ // Load the entire ROOT file to memory
822850 pbRootFile = LoadInternalFileToMemory (hs, pCKeyEntry, &cbRootFile);
823851 if (pbRootFile != NULL )
824852 {
@@ -1134,6 +1162,12 @@ static int LoadCascStorage(TCascStorage * hs, DWORD dwLocaleMask)
11341162// -----------------------------------------------------------------------------
11351163// Public functions
11361164
1165+ void WINAPI CascSetProgressCallback (PFNPROGRESSCALLBACK PtrUserCallback, void * PtrUserParam)
1166+ {
1167+ PfnProgressCallback = PtrUserCallback;
1168+ PtrProgressParam = PtrUserParam;
1169+ }
1170+
11371171bool WINAPI CascOpenStorage (LPCTSTR szPath, DWORD dwLocaleMask, HANDLE * phStorage)
11381172{
11391173 TCascStorage * hs;
0 commit comments