internal static string MakeFullPath()

in src/Sarif.Viewer.VisualStudio.Core/SdkUiUtilities.cs [539:572]


        internal static string MakeFullPath(string fileName, IEnumerable<string> searchPaths, string relativePathBase)
        {
            // Simple case, if it's rooted, just return it
            if (Path.IsPathRooted(fileName))
            {
                return fileName;
            }

            // Check if it is in the relative directory
            if (!string.IsNullOrEmpty(relativePathBase))
            {
                // Using GetFullPath to remove any \..\ in the path
                string path = Path.GetFullPath(Path.Combine(relativePathBase, fileName));
                if (File.Exists(path))
                {
                    return path;
                }
            }

            // If it's just a file name, search the search paths
            if (searchPaths != null && fileName == Path.GetFileName(fileName))
            {
                foreach (string searchPath in searchPaths)
                {
                    string path = Path.Combine(searchPath, fileName);
                    if (File.Exists(path))
                    {
                        return path;
                    }
                }
            }

            return null;
        }