Example #1
0
        public async Task ExtractInstallFiles(Action <int> progressCallback)
        {
            if (_casc == null)
            {
                return;
            }

            IProgress <int> progress = new Progress <int>(progressCallback);

            await Task.Run(() =>
            {
                var installFiles = _casc.Install.GetEntries("Windows");
                var build        = _casc.Config.BuildName;

                int numFiles = installFiles.Count();
                int numDone  = 0;

                foreach (var file in installFiles)
                {
                    _casc.ExtractFile(_casc.Encoding.GetEntry(file.MD5).Key, "data\\" + build + "\\install_files", file.Name);

                    progress.Report((int)(++numDone / (float)numFiles * 100.0f));
                }
            });
        }
Example #2
0
        private void ExtractFile(CASCFile file)
        {
            if (backgroundWorker1.CancellationPending)
            {
                throw new OperationCanceledException();
            }

            backgroundWorker1.ReportProgress((int)((float)++NumExtracted / (float)NumFiles * 100));

            var rootInfos = cascHandler.GetRootInfo(file.Hash);

            if (rootInfos == null)
            {
                return;
            }

            foreach (var rootInfo in rootInfos)
            {
                // only enUS atm
                if ((rootInfo.Block.Flags & locale) == 0)
                {
                    continue;
                }

                var encInfo = cascHandler.GetEncodingInfo(rootInfo.MD5);

                if (encInfo == null)
                {
                    continue;
                }

                foreach (var key in encInfo.Keys)
                {
                    cascHandler.ExtractFile(key, ExtractPath, file.FullName);
                    return;
                }
            }
        }