コード例 #1
0
        /// <summary>
        /// Builds a EmulatorModel for every rom
        /// </summary>
        public static EmulatorModel[] GetEmulatorInformationFromDisk(string rootEmuDirectory)
        {
            EmulatorModel[] models = null;
            try
            {
                models = new EmulatorModel[EnumerateEmulators(rootEmuDirectory)];
            }
            catch (DirectoryNotFoundException ex)
            {
                DebugManager.ShowErrorDialog("An error occured getting the emulator directory", ex);
                return(models);
            }

            string[] emulatorConsoleAssociations = new EmuManagerModel().EmulatorAssociations.Split(';');

            int i = 0;

            foreach (string association in emulatorConsoleAssociations)
            {
                try
                {
                    // EX association: PS1:ePSXe.exe
                    string emulator = association.Split(':')[1];

                    string[] files = System.IO.Directory.GetFiles(rootEmuDirectory, emulator, SearchOption.AllDirectories);
                    foreach (string file in files)
                    {
                        EmulatorModel model = new EmulatorModel();
                        model.BinaryPath = file;
                        model.Console    = association.Split(':')[0];

                        models[i] = model;
                        i++;
                    }
                }
                catch (NullReferenceException)
                {
                    // This would mean an improperly formatted emulator association was present if hit
                    continue;
                }
                catch (IOException)
                {
                    // This would mean the emulator directory was set incorrectly or unreadable
                    continue;
                }
            }

            return(models);
        }
コード例 #2
0
        /// <summary>
        /// Builds a RomModel for every rom
        /// </summary>
        public static RomModel[] GetRomInformationFromDisk(string rootRomDirectory)
        {
            string consoleAliases = ConfigurationManager.AppSettings.Get("ConsoleAliases");

            RomModel[] models = null;

            try
            {
                models = new RomModel[EnumerateRomFiles(rootRomDirectory)];
            }
            catch (DirectoryNotFoundException ex)
            {
                DebugManager.ShowErrorDialog("An error occured getting the rom directory", ex);
                return(models);
            }

            string[] romExtensions = new EmuManagerModel().RomExtensions.Split(',');

            //TODO: We probably want to take a look at the nesting here
            int x = 0;

            try
            {
                foreach (string extension in romExtensions)
                {
                    string[] files = System.IO.Directory.GetFiles(rootRomDirectory, "*." + extension, SearchOption.AllDirectories);
                    for (int i = 0; i < files.Length; i++)
                    {
                        models[x] = PopulateRomModelFromRomPathRomFileName(files[i], consoleAliases);
                        x++;
                    }
                }
            }
            catch (NullReferenceException)
            {
                // This would mean an improperly formatted emulator association was present if hit
            }
            catch (IOException)
            {
                // This would mean the rom directory was set incorrectly or unreadable
            }

            return(models);
        }