Example #1
0
        private void ProcessFile(PatchDefinition definition, PatchDefinitionEntry entry)
        {
            switch (entry.Operation)
            {
            case PatchOperation.Added:
                _context.LogProgress(string.Format(_context.LocalizedMessages.UpdateProcessingNewFile, entry.RelativePath));
                HandleAddedFile(definition, entry);
                _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateProcessedNewFile, entry.RelativePath));
                break;

            case PatchOperation.Deleted:
                _context.LogProgress(string.Format(_context.LocalizedMessages.UpdateProcessingDeletedFile, entry.RelativePath));
                HandleDeletedFile(definition, entry);
                _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateProcessedDeletedFile, entry.RelativePath));
                break;

            case PatchOperation.Updated:
                _context.LogProgress(string.Format(_context.LocalizedMessages.UpdateProcessingUpdatedFile, entry.RelativePath));
                HandleUpdatedFile(definition, entry);
                _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateProcessedUpdatedFile, entry.RelativePath));
                break;

            case PatchOperation.ChangedAttributes:
                _context.LogProgress(string.Format(_context.LocalizedMessages.UpdateProcessingChangedAttributesFile, entry.RelativePath));
                HandleChangedAttributesFile(definition, entry);
                _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateProcessedChangedAttributesFile, entry.RelativePath));
                break;
            }
        }
Example #2
0
        private void HandleChangedAttributesFile(PatchDefinitionEntry entry)
        {
            var path = PathsManager.Combine(_context.Settings.GetGameFolderPath(_context.VersionTo), entry.RelativePath);
            var info = FilesManager.GetFileInfo(path);

            entry.Attributes  = info.Attributes;
            entry.LastWriting = info.LastWriting;
        }
Example #3
0
        private void HandleAddedFile(PatchDefinition definition, PatchDefinitionEntry entry)
        {
            var sourcePath      = PathsManager.Combine(_context.Settings.GetUncompressedPatchArchivePath(definition.From, definition.To), entry.RelativePath);
            var destinationPath = PathsManager.Combine(_context.Settings.GetGamePath(), entry.RelativePath);

            FilesManager.Delete(destinationPath);
            FilesManager.Move(sourcePath, destinationPath);

            EnsureDefinition(destinationPath, entry);
        }
Example #4
0
        private void HandleUpdatedFile(PatchDefinitionEntry entry)
        {
            var fromFile      = PathsManager.Combine(_context.Settings.GetGameFolderPath(_context.VersionFrom), entry.RelativePath);
            var toFile        = PathsManager.Combine(_context.Settings.GetGameFolderPath(_context.VersionTo), entry.RelativePath);
            var patchFile     = PathsManager.Combine(_context.Settings.GetPatchesTempFolderPath(), entry.RelativePath + ".patch");
            var signatureFile = PathsManager.Combine(_context.Settings.GetPatchesTempFolderPath(), entry.RelativePath + ".signature");

            DirectoriesManager.Create(PathsManager.GetDirectoryPath(patchFile));

            DeltaFileBuilder.Build(fromFile, toFile, patchFile, signatureFile);

            var path = PathsManager.Combine(_context.Settings.GetGameFolderPath(_context.VersionTo), entry.RelativePath);
            var info = FilesManager.GetFileInfo(path);

            entry.Attributes  = info.Attributes;
            entry.LastWriting = info.LastWriting;
        }
Example #5
0
        private void HandleUpdatedFile(PatchDefinition definition, PatchDefinitionEntry entry)
        {
            var filePath       = PathsManager.Combine(_context.Settings.GetGamePath(), entry.RelativePath);
            var fileBackupPath = filePath + ".bak";
            var patchPath      = PathsManager.Combine(_context.Settings.GetUncompressedPatchArchivePath(definition.From, definition.To), entry.RelativePath + ".patch");

            try
            {
                FilesManager.Rename(filePath, fileBackupPath);

                DeltaFileApplier.Apply(fileBackupPath, patchPath, filePath);

                EnsureDefinition(filePath, entry);
            }
            catch
            {
            }
            finally
            {
                FilesManager.Delete(fileBackupPath);
            }
        }
Example #6
0
 private void EnsureDefinition(string filePath, PatchDefinitionEntry entry)
 {
     File.SetAttributes(filePath, entry.Attributes);
     File.SetLastWriteTimeUtc(filePath, entry.LastWriting);
 }
Example #7
0
        private void HandleChangedAttributesFile(PatchDefinition definition, PatchDefinitionEntry entry)
        {
            var path = PathsManager.Combine(_context.Settings.GetGamePath(), entry.RelativePath);

            EnsureDefinition(path, entry);
        }
Example #8
0
        private void HandleDeletedFile(PatchDefinition definition, PatchDefinitionEntry entry)
        {
            var path = PathsManager.Combine(_context.Settings.GetGamePath(), entry.RelativePath);

            FilesManager.Delete(path);
        }