Example #1
0
        private static bool InstallPatch(string patchPath, string gamePath)
        {
            try
            {
                Log.Information("Installing {0} to {1}", patchPath, gamePath);

                using var patchFile = ZiPatchFile.FromFileName(patchPath);

                using (var store = new SqexFileStreamStore())
                {
                    var config = new ZiPatchConfig(gamePath)
                    {
                        Store = store
                    };

                    foreach (var chunk in patchFile.GetChunks())
                    {
                        chunk.ApplyChunk(config);
                    }
                }

                Log.Information("Patch {0} installed", patchPath);

                return(true);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Patch install failed.");
                return(false);
            }
        }
        public override void ApplyChunk(ZiPatchConfig config)
        {
            TargetFile.ResolvePath(config.Platform);

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

            SqpackDatFile.WriteEmptyFileBlockAt(file, BlockOffset, BlockNumber);
        }
        public override void ApplyChunk(ZiPatchConfig config)
        {
            TargetFile.ResolvePath(config.Platform);

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

            file.WriteFromOffset(HeaderData, HeaderKind == TargetHeaderKind.Version ? 0 : HEADER_SIZE);
        }
        public override void ApplyChunk(ZiPatchConfig config)
        {
            TargetFile.ResolvePath(config.Platform);

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

            file.WriteFromOffset(BlockData, BlockOffset);
            file.Wipe(BlockDeleteNumber);
        }
Example #5
0
 public override void ApplyChunk(ZiPatchConfig config)
 {
     try
     {
         Directory.Delete(config.GamePath + DirName);
     }
     catch (Exception e)
     {
         Log.Debug(e, $"Ran into {this}, failed at deleting the dir.");
         throw;
     }
 }
Example #6
0
        public override void ApplyChunk(ZiPatchConfig config)
        {
            switch (OptionKind)
            {
            case ApplyOptionKind.IgnoreMissing:
                config.IgnoreMissing = OptionValue;
                break;

            case ApplyOptionKind.IgnoreOldMismatch:
                config.IgnoreOldMismatch = OptionValue;
                break;
            }
        }
Example #7
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;
            }
        }
 public override void ApplyChunk(ZiPatchConfig config)
 {
     config.Platform = Platform;
 }
 public virtual void ApplyChunk(ZiPatchConfig config)
 {
 }
 public override void ApplyChunk(ZiPatchConfig config)
 {
     Directory.CreateDirectory(config.GamePath + DirName);
 }