예제 #1
0
        public MBStudioUpdater(MB_UPDATER_MODE mode = 0, List <string> textArguments = null)
        {
            UseGUI            = ((mode & MB_UPDATER_MODE.USE_GUI) == MB_UPDATER_MODE.USE_GUI);
            StartStudioOnExit = ((mode & MB_UPDATER_MODE.START_STUDIO_ON_EXIT) == MB_UPDATER_MODE.START_STUDIO_ON_EXIT);
            WriteIndexActive  = ((mode & MB_UPDATER_MODE.WRITE_INDEX) == MB_UPDATER_MODE.WRITE_INDEX);
            SelfUpdateActive  = ((mode & MB_UPDATER_MODE.SELF_UPDATE) == MB_UPDATER_MODE.SELF_UPDATE);
            AddNewFiles       = ((mode & MB_UPDATER_MODE.ADD_NEW_FILES) == MB_UPDATER_MODE.ADD_NEW_FILES);
            Forced32Bit       = ((mode & MB_UPDATER_MODE.FORCE_32_BIT) == MB_UPDATER_MODE.FORCE_32_BIT);

            SetTextArguments(ref textArguments);

            Channel    = textArguments[0];
            FolderPath = Path.GetFullPath(textArguments[1]);

            SetIsConsole();

            CloseAllOtherInstances();
        }
예제 #2
0
        private static MBStudioUpdater HandleArguments(string[] args)
        {
            bool useGUI      = false;
            bool startOE     = false;
            bool writeIndex  = false;
            bool selfUpdate  = false;
            bool addNewFiles = false;

            bool is64Bit = Environment.Is64BitOperatingSystem;
            bool is32Bit = !is64Bit;

            MBStudioUpdater updater;
            MB_UPDATER_MODE updaterMode = 0;

            bool          hasArguments  = (args.Length != 0);
            List <string> textArguments = new List <string>();

            if (hasArguments)
            {
                useGUI = args[0].Equals("-gui"); // else -no-gui
                if (args.Length > 1)
                {
                    selfUpdate = args[1].Equals("-su");
                    if (selfUpdate && args.Length > 2)
                    {
                        textArguments.Add(args[2].TrimStart('-')); // channel
                    }
                }
            }

            if (hasArguments && !selfUpdate && args.Length > 1)
            {
                string channel = args[1].TrimStart('-');
                textArguments.Add(channel);

                string folderPath = ".";
                if (args.Length > 2)
                {
                    folderPath = args[2];
                    if (folderPath.Contains("\"") && folderPath[folderPath.Length - 1] != '\"')
                    {
                        for (int i = 2; i < args.Length; i++)
                        {
                            if (folderPath[folderPath.Length - 1] == '\"')
                            {
                                i = args.Length;
                            }
                            folderPath += args[i];
                        }
                    }

                    if (args.Length > 3)
                    {
                        writeIndex = args[3].Equals("-index");
                        startOE    = args[3].Equals("-startOE");

                        if (args.Length > 4)
                        {
                            if (args[4].StartsWith("-f-arch=") ||
                                args[4].StartsWith("--force-arch=") ||
                                args[4].StartsWith("--force-architecture="))
                            {
                                string architecture = args[4].Split('=')[1];
                                is32Bit = architecture.Equals("x86");
                                is64Bit = architecture.Equals("x64");
                            }

                            if (args.Length > 5)
                            {
                                addNewFiles = (args[5].Equals("-anf") || args[5].Equals("--add-new-files"));
                            }
                        }
                    }
                }

                folderPath = Path.GetFullPath(folderPath);

                textArguments.Add(folderPath);

                if (useGUI)
                {
                    updaterMode |= MB_UPDATER_MODE.USE_GUI;
                }

                if (startOE)
                {
                    updaterMode |= MB_UPDATER_MODE.START_STUDIO_ON_EXIT;
                }

                if (writeIndex)
                {
                    updaterMode |= MB_UPDATER_MODE.WRITE_INDEX;
                }

                if (selfUpdate)
                {
                    updaterMode |= MB_UPDATER_MODE.SELF_UPDATE;
                }

                if (addNewFiles)
                {
                    updaterMode |= MB_UPDATER_MODE.ADD_NEW_FILES;
                }

                if (is32Bit)
                {
                    updaterMode |= MB_UPDATER_MODE.FORCE_32_BIT;
                }
            }
            else if (selfUpdate)
            {
                updaterMode |= MB_UPDATER_MODE.SELF_UPDATE;
            }

            updater = new MBStudioUpdater(updaterMode, textArguments);

            return(updater);
        }