Example #1
0
        /// <summary>
        /// Another file was fetched!
        /// </summary>
        /// <param name="FileStream">Stream of the file that was fetched.</param>
        private void m_Requester_OnFetchedFile(MemoryStream MemStream)
        {
            string TmpPath = RelativePath + "Tmp\\" + Path.GetFileName(m_PatchDiff[m_NumFilesDownloaded].Address);

            using (BinaryWriter Writer = new BinaryWriter(File.Create(TmpPath), Encoding.Default))
            {
                Writer.Write(MemStream.ToArray());
                Writer.Flush();
            }

            //Delete original file...
            if (File.Exists(RelativePath + m_PatchDiff[m_NumFilesDownloaded].Address))
            {
                File.Delete(RelativePath + m_PatchDiff[m_NumFilesDownloaded].Address);
            }

            //...and replace it with the downloaded one!
            FileManager.CreateDirectory(RelativePath + m_PatchDiff[m_NumFilesDownloaded].Address);
            File.Move(TmpPath, RelativePath + m_PatchDiff[m_NumFilesDownloaded].Address);

            if ((m_NumFilesDownloaded + 1) != m_PatchDiff.Count)
            {
                Interlocked.Increment(ref m_NumFilesDownloaded);
                m_Requester.FetchFile(m_PatchDiff[m_NumFilesDownloaded].URL);

                this.Invoke(new MethodInvoker(() =>
                {
                    PrgTotal.Step = (int)((float)(m_PatchDiff.Count * 100) / (float)PrgTotal.Width);
                    PrgTotal.PerformStep();
                    PrgFile.Value = 0;
                }));
            }
            else
            {
                MessageBox.Show("Your client is up to date!\n Exiting...");
                if (File.Exists(RelativePath + "Project Dollhouse Client.exe"))
                {
                    Process.Start(RelativePath + "Project Dollhouse Client.exe");
                }

                Environment.Exit(0);
            }
        }
Example #2
0
        /// <summary>
        /// Another file was fetched!
        /// </summary>
        /// <param name="FileStream">Stream of the file that was fetched.</param>
        private void m_Requester_OnFetchedFile(MemoryStream MemStream)
        {
            string TmpPath;

            if (!m_PatchingUpdater)
            {
                TmpPath = RelativePath + "Tmp\\" + Path.GetFileName(m_PatchDiff[m_NumFilesDownloaded].Address);
            }
            else
            {
                TmpPath = RelativePath + "Tmp\\" + Path.GetFileNameWithoutExtension(m_PatchDiff[m_NumFilesDownloaded].Address) +
                          " NEW" + Path.GetExtension(m_PatchDiff[m_NumFilesDownloaded].Address);
            }

            using (BinaryWriter Writer = new BinaryWriter(File.Create(TmpPath), Encoding.Default))
            {
                Writer.Write(MemStream.ToArray());
                Writer.Flush();
            }

            //Delete original file...
            if (File.Exists(RelativePath + m_PatchDiff[m_NumFilesDownloaded].Address))
            {
                File.Delete(RelativePath + m_PatchDiff[m_NumFilesDownloaded].Address);
            }

            //...and replace it with the downloaded one!
            FileManager.CreateDirectory(RelativePath + m_PatchDiff[m_NumFilesDownloaded].Address);
            File.Move(TmpPath, RelativePath + m_PatchDiff[m_NumFilesDownloaded].Address);

            if ((m_NumFilesDownloaded + 1) != m_PatchDiff.Count)
            {
                Interlocked.Increment(ref m_NumFilesDownloaded);
                m_NumFilesDownloaded++;
                m_Requester.FetchFile(m_PatchDiff[m_NumFilesDownloaded].URL);

                this.Invoke(new MethodInvoker(() =>
                {
                    PrgTotal.Step = (int)((float)(m_PatchDiff.Count * 100) / (float)PrgTotal.Width);
                    PrgTotal.PerformStep();
                    PrgFile.Value = 0;
                }));
            }
            else
            {
                if (!m_PatchingUpdater)
                {
                    MessageBox.Show("Your client is up to date!\n Exiting...");
                    if (File.Exists(RelativePath + "Project Dollhouse Client.exe"))
                    {
                        Process.Start(RelativePath + "Project Dollhouse Client.exe");
                    }

                    Environment.Exit(0);
                }
                else
                {
                    MessageBox.Show("Done patching updater, please restart from desktop!");

                    //Desktop shortcuts points to new patcher, wich will rename itself when starting (see Program.cs).
                    if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "Project Dollhouse.lnk"))
                    {
                        Program.ModifyShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) +
                                               "Project Dollhouse.lnk", RelativePath + "PDPatcher NEW.exe");
                    }

                    //TODO: Update start menu shortcut?

                    Environment.Exit(0);
                }
            }
        }