Beispiel #1
0
        public static string GetRawExecutablePath(this Game game)
        {
            try
            {
                var playAction = game.GameActions?.FirstOrDefault(a => a.IsPlayAction && a.Type == GameActionType.File);
                if (playAction == null)
                {
                    return(null);
                }

                playAction = playAction.ExpandVariables(game);
                if (playAction.Type == GameActionType.File)
                {
                    if (string.IsNullOrEmpty(playAction.WorkingDir))
                    {
                        if (Paths.IsValidFilePath(playAction.Path))
                        {
                            return(Path.GetFullPath(playAction.Path));
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        if (Path.IsPathRooted(playAction.Path))
                        {
                            return(playAction.Path);
                        }
                        else
                        {
                            var combined = Path.Combine(playAction.WorkingDir, playAction.Path);
                            return(Path.GetFullPath(combined));
                        }
                    }
                }
                else if (playAction.Type == GameActionType.URL)
                {
                    return(playAction.Path);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
            {
                logger.Error(e, "Failed to get executable from game data.");
                return(null);
            }
        }
Beispiel #2
0
        public static string GetRawExecutablePath(this Game game)
        {
            if (game.PlayAction == null)
            {
                return(null);
            }

            var playAction = game.PlayAction.ExpandVariables(game);

            if (playAction.Type == GameActionType.File)
            {
                if (string.IsNullOrEmpty(playAction.WorkingDir))
                {
                    if (Paths.IsValidFilePath(playAction.Path))
                    {
                        return(Path.GetFullPath(playAction.Path));
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    if (Path.IsPathRooted(playAction.Path))
                    {
                        return(playAction.Path);
                    }
                    else
                    {
                        var combined = Path.Combine(playAction.WorkingDir, playAction.Path);
                        return(Path.GetFullPath(combined));
                    }
                }
            }
            else if (playAction.Type == GameActionType.URL)
            {
                return(playAction.Path);
            }
            else
            {
                return(null);
            }
        }