From f5626a26132a9b8f63aec130652db76621d0e058 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Sun, 10 Mar 2019 11:45:36 -0600 Subject: [PATCH] Resolved #151 - Pass 2: Cleaned up --- GBM/Forms/frmGameManager.vb | 6 ++++++ GBM/Managers/mgrBackup.vb | 12 ++++++------ GBM/Managers/mgrPath.vb | 2 +- GBM/Managers/mgrRestore.vb | 12 ++++++------ GBM/My Project/Resources.Designer.vb | 4 ++-- GBM/My Project/Resources.resx | 4 ++-- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index 91d010d..a9f87a2 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -1396,6 +1396,12 @@ Public Class frmGameManager oApp.Parameter = txtParameter.Text oApp.OS = CType(cboOS.SelectedValue, clsGame.eOS) oApp.Path = mgrPath.ValidatePathForOS(txtSavePath.Text) + + 'If we have a registry path, trim any trailing backslashes because they cause export failures + If mgrPath.IsSupportedRegistryPath(oApp.Path) Then + oApp.Path = oApp.Path.TrimEnd("\") + End If + 'We need to handle a special case here when working with Windows configurations in Linux If mgrCommon.IsUnix And mgrVariables.CheckForReservedVariables(oApp.Path) And oApp.OS = clsGame.eOS.Windows Then oApp.AbsolutePath = True diff --git a/GBM/Managers/mgrBackup.vb b/GBM/Managers/mgrBackup.vb index f54e062..43de6db 100644 --- a/GBM/Managers/mgrBackup.vb +++ b/GBM/Managers/mgrBackup.vb @@ -127,7 +127,7 @@ Public Class mgrBackup bRegistry = mgrPath.IsSupportedRegistryPath(oGame.TruePath) If bRegistry Then - 'If this is a registry backup, we need to have elevated permissions in Windows to use regedit + 'If this is a registry backup, we need to have elevated permissions in Windows to use reg.exe If Not mgrCommon.IsUnix And Not mgrCommon.IsElevated Then RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorRegBackupElevation, oGame.Name), False, ToolTipIcon.Info, True) Return False @@ -314,7 +314,7 @@ Public Class mgrBackup Dim sBinaryPath As String Dim sArguments As String Dim oWineData As clsWineData - Dim sWineRegEdit As String + Dim sWineReg As String Dim bPathVerified As Boolean = False Dim bBackupCompleted As Boolean = False @@ -324,13 +324,13 @@ Public Class mgrBackup oWineData = mgrWineData.DoWineDataGetbyID(oGame.ID) prsReg.StartInfo.EnvironmentVariables.Add("WINEPREFIX", oWineData.Prefix) sBinaryPath = oWineData.BinaryPath & Path.DirectorySeparatorChar & "wine" - sWineRegEdit = oWineData.Prefix & Path.DirectorySeparatorChar & "drive_c/windows/system32/reg.exe" - sArguments = """" & sWineRegEdit & """ " & sArguments + sWineReg = oWineData.Prefix & Path.DirectorySeparatorChar & "drive_c/windows/system32/reg.exe" + sArguments = """" & sWineReg & """ " & sArguments If File.Exists(sBinaryPath) Then - If File.Exists(sWineRegEdit) Then + If File.Exists(sWineReg) Then bPathVerified = True Else - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorRegNotFound, sWineRegEdit), False, ToolTipIcon.Error, True) + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorRegNotFound, sWineReg), False, ToolTipIcon.Error, True) End If Else RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorWineNotFound, sBinaryPath), False, ToolTipIcon.Error, True) diff --git a/GBM/Managers/mgrPath.vb b/GBM/Managers/mgrPath.vb index fb33617..32c080c 100644 --- a/GBM/Managers/mgrPath.vb +++ b/GBM/Managers/mgrPath.vb @@ -485,7 +485,7 @@ Public Class mgrPath Return sValue End Function - Public Shared Function IsSupportedRegistryPath(ByVal sPath As String) + Public Shared Function IsSupportedRegistryPath(ByVal sPath As String) As Boolean If sPath.StartsWith("HKEY_CURRENT_USER") Then Return True ElseIf sPath.StartsWith("HKEY_LOCAL_MACHINE") Then diff --git a/GBM/Managers/mgrRestore.vb b/GBM/Managers/mgrRestore.vb index 068546f..a0d6e1c 100644 --- a/GBM/Managers/mgrRestore.vb +++ b/GBM/Managers/mgrRestore.vb @@ -129,7 +129,7 @@ Public Class mgrRestore bRegistry = mgrPath.IsSupportedRegistryPath(oBackupInfo.TruePath) If bRegistry Then - 'If this is a registry backup, we need to have elevated permissions in Windows to use regedit + 'If this is a registry backup, we need to have elevated permissions in Windows to use reg.exe If Not mgrCommon.IsUnix And Not mgrCommon.IsElevated Then RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorRegBackupElevation, oBackupInfo.Name), False, ToolTipIcon.Info, True) Return False @@ -187,7 +187,7 @@ Public Class mgrRestore Dim sBinaryPath As String Dim sArguments As String Dim oWineData As clsWineData - Dim sWineRegEdit As String + Dim sWineReg As String Dim bPathVerified As Boolean Dim bRestoreCompleted As Boolean = False @@ -197,13 +197,13 @@ Public Class mgrRestore oWineData = mgrWineData.DoWineDataGetbyID(oBackupInfo.MonitorID) prsReg.StartInfo.EnvironmentVariables.Add("WINEPREFIX", oWineData.Prefix) sBinaryPath = oWineData.BinaryPath & Path.DirectorySeparatorChar & "wine" - sWineRegEdit = oWineData.Prefix & Path.DirectorySeparatorChar & "drive_c/windows/system32/reg.exe" - sArguments = """" & sWineRegEdit & """ " & sArguments + sWineReg = oWineData.Prefix & Path.DirectorySeparatorChar & "drive_c/windows/system32/reg.exe" + sArguments = """" & sWineReg & """ " & sArguments If File.Exists(sBinaryPath) Then - If File.Exists(sWineRegEdit) Then + If File.Exists(sWineReg) Then bPathVerified = True Else - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorRegNotFound, sWineRegEdit), False, ToolTipIcon.Error, True) + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorRegNotFound, sWineReg), False, ToolTipIcon.Error, True) End If Else RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorWineNotFound, sBinaryPath), False, ToolTipIcon.Error, True) diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index d605dcd..452c854 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -6151,7 +6151,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to The regedit utility could not be located at [PARAM]. The backup cannot continue.. + ''' Looks up a localized string similar to The utility reg.exe could not be located at [PARAM]. The backup cannot continue.. ''' Friend ReadOnly Property mgrBackup_ErrorRegNotFound() As String Get @@ -6700,7 +6700,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to The regedit utility could not be located at [PARAM]. The restore cannot continue.. + ''' Looks up a localized string similar to The utility reg.exe could not be located at [PARAM]. The restore cannot continue.. ''' Friend ReadOnly Property mgrRestore_ErrorRegNotFound() As String Get diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 73166b7..588ce2d 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2354,13 +2354,13 @@ The backup has failed, please ensure the registry path is correct. - The regedit utility could not be located at [PARAM]. The backup cannot continue. + The utility reg.exe could not be located at [PARAM]. The backup cannot continue. The wine binary could not be located at [PARAM]. The backup cannot continue. - The regedit utility could not be located at [PARAM]. The restore cannot continue. + The utility reg.exe could not be located at [PARAM]. The restore cannot continue. The wine binary could not be located at [PARAM]. The restore cannot continue.