Ejemplo n.º 1
0
        /// <summary>
        /// Determines whether the specified path is game.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <param name="consoleType">The type of gamesystem this game belongs too</param>
        /// <returns>A Game</returns>
        private Game GetGame(ItemResolveArgs args, string consoleType)
        {
            var validExtensions = GetExtensions(consoleType);

            var gameFiles = args.FileSystemChildren.Where(f =>
            {
                var fileExtension = Path.GetExtension(f.FullName);

                return(validExtensions.Contains(fileExtension, StringComparer.OrdinalIgnoreCase));
            }).ToList();

            if (gameFiles.Count == 0)
            {
                _logger.Error("gameFiles is 0 for " + args.Path);
                return(null);
            }

            var game = new Game
            {
                Path       = gameFiles[0].FullName,
                GameSystem = ResolverHelper.GetGameSystemFromPlatform(consoleType)
            };

            game.IsPlaceHolder = false;

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

            return(game);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines whether the specified path is game.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <param name="consoleType">The type of gamesystem this game belongs too</param>
        /// <returns>A Game</returns>
        private Game GetGame(ItemResolveArgs args, string consoleType)
        {
            var validExtensions = GetExtensions(consoleType);

            var gameFiles = args.FileSystemChildren.Where(f =>
            {
                var fileExtension = Path.GetExtension(f.FullName) ?? string.Empty;

                return(validExtensions.Contains(fileExtension, StringComparer.OrdinalIgnoreCase));
            }).ToList();

            if (gameFiles.Count == 0)
            {
                return(null);
            }

            var game = new Game
            {
                Path       = gameFiles[0].FullName,
                GameSystem = ResolverHelper.GetGameSystemFromPlatform(consoleType)
            };

            game.IsPlaceHolder =
                string.Equals(game.GameSystem, GameSystem.Windows, StringComparison.OrdinalIgnoreCase) ||
                string.Equals(game.GameSystem, GameSystem.DOS, StringComparison.OrdinalIgnoreCase);

            game.DisplayMediaType = ResolverHelper.GetDisplayMediaTypeFromPlatform(consoleType);

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

            return(game);
        }
Ejemplo n.º 4
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);
        }