CASCExplorer.CASCHandler.SaveFileTo C# (CSharp) Метод

SaveFileTo() публичный Метод

public SaveFileTo ( ulong hash, string extractPath, string fullName ) : void
hash ulong
extractPath string
fullName string
Результат 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);
        }

Usage 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)
                {
                    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));
                }
            });
        }
All Usage Examples Of CASCExplorer.CASCHandler::SaveFileTo