Example #1
0
        /// <summary>
        /// Resolves the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns>Game.</returns>
        protected override Game Resolve(ItemResolveArgs args)
        {
            var collectionType = args.GetCollectionType();

            if (!string.Equals(collectionType, CollectionType.Games, StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            var platform = ResolverHelper.AttemptGetGamePlatformTypeFromPath(_fileSystem, args.Path);

            if (string.IsNullOrEmpty(platform))
            {
                return(null);
            }

            if (args.IsDirectory)
            {
                return(GetGame(args, platform));
            }

            // For MAME we will allow all games in the same dir
            if (string.Equals(platform, "Arcade"))
            {
                var extension = Path.GetExtension(args.Path);

                if (string.Equals(extension, ".zip", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".7z", StringComparison.OrdinalIgnoreCase))
                {
                    // ignore zips that are bios roms.
                    if (MameUtils.IsBiosRom(args.Path))
                    {
                        return(null);
                    }

                    var game = new Game
                    {
                        Name             = MameUtils.GetFullNameFromPath(args.Path, _logger),
                        Path             = args.Path,
                        GameSystem       = "Arcade",
                        DisplayMediaType = "Arcade",
                        IsInMixedFolder  = true
                    };
                    return(game);
                }
            }

            return(null);
        }
Example #2
0
        private Game ResolveGame(FileSystemMetadata file, GameSystem gameSystem)
        {
            var path = file.FullName;

            var platform = ResolverHelper.AttemptGetGamePlatformTypeFromPath(_fileSystem, path);

            if (string.IsNullOrEmpty(platform))
            {
                return(null);
            }

            // For MAME we will allow all games in the same dir
            if (string.Equals(platform, "Arcade", StringComparison.OrdinalIgnoreCase))
            {
                var extension = Path.GetExtension(path);

                if (string.Equals(extension, ".zip", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".7z", StringComparison.OrdinalIgnoreCase))
                {
                    // ignore zips that are bios roms.
                    if (MameUtils.IsBiosRom(path))
                    {
                        return(null);
                    }

                    var game = new Game
                    {
                        Name            = MameUtils.GetFullNameFromPath(path, _logger),
                        Path            = path,
                        IsInMixedFolder = true,
                        Album           = gameSystem.Name,
                        AlbumId         = gameSystem.InternalId,
                        Container       = extension.TrimStart('.')
                    };
                    return(game);
                }
            }
            else
            {
                var validExtensions = GetExtensions(platform);
                var fileExtension   = Path.GetExtension(path);

                if (!validExtensions.Contains(fileExtension, StringComparer.OrdinalIgnoreCase))
                {
                    return(null);
                }

                var game = new Game
                {
                    Path      = path,
                    Album     = gameSystem.Name,
                    AlbumId   = gameSystem.InternalId,
                    Container = fileExtension.TrimStart('.')
                };

                //if (gameFiles.Count > 1)
                //{
                //    game.MultiPartGameFiles = gameFiles.Select(i => i.FullName).ToArray();
                //    game.IsMultiPart = true;
                //}

                return(game);
            }

            return(null);
        }