Пример #1
0
        public void Run(string[] args)
        {
            bool gui = true;

            foreach (var arg in args)
            {
                if (arg.ToUpper() == "COMMAND")
                {
                    gui = false;
                }
            }

            if (gui)
            {
                var dialog = new MainDiscoForm();
                dialog.ShowDialog();
                return;
            }
            else
            {
                //test stuff...
                MednadiscTester tester = new MednadiscTester();
                tester.TestDirectory(@"c:\isos\psx");
            }
        }
Пример #2
0
        public void Run(string[] args)
        {
            bool gui = true;

            foreach (var arg in args)
            {
                if (arg.ToUpper() == "COMMAND")
                {
                    gui = false;
                }
            }

            if (gui)
            {
                var dialog = new MainDiscoForm();
                dialog.ShowDialog();
                return;
            }
        }
Пример #3
0
        public void Run(string[] args)
        {
            if (args.Length == 0)
            {
                var dialog = new MainDiscoForm();
                dialog.ShowDialog();
                return;
            }

            bool   scanCues              = false;
            string dirArg                = null;
            string infile                = null;
            var    loadDiscInterface     = DiscInterface.BizHawk;
            var    compareDiscInterfaces = new List <DiscInterface>();
            bool   hawk = false;

            int idx = 0;

            while (idx < args.Length)
            {
                string a  = args[idx++];
                string au = a.ToUpperInvariant();
                if (au == "LOAD")
                {
                    loadDiscInterface = (DiscInterface)Enum.Parse(typeof(DiscInterface), args[idx++], true);
                }
                else if (au == "COMPARE")
                {
                    compareDiscInterfaces.Add((DiscInterface)Enum.Parse(typeof(DiscInterface), args[idx++], true));
                }
                else if (au == "HAWK")
                {
                    hawk = true;
                }
                else if (au == "CUEDIR")
                {
                    dirArg   = args[idx++];
                    scanCues = true;
                }
                else
                {
                    infile = a;
                }
            }

            if (hawk)
            {
                if (infile == null)
                {
                    return;
                }

                // TODO - write it out
                var dmj = new DiscMountJob {
                    IN_DiscInterface = loadDiscInterface, IN_FromPath = infile
                };
                dmj.Run();
            }

            bool verbose = true;

            if (scanCues)
            {
                verbose = false;
                var todo = FindCuesRecurse(dirArg);
                var po   = new ParallelOptions();
                var cts  = new CancellationTokenSource();
                po.CancellationToken      = cts.Token;
                po.MaxDegreeOfParallelism = 1;
                if (po.MaxDegreeOfParallelism < 0)
                {
                    po.MaxDegreeOfParallelism = 1;
                }
                object olock   = new object();
                int    ctr     = 0;
                bool   blocked = false;
                try
                {
                    Parallel.ForEach(todo, po, (fp) =>
                    {
                        lock (olock)
                        {
                            ctr++;
                            int strlen = todo.Count.ToString().Length;
                            string fmt = string.Format("{{0,{0}}}/{{1,{0}}} {{2}}", strlen);
                            Console.WriteLine(fmt, ctr, todo.Count, Path.GetFileNameWithoutExtension(fp));
                        }

                        if (!blocked)
                        {
                            foreach (var cmpif in compareDiscInterfaces)
                            {
                                var sw       = new StringWriter();
                                bool success = CompareFile(fp, loadDiscInterface, cmpif, verbose, cts, sw);
                                if (!success)
                                {
                                    lock (Console.Out)
                                        Console.Out.Write(sw.ToString());

                                    cts.Cancel();
                                    return;
                                }
                            }
                        }
                    });
                }
                catch (AggregateException ae) {
                    Console.WriteLine(ae.ToString());
                }
                catch (OperationCanceledException oce)
                {
                    Console.WriteLine(oce.ToString());
                }
                Console.WriteLine("--TERMINATED--");
                return;
            }

            if (compareDiscInterfaces.Count != 0)
            {
                var sw = new StringWriter();
                foreach (var cmpif in compareDiscInterfaces)
                {
                    CompareFile(infile, loadDiscInterface, cmpif, verbose, null, sw);
                }

                sw.Flush();
                string results = sw.ToString();
                var    cr      = new ComparisonResults {
                    textBox1 = { Text = results }
                };
                cr.ShowDialog();
            }
        }         //Run()
Пример #4
0
		public void Run(string[] args)
		{
			bool gui = true;
			foreach (var arg in args)
			{
				if (arg.ToUpper() == "COMMAND") gui = false;
			}

			if (gui)
			{
				var dialog = new MainDiscoForm();
				dialog.ShowDialog();
				return;
			}
		}
Пример #5
0
        public void Run(string[] args)
        {
            if (args.Length == 0)
            {
                var dialog = new MainDiscoForm();
                dialog.ShowDialog();
                return;
            }

            bool scanCues = false;
            string dirArg = null;
            string infile = null;
            var loadDiscInterface = DiscInterface.BizHawk;
            var compareDiscInterfaces = new List<DiscInterface> ();
            bool hawk = false;

            int idx = 0;
            while (idx < args.Length)
            {
                string a = args[idx++];
                string au = a.ToUpperInvariant();
                if (au == "LOAD")
                    loadDiscInterface = (DiscInterface)Enum.Parse(typeof(DiscInterface), args[idx++], true);
                else if (au == "COMPARE")
                    compareDiscInterfaces.Add((DiscInterface)Enum.Parse(typeof(DiscInterface), args[idx++], true));
                else if (au == "HAWK")
                    hawk = true;
                else if (au == "CUEDIR")
                {
                    dirArg = args[idx++];
                    scanCues = true;
                }
                else infile = a;
            }

            if (hawk)
            {
                if (infile == null)
                    return;

                //TODO - write it out
                var dmj = new DiscMountJob { IN_DiscInterface = loadDiscInterface, IN_FromPath = infile };
                dmj.Run();
                //var disc = dmj.OUT_Disc;
            }

            bool verbose = true;

            if (scanCues)
            {
                verbose = false;
                var todo = FindCuesRecurse(dirArg);
                var po = new ParallelOptions();
                var cts = new CancellationTokenSource();
                po.CancellationToken = cts.Token;
                po.MaxDegreeOfParallelism = 1;
                //po.MaxDegreeOfParallelism = System.Environment.ProcessorCount - 2; //I'm disk or network bound, no sense hammering this
                if(po.MaxDegreeOfParallelism < 0) po.MaxDegreeOfParallelism = 1;
                object olock = new object();
                int ctr=0;
                bool blocked = false;
                try
                {
                    Parallel.ForEach(todo, po, (fp) =>
                    {
                        lock (olock)
                        {
                            ctr++;
                            int strlen = todo.Count.ToString().Length;
                            string fmt = string.Format("{{0,{0}}}/{{1,{0}}} {{2}}", strlen);
                            Console.WriteLine(fmt, ctr, todo.Count, Path.GetFileNameWithoutExtension(fp));
                            //if (fp.Contains("Break Out"))
                            //  blocked = false;
                        }

                        if(!blocked)
                            foreach (var cmpif in compareDiscInterfaces)
                            {
                                StringWriter sw = new StringWriter();
                                bool success = CompareFile(fp, loadDiscInterface, cmpif, verbose, cts, sw);
                                if (!success)
                                {
                                    lock (Console.Out)
                                        Console.Out.Write(sw.ToString());

                                    cts.Cancel();
                                    return;
                                }
                        }
                    });
                }
                catch (AggregateException ae) {
                    Console.WriteLine(ae.ToString());
                }
                catch (OperationCanceledException oce)
                {
                    Console.WriteLine(oce.ToString());
                }
                Console.WriteLine("--TERMINATED--");
                return;
            }

            if (compareDiscInterfaces.Count != 0)
            {
                StringWriter sw = new StringWriter();
                foreach (var cmpif in compareDiscInterfaces)
                    CompareFile(infile, loadDiscInterface, cmpif, verbose, null, sw);
                sw.Flush();
                string results = sw.ToString();
                var cr = new ComparisonResults();
                cr.textBox1.Text = results;
                cr.ShowDialog();
            }
        }