Example #1
0
        public static bool AddRomsFromDirectory(Platform platform, string directory)
        {
            if (platform == null)
            {
                return(false);
            }

            List <Rom> romList  = new List <Rom>();
            var        files    = Directory.GetFiles(directory);
            var        exts     = platform.DefaultRomExtensions.Split(',').ToList();
            bool       addedAny = false;

            foreach (var file in files)
            {
                var fileExt = GetFileExtension(file);
                if (!exts.Contains(fileExt.Replace(".", "")))
                {
                    continue;
                }

                var rom = RomBusiness.Get(platform.Name, RomFunctions.GetFileName(file));

                if (rom == null)
                {
                    romList.Add(RomBusiness.NewRom(file, platform));
                    addedAny = true;
                }
            }

            RomBusiness.SetRom(romList);

            return(addedAny);
        }
Example #2
0
        public static bool AddRomsFiles(Platform platform, string[] files)
        {
            bool addedAny = false;

            foreach (var file in files)
            {
                var rom = RomBusiness.Get(platform.Name, RomFunctions.GetFileName(file));

                if (rom == null)
                {
                    rom      = RomBusiness.NewRom(file, platform);
                    addedAny = true;
                    RomBusiness.SetRom(rom);
                }
            }

            return(addedAny);
        }