Exemple #1
0
        /// <summary>
        /// Get the current system from drive
        /// </summary>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public RedumpSystem?GetRedumpSystem(RedumpSystem?defaultValue)
        {
            string drivePath = $"{this.Letter}:\\";

            // If we can't read the media in that drive, we can't do anything
            if (!Directory.Exists(drivePath))
            {
                return(defaultValue);
            }

            // We're going to assume for floppies, HDDs, and removable drives
            // TODO: Try to be smarter about this
            if (this.InternalDriveType != Data.InternalDriveType.Optical)
            {
                return(RedumpSystem.IBMPCcompatible);
            }

            // Check volume labels first
            RedumpSystem?systemFromLabel = GetRedumpSystemFromVolumeLabel();

            if (systemFromLabel != null)
            {
                return(systemFromLabel);
            }

            #region Consoles

            // Microsoft Xbox 360
            try
            {
                if (Directory.Exists(Path.Combine(drivePath, "$SystemUpdate")) &&
                    Directory.EnumerateFiles(Path.Combine(drivePath, "$SystemUpdate")).Any() &&
                    this.TotalSize <= 500_000_000)
                {
                    return(RedumpSystem.MicrosoftXbox360);
                }
            }
            catch { }

            // Microsoft Xbox One
            try
            {
                if (Directory.Exists(Path.Combine(drivePath, "MSXC")) &&
                    Directory.EnumerateFiles(Path.Combine(drivePath, "MSXC")).Any())
                {
                    return(RedumpSystem.MicrosoftXboxOne);
                }
            }
            catch { }

            // Sega Dreamcast
            if (File.Exists(Path.Combine(drivePath, "IP.BIN")))
            {
                return(RedumpSystem.SegaDreamcast);
            }

            // Sega Mega-CD / Sega-CD
            if (File.Exists(Path.Combine(drivePath, "_BOOT", "IP.BIN")) ||
                File.Exists(Path.Combine(drivePath, "_BOOT", "SP.BIN")) ||
                File.Exists(Path.Combine(drivePath, "_BOOT", "SP_AS.BIN")) ||
                File.Exists(Path.Combine(drivePath, "FILESYSTEM.BIN")))
            {
                return(RedumpSystem.SegaMegaCDSegaCD);
            }

            // Sega Saturn
            try
            {
                byte[] sector = ReadSector(0);
                if (sector != null)
                {
                    if (sector.StartsWith(Interface.SaturnSectorZeroStart))
                    {
                        return(RedumpSystem.SegaSaturn);
                    }
                }
            }
            catch { }

            // Sony PlayStation and Sony PlayStation 2
            string psxExePath    = Path.Combine(drivePath, "PSX.EXE");
            string systemCnfPath = Path.Combine(drivePath, "SYSTEM.CNF");
            if (File.Exists(systemCnfPath))
            {
                // Check for either BOOT or BOOT2
                var systemCnf = new IniFile(systemCnfPath);
                if (systemCnf.ContainsKey("BOOT"))
                {
                    return(RedumpSystem.SonyPlayStation);
                }
                else if (systemCnf.ContainsKey("BOOT2"))
                {
                    return(RedumpSystem.SonyPlayStation2);
                }
            }
            else if (File.Exists(psxExePath))
            {
                return(RedumpSystem.SonyPlayStation);
            }

            // V.Tech V.Flash / V.Smile Pro
            if (File.Exists(Path.Combine(drivePath, "0SYSTEM")))
            {
                return(RedumpSystem.VTechVFlashVSmilePro);
            }

            #endregion

            #region Video Formats

            // BD-Video
            if (Directory.Exists(Path.Combine(drivePath, "BDMV")))
            {
                // Technically BD-Audio has this as well, but it's hard to split that out right now
                return(RedumpSystem.BDVideo);
            }

            // DVD-Audio and DVD-Video
            try
            {
                if (Directory.Exists(Path.Combine(drivePath, "AUDIO_TS")) &&
                    Directory.EnumerateFiles(Path.Combine(drivePath, "AUDIO_TS")).Any())
                {
                    return(RedumpSystem.DVDAudio);
                }

                else if (Directory.Exists(Path.Combine(drivePath, "VIDEO_TS")) &&
                         Directory.EnumerateFiles(Path.Combine(drivePath, "VIDEO_TS")).Any())
                {
                    return(RedumpSystem.DVDVideo);
                }
            }
            catch { }

            // HD-DVD-Video
            try
            {
                if (Directory.Exists(Path.Combine(drivePath, "HVDVD_TS")) &&
                    Directory.EnumerateFiles(Path.Combine(drivePath, "HVDVD_TS")).Any())
                {
                    return(RedumpSystem.HDDVDVideo);
                }
            }
            catch { }

            // VCD
            try
            {
                if (Directory.Exists(Path.Combine(drivePath, "VCD")) &&
                    Directory.EnumerateFiles(Path.Combine(drivePath, "VCD")).Any())
                {
                    return(RedumpSystem.VideoCD);
                }
            }
            catch { }

            #endregion

            // Default return
            return(defaultValue);
        }