Пример #1
0
 public void ExtractFile(string path, string outputdir)
 {
     if (UseExternalUnzipper)
     {
         ProcessStartInfo psi = new ProcessStartInfo();
         psi.FileName  = PathToExternalUnzipper;
         psi.Arguments = ExternalUnzipperArguments.Replace("%1%", path).Replace("%2%", outputdir);
         Process myProcess = Process.Start(psi);
         myProcess.WaitForExit();
     }
     else
     {
         ZipManager.ExtractToDirectory(path, outputdir);
     }
 }
Пример #2
0
        private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            DownloadJob job = jobQueue[jobQueue.Count - 1];

            WebClient wc = (WebClient)e.UserState;
            string    header_contentDisposition = wc.ResponseHeaders["content-disposition"];

            filename = job.path + new ContentDisposition(header_contentDisposition).FileName;

            FileStream fs = new FileStream(filename, FileMode.Create);

            fs.Write(e.Result, 0, e.Result.Length);
            fs.Close();

            ZipManager.ExtractToDirectory(filename, job.path);

            File.Delete(filename);
            jobQueue.RemoveAt(jobQueue.Count - 1);
            downloadNextJob();
        }
Пример #3
0
        public void ExtractPhysicsRBZ(bool overwriteSubFolder)
        {
            if (!Directory.Exists("Physics") && !File.Exists("physics.rbz"))
            {
                DialogResult dr = MessageBox.Show("Neither the file 'physics.rbz' nor the subfolder 'Physics' could be found." +
                                                  "\nPlease start this tool from inside an RBR folder." +
                                                  "\nIf this is already the case, please restore 'physics.rbz'." +
                                                  "\n\nAlternatively, the NGP plugin could be downloaded now to rectify the situation. Download now?", "", MessageBoxButtons.OKCancel);
                if (dr == DialogResult.OK)
                {
                    DownloadPluginNGP();
                }
                else
                {
                    Environment.Exit(-1);
                }
            }

            if (Directory.Exists("Physics"))
            {
                if (overwriteSubFolder)
                {
                    //Directory.Delete("Physics", true);
                    //while (Directory.Exists("Physics")) System.Threading.Thread.Sleep(10);
                    HelperFunctions.DirectoryDeleteAllFilesRecursively("Physics");
                }
                else
                {
                    return;
                }
            }
            if (File.Exists("physics.rbz"))
            {
                ZipManager.ExtractToDirectory("physics.rbz", ".");
            }
        }
Пример #4
0
        //force=true: do it even if there is no desired change, required for updating physics.rbz after an NGP plugin download/update
        private void CopyNGPPhysics(bool replaceSchoolFiles, bool force)
        {
            for (int i = 0; i < 8; i++)
            {
                if (!force && DesiredCarList[i].Equals(CurrentCarList[i]))
                {
                    continue;
                }
                Car c = DesiredCarList[i];

                //if it is a car unknown in carList.ini skip it
                if (c.physics == null)
                {
                    continue;
                }

                //copy NGP physics if it exists
                string sourceFolder = "RBRCIT\\physics\\" + c.physics;
                string destFolder   = "Physics\\" + PhysicsFolders[i];

                if (Directory.Exists(sourceFolder))
                {
                    if (Directory.Exists(destFolder))
                    {
                        HelperFunctions.DirectoryDeleteAllFilesRecursively(destFolder);
                    }
                    HelperFunctions.DirectoryCopy(sourceFolder, destFolder);
                }
            }

            //special handling for school car
            if (replaceSchoolFiles)
            {
                File.Copy("RBRCIT\\physics\\" + DesiredCarList[5].physics + "\\setups\\d_gravel.lsp", "Physics\\school\\gravel.lsp", true);
                File.Copy("RBRCIT\\physics\\" + DesiredCarList[5].physics + "\\setups\\d_gravel.lsp", "Physics\\school\\sfgravel.lsp", true);
                File.Copy("RBRCIT\\physics\\" + DesiredCarList[5].physics + "\\setups\\d_tarmac.lsp", "Physics\\school\\tarmac.lsp", true);

                string[] lines = File.ReadAllLines("Physics\\school\\sfgravel.lsp");
                int      j     = 0;
                foreach (string line in lines)
                {
                    if (line.Contains("FrontRollBarStiffness"))
                    {
                        lines[j] = "   FrontRollBarStiffness\t\t\t0";
                    }
                    if (line.Contains("RearRollBarStiffness"))
                    {
                        lines[j] = "   RearRollBarStiffness\t\t\t\t0";
                    }
                    j++;
                }
                File.WriteAllLines("Physics\\school\\sfgravel.lsp", lines);
            }
            else
            {
                HelperFunctions.DirectoryCopy("RBRCIT\\physics\\school", "Physics\\school");
            }

            //create physics.rbz from subfolder
            ZipManager.CreateFromDirectory("Physics", "physics.rbz", true);
        }