public SaveFileTo ( ulong hash, string extractPath, string fullName ) : void | ||
hash | ulong | |
extractPath | string | |
fullName | string | |
return | void |
public override void SaveFileTo(ulong hash, string extractPath, string fullName)
{
EncodingEntry encInfo;
if (GetEncodingEntry(hash, out encInfo))
{
SaveFileTo(encInfo.Key, extractPath, fullName);
return;
}
if (RootHandler is OwRootHandler)
{
OWRootEntry entry;
if ((RootHandler as OwRootHandler).GetEntry(hash, out entry))
{
if ((entry.baseEntry.ContentFlags & ContentFlags.Bundle) != ContentFlags.None)
{
if (Encoding.GetEntry(entry.pkgIndex.bundleContentKey, out encInfo))
{
using (Stream bundle = OpenFile(encInfo.Key))
{
string fullPath = Path.Combine(extractPath, fullName);
string dir = Path.GetDirectoryName(fullPath);
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
using (var fileStream = File.Open(fullPath, FileMode.Create))
{
bundle.Position = entry.pkgIndexRec.Offset;
bundle.CopyBytes(fileStream, entry.pkgIndexRec.Size);
}
}
return;
}
}
}
}
if (CASCConfig.ThrowOnFileNotFound)
throw new FileNotFoundException(fullName);
}
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)); } }); }