Windream: Fix normalized paths
This commit is contained in:
parent
1ea73d9234
commit
f5107a3d21
@ -816,22 +816,16 @@ Public Class Windream
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function GetNormalizedPath(Path As String, pCleanPath As Boolean) As String
|
Public Function GetNormalizedPath(pPath As String, pCleanPath As Boolean) As String
|
||||||
_logger.Debug("Normalizing Path: [{0}]", Path)
|
_logger.Debug("Normalizing Path: [{0}]", pPath)
|
||||||
Dim oNormalizedPath As String = Path
|
Dim oNormalizedPath As String = pPath
|
||||||
|
|
||||||
If pCleanPath = True Then
|
If pCleanPath = True Then
|
||||||
oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path)
|
oNormalizedPath = Utils.RemoveInvalidCharacters(pPath)
|
||||||
_logger.Debug("Path after RemoveInvalidCharacters: [{0}]", oNormalizedPath)
|
_logger.Debug("Path after RemoveInvalidCharacters: [{0}]", oNormalizedPath)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Try
|
Try
|
||||||
' Convert any forward slashes / and double slashes \\ into backslashes \
|
|
||||||
' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes
|
|
||||||
If IsPathRooted(oNormalizedPath) Then
|
|
||||||
oNormalizedPath = GetFullPath(oNormalizedPath)
|
|
||||||
End If
|
|
||||||
|
|
||||||
' Remove Driveletter, eg. W:\
|
' Remove Driveletter, eg. W:\
|
||||||
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
|
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
|
||||||
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
|
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
|
||||||
@ -851,6 +845,18 @@ Public Class Windream
|
|||||||
oNormalizedPath = oNormalizedPath.Substring(3)
|
oNormalizedPath = oNormalizedPath.Substring(3)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
' Convert any forward slashes / and double slashes \\ into backslashes \
|
||||||
|
' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes
|
||||||
|
If IsPathRooted(oNormalizedPath) Then
|
||||||
|
' This breaks because it converts the path "\SomeFolder" into "C:\SomeFolder" LOL
|
||||||
|
'oNormalizedPath = GetFullPath(oNormalizedPath)
|
||||||
|
' Lets just be pragmatic here
|
||||||
|
oNormalizedPath = oNormalizedPath.Replace("\\", "\")
|
||||||
|
oNormalizedPath = oNormalizedPath.Replace("/", "\")
|
||||||
|
|
||||||
|
_logger.Debug("Path after converting slashes: [{0}]", oNormalizedPath)
|
||||||
|
End If
|
||||||
|
|
||||||
If oNormalizedPath.StartsWith("\") = False Then
|
If oNormalizedPath.StartsWith("\") = False Then
|
||||||
oNormalizedPath = $"\{oNormalizedPath}"
|
oNormalizedPath = $"\{oNormalizedPath}"
|
||||||
End If
|
End If
|
||||||
@ -864,6 +870,11 @@ Public Class Windream
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function GetAbsolutePath(pPath As String) As String
|
||||||
|
Dim oNormalizedPath = GetNormalizedPath(pPath, False)
|
||||||
|
Return $"\\windream\objects{oNormalizedPath}"
|
||||||
|
End Function
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Returns the result of a search file
|
''' Returns the result of a search file
|
||||||
''' </summary>
|
''' </summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user