Add special folder verification for issue #144
This commit is contained in:
@@ -1051,6 +1051,12 @@ Public Class frmMain
|
|||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
'Check Special Paths
|
||||||
|
If Not mgrPath.CheckSpecialPaths Then
|
||||||
|
bInitFail = True
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
'Local Database Check
|
'Local Database Check
|
||||||
VerifyDBVersion(mgrSQLite.Database.Local)
|
VerifyDBVersion(mgrSQLite.Database.Local)
|
||||||
LocalDatabaseCheck()
|
LocalDatabaseCheck()
|
||||||
|
|||||||
+40
-12
@@ -202,6 +202,28 @@ Public Class mgrPath
|
|||||||
Return sResult
|
Return sResult
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Shared Function CheckSpecialPaths() As Boolean
|
||||||
|
Dim hshEnvs As New Hashtable
|
||||||
|
Dim bNoError As Boolean = True
|
||||||
|
|
||||||
|
hshEnvs.Add("Documents", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
|
||||||
|
hshEnvs.Add("AppDataRoaming", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))
|
||||||
|
hshEnvs.Add("AppDataLocal", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData))
|
||||||
|
If Not mgrCommon.IsUnix Then
|
||||||
|
hshEnvs.Add("UserData", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile))
|
||||||
|
hshEnvs.Add("PublicDocuments", Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments))
|
||||||
|
End If
|
||||||
|
|
||||||
|
For Each de As DictionaryEntry In hshEnvs
|
||||||
|
If de.Value = String.Empty Then
|
||||||
|
mgrCommon.ShowMessage(mgrPath_SpecialPathError, de.Key, MsgBoxStyle.Critical)
|
||||||
|
bNoError = False
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
|
||||||
|
Return bNoError
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Shared Function ReplaceSpecialPaths(sValue As String) As String
|
Public Shared Function ReplaceSpecialPaths(sValue As String) As String
|
||||||
Dim sMyDocs As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
|
Dim sMyDocs As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
|
||||||
Dim sPublicDocs As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)
|
Dim sPublicDocs As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)
|
||||||
@@ -246,39 +268,45 @@ Public Class mgrPath
|
|||||||
|
|
||||||
Public Shared Function ReverseSpecialPaths(sValue As String) As String
|
Public Shared Function ReverseSpecialPaths(sValue As String) As String
|
||||||
Dim sMyDocs As String = "*mydocs*"
|
Dim sMyDocs As String = "*mydocs*"
|
||||||
|
Dim sEnvMyDocs As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
|
||||||
Dim sPublicDocs As String = "*publicdocs*"
|
Dim sPublicDocs As String = "*publicdocs*"
|
||||||
Dim sAppDataRoaming As String = "*appdatalocal*"
|
Dim sEnvPublicDocs As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)
|
||||||
Dim sAppDataLocal As String = "*appdataroaming*"
|
Dim sAppDataLocal As String = "*appdatalocal*"
|
||||||
|
Dim sEnvAppDataLocal As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
|
||||||
|
Dim sAppDataRoaming As String = "*appdataroaming*"
|
||||||
|
Dim sEnvAppDataRoaming As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
|
||||||
Dim sCurrentUser As String = "*currentuser*"
|
Dim sCurrentUser As String = "*currentuser*"
|
||||||
|
Dim sEnvCurrentUser As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
|
||||||
Dim oCustomVariable As clsPathVariable
|
Dim oCustomVariable As clsPathVariable
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
If sValue.Contains(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)) Then
|
If sValue.Contains(sEnvAppDataRoaming) Then
|
||||||
Return sValue.Replace(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), sAppDataLocal)
|
Return sValue.Replace(sEnvAppDataRoaming, sAppDataRoaming)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If sValue.Contains(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) Then
|
If sValue.Contains(sEnvAppDataLocal) Then
|
||||||
Return sValue.Replace(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), sAppDataRoaming)
|
Return sValue.Replace(sEnvAppDataLocal, sAppDataLocal)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'This needs to be tested last for Unix compatability
|
'This needs to be tested last for Unix compatability
|
||||||
If sValue.Contains(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) Then
|
If sValue.Contains(sEnvMyDocs) Then
|
||||||
Return sValue.Replace(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), sMyDocs)
|
Return sValue.Replace(sEnvMyDocs, sMyDocs)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'Don't use these in Unix
|
'Don't use these in Unix
|
||||||
If Not mgrCommon.IsUnix Then
|
If Not mgrCommon.IsUnix Then
|
||||||
If sValue.Contains(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)) Then
|
If sValue.Contains(sEnvPublicDocs) Then
|
||||||
Return sValue.Replace(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), sPublicDocs)
|
Return sValue.Replace(sEnvPublicDocs, sPublicDocs)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If sValue.Contains(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)) Then
|
If sValue.Contains(sEnvCurrentUser) Then
|
||||||
Return sValue.Replace(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), sCurrentUser)
|
Return sValue.Replace(sEnvCurrentUser, sCurrentUser)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|||||||
Generated
+9
@@ -6060,6 +6060,15 @@ Namespace My.Resources
|
|||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
'''<summary>
|
||||||
|
''' Looks up a localized string similar to An error occured while determining a required system path. [BR][BR]The environment value for [PARAM] is empty.[BR][BR]The application will now exit..
|
||||||
|
'''</summary>
|
||||||
|
Friend ReadOnly Property mgrPath_SpecialPathError() As String
|
||||||
|
Get
|
||||||
|
Return ResourceManager.GetString("mgrPath_SpecialPathError", resourceCulture)
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
'''<summary>
|
'''<summary>
|
||||||
''' Looks up a localized string similar to [PARAM] backup restored..
|
''' Looks up a localized string similar to [PARAM] backup restored..
|
||||||
'''</summary>
|
'''</summary>
|
||||||
|
|||||||
@@ -2191,4 +2191,7 @@
|
|||||||
<data name="mgrBackup_ConfirmOverwriteRelative" xml:space="preserve">
|
<data name="mgrBackup_ConfirmOverwriteRelative" xml:space="preserve">
|
||||||
<value>A file with the same name already exists in the backup folder.[BR][BR]This game stores saves in a relative location, you may need to restore the current backup if the game was recently re-installed.[BR][BR]Do you want to overwrite this file?</value>
|
<value>A file with the same name already exists in the backup folder.[BR][BR]This game stores saves in a relative location, you may need to restore the current backup if the game was recently re-installed.[BR][BR]Do you want to overwrite this file?</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="mgrPath_SpecialPathError" xml:space="preserve">
|
||||||
|
<value>An error occured while determining a required system path. [BR][BR]The environment value for [PARAM] is empty.[BR][BR]The application will now exit.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user