diff --git a/GBM/Classes/clsBackup.vb b/GBM/Classes/clsBackup.vb index b42af69..34174d0 100644 --- a/GBM/Classes/clsBackup.vb +++ b/GBM/Classes/clsBackup.vb @@ -27,6 +27,12 @@ End Set End Property + ReadOnly Property SafeName As String + Get + Return mgrPath.ValidateForFileSystem(sName) + End Get + End Property + ReadOnly Property CroppedName As String Get If Name.Length > 40 Then diff --git a/GBM/Classes/clsGame.vb b/GBM/Classes/clsGame.vb index a3f8dc7..72bf67a 100644 --- a/GBM/Classes/clsGame.vb +++ b/GBM/Classes/clsGame.vb @@ -46,7 +46,7 @@ Public Class clsGame ReadOnly Property CompoundKey As String Get - Return ProcessName & ":" & Name + Return ProcessName & ":" & SafeName End Get End Property @@ -69,6 +69,12 @@ Public Class clsGame End Get End Property + ReadOnly Property SafeName As String + Get + Return mgrPath.ValidateForFileSystem(sGameName) + End Get + End Property + Property ProcessName As String Set(value As String) sProcessName = value diff --git a/GBM/Forms/frmAddWizard.vb b/GBM/Forms/frmAddWizard.vb index 19eba8f..f124a2e 100644 --- a/GBM/Forms/frmAddWizard.vb +++ b/GBM/Forms/frmAddWizard.vb @@ -195,10 +195,7 @@ Public Class frmAddWizard End Sub Private Function ValidateName(ByVal strName As String, ByRef sErrorMessage As String) As Boolean - If txtName.Text <> String.Empty Then - txtName.Text = mgrPath.ValidateForFileSystem(txtName.Text) - Return True - Else + If txtName.Text.Trim = String.Empty Then sErrorMessage = frmAddWizard_ErrorValidName txtName.Focus() Return False @@ -207,7 +204,7 @@ Public Class frmAddWizard End Function Private Function ValidateProcessPath(ByVal strPath As String, ByRef sErrorMessage As String) As Boolean - If strPath = String.Empty Then + If strPath.Trim = String.Empty Then sErrorMessage = frmAddWizard_ErrorValidProcess txtProcessPath.Focus() Return False @@ -235,7 +232,7 @@ Public Class frmAddWizard End Function Private Function ValidateSavePath(ByVal strPath As String, ByRef sErrorMessage As String) As Boolean - If strPath = String.Empty Then + If strPath.Trim = String.Empty Then sErrorMessage = frmAddWizard_ErrorValidSavePath txtSavePath.Focus() Return False @@ -257,7 +254,7 @@ Public Class frmAddWizard End Function Private Function ValidateSaveType(ByVal strSaveType As String, ByRef sErrorMessage As String) - If strSaveType = String.Empty Then + If strSaveType.Trim = String.Empty Then sErrorMessage = frmAddWizard_ErrorValidSaveType txtFileTypes.Focus() Return False @@ -268,7 +265,7 @@ Public Class frmAddWizard Private Sub DoSave() Dim hshDupeCheck As New Hashtable - Dim sNewGame As String = oGameToSave.ProcessName & ":" & oGameToSave.Name + Dim sNewGame As String = oGameToSave.ProcessName & ":" & oGameToSave.SafeName For Each o As clsGame In GameData.Values hshDupeCheck.Add(o.CompoundKey, String.Empty) diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index 7b4cc83..0bdbdbb 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -183,14 +183,14 @@ Public Class frmGameManager sFileName = BackupFolder & oBackupItem.FileName 'Rename Backup File - sNewFileName = Path.GetDirectoryName(sFileName) & Path.DirectorySeparatorChar & Path.GetFileName(sFileName).Replace(oOriginalApp.Name, oNewApp.Name) + sNewFileName = Path.GetDirectoryName(sFileName) & Path.DirectorySeparatorChar & Path.GetFileName(sFileName).Replace(oOriginalApp.SafeName, oNewApp.SafeName) If File.Exists(sFileName) Then FileSystem.Rename(sFileName, sNewFileName) End If 'Rename Directory sDirectory = Path.GetDirectoryName(sFileName) - sNewDirectory = sDirectory.Replace(oOriginalApp.Name, oNewApp.Name) + sNewDirectory = sDirectory.Replace(oOriginalApp.SafeName, oNewApp.SafeName) If sDirectory <> sNewDirectory Then If Directory.Exists(sDirectory) Then FileSystem.Rename(sDirectory, sNewDirectory) @@ -198,7 +198,7 @@ Public Class frmGameManager End If oBackupItem.Name = oNewApp.Name - oBackupItem.FileName = oBackupItem.FileName.Replace(oOriginalApp.Name, oNewApp.Name) + oBackupItem.FileName = oBackupItem.FileName.Replace(oOriginalApp.SafeName, oNewApp.SafeName) mgrManifest.DoManifestUpdateByID(oBackupItem, mgrSQLite.Database.Local) Next oLocalBackupData = mgrManifest.ReadLatestManifest(mgrSQLite.Database.Local) @@ -210,7 +210,7 @@ Public Class frmGameManager For Each oBackupItem As clsBackup In oBackupItems oBackupItem.Name = oNewApp.Name - oBackupItem.FileName = oBackupItem.FileName.Replace(oOriginalApp.Name, oNewApp.Name) + oBackupItem.FileName = oBackupItem.FileName.Replace(oOriginalApp.SafeName, oNewApp.SafeName) mgrManifest.DoManifestUpdateByID(oBackupItem, mgrSQLite.Database.Remote) Next oRemoteBackupData = mgrManifest.ReadLatestManifest(mgrSQLite.Database.Remote) @@ -1160,7 +1160,7 @@ Public Class frmGameManager If txtID.Text <> String.Empty Then oApp.ID = txtID.Text End If - oApp.Name = mgrPath.ValidateForFileSystem(txtName.Text) + oApp.Name = txtName.Text If Path.HasExtension(txtProcess.Text) Then If txtProcess.Text.ToLower.EndsWith(".exe") Then oApp.ProcessName = Path.GetFileNameWithoutExtension(txtProcess.Text) @@ -1280,13 +1280,13 @@ Public Class frmGameManager End Sub Private Function CoreValidatation(ByVal oApp As clsGame) As Boolean - If txtName.Text = String.Empty Then + If txtName.Text.Trim = String.Empty Then mgrCommon.ShowMessage(frmGameManager_ErrorValidName, MsgBoxStyle.Exclamation) txtName.Focus() Return False End If - If txtProcess.Text = String.Empty Then + If txtProcess.Text.Trim = String.Empty Then mgrCommon.ShowMessage(frmGameManager_ErrorValidProcess, MsgBoxStyle.Exclamation) txtProcess.Focus() Return False diff --git a/GBM/Managers/mgrBackup.vb b/GBM/Managers/mgrBackup.vb index 1c93bda..ff50130 100644 --- a/GBM/Managers/mgrBackup.vb +++ b/GBM/Managers/mgrBackup.vb @@ -107,8 +107,8 @@ Public Class mgrBackup Dim lAvailableSpace As Long Dim lFolderSize As Long - If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name - sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & ".7z" + If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName + sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName & ".7z" 'Verify saved game path sSavePath = VerifySavePath(oGame) @@ -199,7 +199,7 @@ Public Class mgrBackup RaiseEvent UpdateBackupInfo(oGame) If oSettings.CreateSubFolder Then - sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name + sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName Try If Not Directory.Exists(sBackupFile) Then Directory.CreateDirectory(sBackupFile) @@ -212,9 +212,9 @@ Public Class mgrBackup If oGame.AppendTimeStamp Then CheckOldBackups(oGame) - sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & sTimeStamp & ".7z" + sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName & sTimeStamp & ".7z" Else - sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & ".7z" + sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName & ".7z" End If If bDoBackup Then diff --git a/GBM/Managers/mgrCommon.vb b/GBM/Managers/mgrCommon.vb index 815190b..de91b3b 100644 --- a/GBM/Managers/mgrCommon.vb +++ b/GBM/Managers/mgrCommon.vb @@ -430,10 +430,10 @@ Public Class mgrCommon 'Delete a sub-folder based on the provided backup information Public Shared Sub DeleteDirectoryByBackup(ByVal sBackupFolder As String, ByVal oBackup As clsBackup) Dim oDir As DirectoryInfo - Dim sDir As String = sBackupFolder & oBackup.Name + Dim sDir As String = sBackupFolder & oBackup.SafeName 'Delete sub directory if it's empty - If oBackup.FileName.StartsWith(oBackup.Name & Path.DirectorySeparatorChar) Then + If oBackup.FileName.StartsWith(oBackup.SafeName & Path.DirectorySeparatorChar) Then If Directory.Exists(sDir) Then 'Check if there's any sub-directories or files remaining oDir = New DirectoryInfo(sDir) diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index d239cd7..ba0f1ed 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -85,13 +85,13 @@ Public Class mgrMonitorList Select Case eListType Case eListTypes.FullList 'Don't wrap this, if it fails there's a problem with the database - hshList.Add(oGame.ProcessName & ":" & oGame.Name, oGame) + hshList.Add(oGame.ProcessName & ":" & oGame.SafeName, oGame) Case eListTypes.ScanList For Each de As DictionaryEntry In hshList oCompareGame = DirectCast(de.Value, clsGame) If Regex.IsMatch(oGame.ProcessName, oCompareGame.ProcessName) Or (oGame.ProcessName = oCompareGame.ProcessName) Then DirectCast(hshList.Item(oCompareGame.ProcessName), clsGame).Duplicate = True - oGame.ProcessName = oGame.ProcessName & ":" & oGame.Name + oGame.ProcessName = oGame.ProcessName & ":" & oGame.SafeName oGame.Duplicate = True End If Next diff --git a/GBM/Managers/mgrXML.vb b/GBM/Managers/mgrXML.vb index ee5a6e7..0fe80ba 100644 --- a/GBM/Managers/mgrXML.vb +++ b/GBM/Managers/mgrXML.vb @@ -42,7 +42,7 @@ Public Class mgrXML 'This should be wrapped just in case we get some bad data Try - hshList.Add(oGame.ProcessName & ":" & oGame.Name, oGame) + hshList.Add(oGame.ProcessName & ":" & oGame.SafeName, oGame) Catch e As Exception 'Do Nothing End Try