Changes for issue #123 (Pass 1)

This commit is contained in:
MikeMaximus
2018-02-18 09:38:52 -06:00
parent e897fda8e8
commit 1c54085d6c
8 changed files with 35 additions and 26 deletions
+6
View File
@@ -27,6 +27,12 @@
End Set End Set
End Property End Property
ReadOnly Property SafeName As String
Get
Return mgrPath.ValidateForFileSystem(sName)
End Get
End Property
ReadOnly Property CroppedName As String ReadOnly Property CroppedName As String
Get Get
If Name.Length > 40 Then If Name.Length > 40 Then
+7 -1
View File
@@ -46,7 +46,7 @@ Public Class clsGame
ReadOnly Property CompoundKey As String ReadOnly Property CompoundKey As String
Get Get
Return ProcessName & ":" & Name Return ProcessName & ":" & SafeName
End Get End Get
End Property End Property
@@ -69,6 +69,12 @@ Public Class clsGame
End Get End Get
End Property End Property
ReadOnly Property SafeName As String
Get
Return mgrPath.ValidateForFileSystem(sGameName)
End Get
End Property
Property ProcessName As String Property ProcessName As String
Set(value As String) Set(value As String)
sProcessName = value sProcessName = value
+5 -8
View File
@@ -195,10 +195,7 @@ Public Class frmAddWizard
End Sub End Sub
Private Function ValidateName(ByVal strName As String, ByRef sErrorMessage As String) As Boolean Private Function ValidateName(ByVal strName As String, ByRef sErrorMessage As String) As Boolean
If txtName.Text <> String.Empty Then If txtName.Text.Trim = String.Empty Then
txtName.Text = mgrPath.ValidateForFileSystem(txtName.Text)
Return True
Else
sErrorMessage = frmAddWizard_ErrorValidName sErrorMessage = frmAddWizard_ErrorValidName
txtName.Focus() txtName.Focus()
Return False Return False
@@ -207,7 +204,7 @@ Public Class frmAddWizard
End Function End Function
Private Function ValidateProcessPath(ByVal strPath As String, ByRef sErrorMessage As String) As Boolean 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 sErrorMessage = frmAddWizard_ErrorValidProcess
txtProcessPath.Focus() txtProcessPath.Focus()
Return False Return False
@@ -235,7 +232,7 @@ Public Class frmAddWizard
End Function End Function
Private Function ValidateSavePath(ByVal strPath As String, ByRef sErrorMessage As String) As Boolean 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 sErrorMessage = frmAddWizard_ErrorValidSavePath
txtSavePath.Focus() txtSavePath.Focus()
Return False Return False
@@ -257,7 +254,7 @@ Public Class frmAddWizard
End Function End Function
Private Function ValidateSaveType(ByVal strSaveType As String, ByRef sErrorMessage As String) 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 sErrorMessage = frmAddWizard_ErrorValidSaveType
txtFileTypes.Focus() txtFileTypes.Focus()
Return False Return False
@@ -268,7 +265,7 @@ Public Class frmAddWizard
Private Sub DoSave() Private Sub DoSave()
Dim hshDupeCheck As New Hashtable 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 For Each o As clsGame In GameData.Values
hshDupeCheck.Add(o.CompoundKey, String.Empty) hshDupeCheck.Add(o.CompoundKey, String.Empty)
+7 -7
View File
@@ -183,14 +183,14 @@ Public Class frmGameManager
sFileName = BackupFolder & oBackupItem.FileName sFileName = BackupFolder & oBackupItem.FileName
'Rename Backup File '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 If File.Exists(sFileName) Then
FileSystem.Rename(sFileName, sNewFileName) FileSystem.Rename(sFileName, sNewFileName)
End If End If
'Rename Directory 'Rename Directory
sDirectory = Path.GetDirectoryName(sFileName) sDirectory = Path.GetDirectoryName(sFileName)
sNewDirectory = sDirectory.Replace(oOriginalApp.Name, oNewApp.Name) sNewDirectory = sDirectory.Replace(oOriginalApp.SafeName, oNewApp.SafeName)
If sDirectory <> sNewDirectory Then If sDirectory <> sNewDirectory Then
If Directory.Exists(sDirectory) Then If Directory.Exists(sDirectory) Then
FileSystem.Rename(sDirectory, sNewDirectory) FileSystem.Rename(sDirectory, sNewDirectory)
@@ -198,7 +198,7 @@ Public Class frmGameManager
End If End If
oBackupItem.Name = oNewApp.Name 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) mgrManifest.DoManifestUpdateByID(oBackupItem, mgrSQLite.Database.Local)
Next Next
oLocalBackupData = mgrManifest.ReadLatestManifest(mgrSQLite.Database.Local) oLocalBackupData = mgrManifest.ReadLatestManifest(mgrSQLite.Database.Local)
@@ -210,7 +210,7 @@ Public Class frmGameManager
For Each oBackupItem As clsBackup In oBackupItems For Each oBackupItem As clsBackup In oBackupItems
oBackupItem.Name = oNewApp.Name 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) mgrManifest.DoManifestUpdateByID(oBackupItem, mgrSQLite.Database.Remote)
Next Next
oRemoteBackupData = mgrManifest.ReadLatestManifest(mgrSQLite.Database.Remote) oRemoteBackupData = mgrManifest.ReadLatestManifest(mgrSQLite.Database.Remote)
@@ -1160,7 +1160,7 @@ Public Class frmGameManager
If txtID.Text <> String.Empty Then If txtID.Text <> String.Empty Then
oApp.ID = txtID.Text oApp.ID = txtID.Text
End If End If
oApp.Name = mgrPath.ValidateForFileSystem(txtName.Text) oApp.Name = txtName.Text
If Path.HasExtension(txtProcess.Text) Then If Path.HasExtension(txtProcess.Text) Then
If txtProcess.Text.ToLower.EndsWith(".exe") Then If txtProcess.Text.ToLower.EndsWith(".exe") Then
oApp.ProcessName = Path.GetFileNameWithoutExtension(txtProcess.Text) oApp.ProcessName = Path.GetFileNameWithoutExtension(txtProcess.Text)
@@ -1280,13 +1280,13 @@ Public Class frmGameManager
End Sub End Sub
Private Function CoreValidatation(ByVal oApp As clsGame) As Boolean 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) mgrCommon.ShowMessage(frmGameManager_ErrorValidName, MsgBoxStyle.Exclamation)
txtName.Focus() txtName.Focus()
Return False Return False
End If End If
If txtProcess.Text = String.Empty Then If txtProcess.Text.Trim = String.Empty Then
mgrCommon.ShowMessage(frmGameManager_ErrorValidProcess, MsgBoxStyle.Exclamation) mgrCommon.ShowMessage(frmGameManager_ErrorValidProcess, MsgBoxStyle.Exclamation)
txtProcess.Focus() txtProcess.Focus()
Return False Return False
+5 -5
View File
@@ -107,8 +107,8 @@ Public Class mgrBackup
Dim lAvailableSpace As Long Dim lAvailableSpace As Long
Dim lFolderSize As Long Dim lFolderSize As Long
If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & ".7z" sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName & ".7z"
'Verify saved game path 'Verify saved game path
sSavePath = VerifySavePath(oGame) sSavePath = VerifySavePath(oGame)
@@ -199,7 +199,7 @@ Public Class mgrBackup
RaiseEvent UpdateBackupInfo(oGame) RaiseEvent UpdateBackupInfo(oGame)
If oSettings.CreateSubFolder Then If oSettings.CreateSubFolder Then
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName
Try Try
If Not Directory.Exists(sBackupFile) Then If Not Directory.Exists(sBackupFile) Then
Directory.CreateDirectory(sBackupFile) Directory.CreateDirectory(sBackupFile)
@@ -212,9 +212,9 @@ Public Class mgrBackup
If oGame.AppendTimeStamp Then If oGame.AppendTimeStamp Then
CheckOldBackups(oGame) CheckOldBackups(oGame)
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & sTimeStamp & ".7z" sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName & sTimeStamp & ".7z"
Else Else
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & ".7z" sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.SafeName & ".7z"
End If End If
If bDoBackup Then If bDoBackup Then
+2 -2
View File
@@ -430,10 +430,10 @@ Public Class mgrCommon
'Delete a sub-folder based on the provided backup information 'Delete a sub-folder based on the provided backup information
Public Shared Sub DeleteDirectoryByBackup(ByVal sBackupFolder As String, ByVal oBackup As clsBackup) Public Shared Sub DeleteDirectoryByBackup(ByVal sBackupFolder As String, ByVal oBackup As clsBackup)
Dim oDir As DirectoryInfo 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 '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 If Directory.Exists(sDir) Then
'Check if there's any sub-directories or files remaining 'Check if there's any sub-directories or files remaining
oDir = New DirectoryInfo(sDir) oDir = New DirectoryInfo(sDir)
+2 -2
View File
@@ -85,13 +85,13 @@ Public Class mgrMonitorList
Select Case eListType Select Case eListType
Case eListTypes.FullList Case eListTypes.FullList
'Don't wrap this, if it fails there's a problem with the database '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 Case eListTypes.ScanList
For Each de As DictionaryEntry In hshList For Each de As DictionaryEntry In hshList
oCompareGame = DirectCast(de.Value, clsGame) oCompareGame = DirectCast(de.Value, clsGame)
If Regex.IsMatch(oGame.ProcessName, oCompareGame.ProcessName) Or (oGame.ProcessName = oCompareGame.ProcessName) Then If Regex.IsMatch(oGame.ProcessName, oCompareGame.ProcessName) Or (oGame.ProcessName = oCompareGame.ProcessName) Then
DirectCast(hshList.Item(oCompareGame.ProcessName), clsGame).Duplicate = True DirectCast(hshList.Item(oCompareGame.ProcessName), clsGame).Duplicate = True
oGame.ProcessName = oGame.ProcessName & ":" & oGame.Name oGame.ProcessName = oGame.ProcessName & ":" & oGame.SafeName
oGame.Duplicate = True oGame.Duplicate = True
End If End If
Next Next
+1 -1
View File
@@ -42,7 +42,7 @@ Public Class mgrXML
'This should be wrapped just in case we get some bad data 'This should be wrapped just in case we get some bad data
Try Try
hshList.Add(oGame.ProcessName & ":" & oGame.Name, oGame) hshList.Add(oGame.ProcessName & ":" & oGame.SafeName, oGame)
Catch e As Exception Catch e As Exception
'Do Nothing 'Do Nothing
End Try End Try