Skip to content

Commit

Permalink
[Debugger] Handle backslashes in paths
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Jul 6, 2023
1 parent 33b80f7 commit 379e3ab
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Libs/FShade.Debug/ProjectData.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

open System.IO
open System.Xml
open System.Text.RegularExpressions
open System.Collections.Generic
open Aardvark.Base

Expand All @@ -27,6 +28,11 @@ module internal ProjectData =

let private cache = Dictionary<string, ProjectData>()

// Replaces back and forward slashes in a path with environment's directory separator.
let private normalizePath (path : string) =
let separator = string Path.DirectorySeparatorChar
Regex.Replace(path, @"\\|\/", separator)

let rec tryLoad (path : string) =
match cache.TryGetValue path with
| (true, result) ->
Expand All @@ -37,15 +43,15 @@ module internal ProjectData =

if File.Exists path then
try
let xml = new XmlDocument()
let xml = XmlDocument()
xml.Load path

let rootDir = Path.GetDirectoryName path

let getFilePaths (xpath : string) =
xml.SelectNodes xpath
|> Seq.cast<XmlAttribute>
|> Seq.map (fun attr -> Path.GetFullPath <| Path.Combine(rootDir, attr.Value))
|> Seq.map (fun attr -> Path.GetFullPath <| Path.Combine(rootDir, normalizePath attr.Value))
|> Seq.toList

let files = getFilePaths "//Compile/@Include"
Expand Down

0 comments on commit 379e3ab

Please sign in to comment.