SaveFileTo() public method

public SaveFileTo ( ulong hash, string extractPath, string fullName ) : void
hash ulong
extractPath string
fullName string
return void
Esempio n. 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)
                {
                    if (_casc.Encoding.GetEntry(file.MD5, out EncodingEntry enc))
                    {
                        _casc.SaveFileTo(enc.Key, Path.Combine("data", build, "install_files"), file.Name);
                    }

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

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

            cascHandler.SaveFileTo(file.FullName, ExtractPath, locale);
        }
Esempio n. 3
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            foreach (var file in files)
            {
                if (backgroundWorker1.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }

                try
                {
                    backgroundWorker1.ReportProgress((int)((float)++NumExtracted / (float)files.Count * 100));

                    CASC.SaveFileTo(file.Hash, ExtractPath, file.FullName);
                }
                catch (Exception exc)
                {
                    Logger.WriteLine("Unable to extract file {0}: {1}", file.FullName, exc.Message);
                }
            }
        }