Ejemplo n.º 1
0
        /// <summary>
        /// Get up-to-date CRC32 values for the ROM.
        /// </summary>
        /// <param name="romPath">Absolute path to the ROM.</param>
        /// <param name="cfgPath">Absolute path to the configuration file (may be <c>null</c>).</param>
        /// <param name="cfgCrc">Receives the CRC32 of the file at <paramref name="cfgPath"/></param>
        /// <returns>The CRC32 of the file at <paramref name="romPath"/>.</returns>
        internal static uint GetCrcs(string romPath, string cfgPath, out uint cfgCrc)
        {
            bool dontCare;
            var  romCrc = GetCrcs(LuigiFileHeader.GetHeader(romPath), romPath, cfgPath, out cfgCrc, out dontCare);

            return(romCrc);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Safely retrieves the LUIGI header for a ROM.
        /// </summary>
        /// <param name="rom">The ROM whose LUIGI header is requested.</param>
        /// <returns>The <see cref="LuigiFileHeader"/> for the ROM, or <c>null</c> if the ROM is not in the LUIGI format.</returns>
        public static LuigiFileHeader GetLuigiHeader(this IRom rom)
        {
            LuigiFileHeader luigiHeader = null;

            if ((rom != null) && (rom.Format == RomFormat.Luigi) && !string.IsNullOrEmpty(rom.RomPath) && StreamUtilities.FileExists(rom.RomPath) && LuigiFileHeader.PotentialLuigiFile(rom.RomPath))
            {
                luigiHeader = LuigiFileHeader.GetHeader(rom.RomPath);
            }
            return(luigiHeader);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Examines the given file and attempts to determine if it is a program in .luigi format.
        /// </summary>
        /// <param name="filePath">The path to the LUIGI file.</param>
        /// <returns>A valid LuigiFormatRom if file is a valid .luigi file, otherwise <c>null</c>.</returns>
        internal static LuigiFormatRom Create(string filePath)
        {
            LuigiFormatRom rom = null;

            if (CheckFormat(filePath) == RomFormat.Luigi)
            {
                LuigiFileHeader header = LuigiFileHeader.GetHeader(filePath);
                if (header != null)
                {
                    rom = new LuigiFormatRom()
                    {
                        Format = RomFormat.Luigi, IsValid = true, RomPath = filePath, Header = header
                    };
                }
            }
            return(rom);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Checks the format of the ROM at the given absolute path.
        /// </summary>
        /// <param name="filePath">Absolute path to a ROM file.</param>
        /// <returns>The format of the ROM.</returns>
        internal static RomFormat CheckFormat(string filePath)
        {
            var format = CheckMemo(filePath);

            if (format == RomFormat.None)
            {
                using (var file = StreamUtilities.OpenFileStream(filePath))
                {
                    if (file != null)
                    {
                        if (file.Length > 0)
                        {
                            if (LuigiFileHeader.GetHeader(filePath) != null)
                            {
                                format = RomFormat.Luigi;
                                AddMemo(filePath, format);
                            }
                        }
                    }
                }
            }
            return(format);
        }