Updated path replacing for #152

This commit is contained in:
MikeMaximus
2018-09-08 08:16:34 -06:00
parent 8800c4ebf4
commit fd6ddd4b85
4 changed files with 9 additions and 14 deletions
Vendored
+1 -3
View File
@@ -186,6 +186,4 @@ FakesAssemblies/
GeneratedArtifacts/ GeneratedArtifacts/
_Pvt_Extensions/ _Pvt_Extensions/
ModelManifest.xml ModelManifest.xml
/.vs/slnx.sqlite /.vs
/.vs/VSWorkspaceState.json
/.vs/Game Backup Monitor/v15
+1 -1
View File
@@ -74,7 +74,7 @@
Property RestorePath As String Property RestorePath As String
Get Get
Return Environment.ExpandEnvironmentVariables(sRestorePath) Return mgrPath.ReplaceSpecialPaths(sRestorePath)
End Get End Get
Set(value As String) Set(value As String)
sRestorePath = mgrPath.ReverseSpecialPaths(value) sRestorePath = mgrPath.ReverseSpecialPaths(value)
+1 -1
View File
@@ -93,7 +93,7 @@ Public Class clsGame
sPath = mgrPath.ReverseSpecialPaths(value) sPath = mgrPath.ReverseSpecialPaths(value)
End Set End Set
Get Get
Return Environment.ExpandEnvironmentVariables(sPath) Return mgrPath.ReplaceSpecialPaths(sPath)
End Get End Get
End Property End Property
+6 -9
View File
@@ -334,7 +334,7 @@ Public Class mgrPath
End Sub End Sub
Private Shared Function ProcessEnvironmentVariables(ByVal sValue As String) As String Public Shared Function ReplaceSpecialPaths(ByVal sValue As String) As String
Dim sXdgData As String = "${XDG_DATA_HOME:-~/.local/share}" Dim sXdgData As String = "${XDG_DATA_HOME:-~/.local/share}"
Dim sEnvAppDataLocal As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) Dim sEnvAppDataLocal As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Dim sXdgConfig As String = "${XDG_CONFIG_HOME:-~/.config}" Dim sXdgConfig As String = "${XDG_CONFIG_HOME:-~/.config}"
@@ -344,11 +344,11 @@ Public Class mgrPath
If mgrCommon.IsUnix Then If mgrCommon.IsUnix Then
'$VAR_iable '$VAR_iable
Dim oParse As new Regex("\$([a-zA-Z0-9_]+)") Dim oParse As New Regex("\$([a-zA-Z0-9_]+)")
'${VAR_iable} but not advanced syntax like ${VAR:-iable} '${VAR_iable} but not advanced syntax like ${VAR:-iable}
Dim oParseBracketed As new Regex("\$\{([a-zA-Z0-9_]+?)\}") Dim oParseBracketed As New Regex("\$\{([a-zA-Z0-9_]+?)\}")
'~ not inside ${...} '~ not inside ${...}
Dim oParseTilde As new Regex("~(?![^\$\{]*\})") Dim oParseTilde As New Regex("~(?![^\$\{]*\})")
If sEnvCurrentUser = String.Empty Then If sEnvCurrentUser = String.Empty Then
'Fall back 'Fall back
sEnvCurrentUser = Environment.GetFolderPath(Environment.SpecialFolder.Personal) sEnvCurrentUser = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
@@ -361,7 +361,7 @@ Public Class mgrPath
'$HOME to ${HOME} '$HOME to ${HOME}
sValue = oParse.Replace(sValue, "${$1}") sValue = oParse.Replace(sValue, "${$1}")
'Special notations for home directory 'Special notations for home directory
sValue = oParseTilde.Replace(sValue,"${HOME}") sValue = oParseTilde.Replace(sValue, "${HOME}")
'XDG Base Directory Specification has default values 'XDG Base Directory Specification has default values
sValue = sValue.Replace("${XDG_DATA_HOME}", sXdgData) sValue = sValue.Replace("${XDG_DATA_HOME}", sXdgData)
sValue = sValue.Replace("${XDG_CONFIG_HOME}", sXdgConfig) sValue = sValue.Replace("${XDG_CONFIG_HOME}", sXdgConfig)
@@ -382,7 +382,7 @@ Public Class mgrPath
If mgrCommon.IsUnix Then If mgrCommon.IsUnix Then
'Transform missing variables back 'Transform missing variables back
Dim oParse As new Regex("%([a-zA-Z0-9_]+?)%") Dim oParse As New Regex("%([a-zA-Z0-9_]+?)%")
sValue = oParse.Replace(sValue, "${$1}") sValue = oParse.Replace(sValue, "${$1}")
'Unscape real Windows variables 'Unscape real Windows variables
sValue = sValue.Replace("\%", "%") sValue = sValue.Replace("\%", "%")
@@ -407,9 +407,6 @@ Public Class mgrPath
Dim sEnvCurrentUser As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) Dim sEnvCurrentUser As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
Dim oCustomVariable As clsPathVariable Dim oCustomVariable As clsPathVariable
sValue = ProcessEnvironmentVariables(sValue)
For Each oCustomVariable In hshCustomVariables.Values For Each oCustomVariable In hshCustomVariables.Values
If sValue.Contains(oCustomVariable.Path) Then If sValue.Contains(oCustomVariable.Path) Then
Return sValue.Replace(oCustomVariable.Path, oCustomVariable.FormattedName) Return sValue.Replace(oCustomVariable.Path, oCustomVariable.FormattedName)