示例#1
0
        private void OnPatchingComplete(object sender, OperationCompleteArgs args)
        {
            if (!_oldPatchingStyle && _needsPatching)
            {
                DirectoryInfo dir     = new DirectoryInfo(_patchFolder);
                FileInfo[]    patches = dir.GetFiles("*.patch");

                for (int i = 0; i < patches.Length; i++)
                {
                    if (patches[i].FullName != _patcher.CombinedPatchFile)
                    {
                        File.Delete(patches[i].FullName);
                    }
                }

                string tempFile = _patcher.CombinedPatchFile;
                CRC32  crc32    = new CRC32();

                ulong hash = 0;
                for (int i = 0; i < _allPatchFiles.Count; i++)
                {
                    hash += (ulong)crc32.GetCrc32(File.Open(_allPatchFiles[i].FullName, FileMode.Open));
                }

                _patchFile = Path.Combine(_patchFolder, hash.ToString() + ".patch");
                File.Move(tempFile, _patchFile);
            }
            else
            {
                DirectoryInfo dir   = new DirectoryInfo(_patchFolder);
                FileInfo[]    patch = dir.GetFiles("*.patch");

                if (patch.Length >= 1)
                {
                    _patchFile = patch[0].FullName;
                }
            }

            if (this.Visible)
            {
                Invoke((MethodInvoker) delegate
                {
                    cancelBtn.Text       = "Close";
                    _closeTimer          = new System.Timers.Timer(1000);
                    _closeTimer.Elapsed += new System.Timers.ElapsedEventHandler(closeTimer_Elapsed);
                    _closeTimer.Start();
                });
            }
        }
示例#2
0
        private void OnPatchingComplete( object sender, OperationCompleteArgs args )
        {
            if (!_oldPatchingStyle && _needsPatching)
            {
                DirectoryInfo dir = new DirectoryInfo(_patchFolder);
                FileInfo[] patches = dir.GetFiles("*.patch");

                for (int i = 0; i < patches.Length; i++)
                    if( patches[i].FullName != _patcher.CombinedPatchFile)
                        File.Delete(patches[i].FullName);

                string tempFile = _patcher.CombinedPatchFile;
                CRC32 crc32 = new CRC32();

                ulong hash = 0;
                for( int i = 0; i < _allPatchFiles.Count; i++ )
                    hash += (ulong)crc32.GetCrc32(File.Open(_allPatchFiles[i].FullName, FileMode.Open));

                _patchFile = Path.Combine(_patchFolder, hash.ToString() + ".patch");
                File.Move(tempFile, _patchFile);
            }
            else
            {
                DirectoryInfo dir = new DirectoryInfo(_patchFolder);
                FileInfo[] patch = dir.GetFiles("*.patch");

                if (patch.Length >= 1)
                    _patchFile = patch[0].FullName;
            }

            if (this.Visible)
                Invoke((MethodInvoker)delegate
                {
                    cancelBtn.Text = "Close";
                    _closeTimer = new System.Timers.Timer(1000);
                    _closeTimer.Elapsed += new System.Timers.ElapsedEventHandler(closeTimer_Elapsed);
                    _closeTimer.Start();
                });
        }