Beispiel #1
0
        public override void ApplyChunk(ZiPatchConfig config)
        {
            switch (Operation)
            {
            // Default behaviour falls through to AddFile, though this shouldn't happen
            case OperationKind.AddFile:
            default:
                // TODO: Check this. I *think* boot usually creates all the folders like sqpack, movie, etc., so this might be kind of a hack
                TargetFile.CreateDirectoryTree(config.GamePath);

                var fileStream = config.Store == null?
                                 TargetFile.OpenStream(config.GamePath, FileMode.OpenOrCreate) :
                                     TargetFile.OpenStream(config.Store, config.GamePath, FileMode.OpenOrCreate);

                if (FileOffset == 0)
                {
                    fileStream.SetLength(0);
                }

                fileStream.Seek(FileOffset, SeekOrigin.Begin);
                foreach (var block in CompressedData)
                {
                    block.DecompressInto(fileStream);
                }

                break;

            case OperationKind.RemoveAll:
                foreach (var file in SqexFile.GetAllExpansionFiles(config.GamePath, ExpansionId).Where(RemoveAllFilter))
                {
                    File.Delete(file);
                }
                break;

            case OperationKind.DeleteFile:
                File.Delete(config.GamePath + "/" + TargetFile.RelativePath);
                break;

            case OperationKind.MakeDirTree:
                Directory.CreateDirectory(config.GamePath + "/" + TargetFile.RelativePath);
                break;
            }
        }