Fixes for issue #39

This commit is contained in:
Michael J. Seiferling
2016-03-06 12:06:43 -06:00
parent ca9fef33ea
commit be2335b61e
2 changed files with 43 additions and 13 deletions
+35 -2
View File
@@ -3,6 +3,7 @@ Imports System.IO
Public Class frmFileFolderSearch Public Class frmFileFolderSearch
Private sSearchItem As String Private sSearchItem As String
Private sGameName As String = String.Empty
Private bIsFolder As Boolean Private bIsFolder As Boolean
Private sFoundItem As String Private sFoundItem As String
Private oDrives As List(Of DriveInfo) Private oDrives As List(Of DriveInfo)
@@ -12,6 +13,15 @@ Public Class frmFileFolderSearch
Delegate Sub UpdateInfoCallBack(ByVal sCurrentFolder As String) Delegate Sub UpdateInfoCallBack(ByVal sCurrentFolder As String)
Public Property GameName As String
Get
Return sGameName
End Get
Set(value As String)
sGameName = value
End Set
End Property
Public Property SearchItem As String Public Property SearchItem As String
Get Get
Return sSearchItem Return sSearchItem
@@ -50,17 +60,28 @@ Public Class frmFileFolderSearch
Private Function SearchDirectory(ByVal dir As DirectoryInfo, ByVal sDirectoryName As String) As String Private Function SearchDirectory(ByVal dir As DirectoryInfo, ByVal sDirectoryName As String) As String
Dim sSubSearch As String = String.Empty Dim sSubSearch As String = String.Empty
Dim sFoundItem As String = String.Empty
If bwSearch.CancellationPending Then If bwSearch.CancellationPending Then
Return "Cancel" Return "Cancel"
End If End If
'Ignore Symlinks
If (dir.Attributes And FileAttributes.ReparsePoint) = FileAttributes.ReparsePoint Then
Return String.Empty
End If
UpdateInfo(dir.FullName) UpdateInfo(dir.FullName)
Try Try
'Search Current Directory 'Search Current Directory
If dir.GetDirectories(sDirectoryName).Length > 0 Then If dir.GetDirectories(sDirectoryName).Length > 0 Then
Return dir.FullName & Path.DirectorySeparatorChar & sDirectoryName sFoundItem = dir.FullName & Path.DirectorySeparatorChar & sDirectoryName
If mgrCommon.ShowMessage(mgrPath_ConfirmPathCorrect, New String() {GameName, sFoundItem}, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Return sFoundItem
Else
Return String.Empty
End If
End If End If
'Search Sub Directory 'Search Sub Directory
@@ -82,23 +103,35 @@ Public Class frmFileFolderSearch
Private Function SearchFile(ByVal dir As DirectoryInfo, ByVal sFileName As String) As String Private Function SearchFile(ByVal dir As DirectoryInfo, ByVal sFileName As String) As String
Dim sSubSearch As String = String.Empty Dim sSubSearch As String = String.Empty
Dim sFoundItem As String = String.Empty
If bwSearch.CancellationPending Then If bwSearch.CancellationPending Then
Return "Cancel" Return "Cancel"
End If End If
'Ignore Symlinks
If (dir.Attributes And FileAttributes.ReparsePoint) = FileAttributes.ReparsePoint Then
Return String.Empty
End If
UpdateInfo(dir.FullName) UpdateInfo(dir.FullName)
Try Try
'Search Current Directory 'Search Current Directory
If dir.GetFiles(sFileName).Length > 0 Then If dir.GetFiles(sFileName).Length > 0 Then
Return dir.FullName & Path.DirectorySeparatorChar & sFileName sFoundItem = Path.GetDirectoryName(dir.FullName & Path.DirectorySeparatorChar & sFileName)
If mgrCommon.ShowMessage(mgrPath_ConfirmPathCorrect, New String() {GameName, sFoundItem}, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Return sFoundItem
Else
Return String.Empty
End If
End If End If
'Search Sub Directory 'Search Sub Directory
Dim subdirs() As DirectoryInfo = dir.GetDirectories("*") Dim subdirs() As DirectoryInfo = dir.GetDirectories("*")
For Each newDir As DirectoryInfo In subdirs For Each newDir As DirectoryInfo In subdirs
sSubSearch = SearchFile(newDir, sFileName) sSubSearch = SearchFile(newDir, sFileName)
If sSubSearch <> String.Empty Then If sSubSearch <> String.Empty Then
Return sSubSearch Return sSubSearch
End If End If
+4 -7
View File
@@ -346,6 +346,7 @@ Public Class mgrPath
Dim sFolder As String = String.Empty Dim sFolder As String = String.Empty
Dim bSearchFailed As Boolean = False Dim bSearchFailed As Boolean = False
frmFind.GameName = sGameName
frmFind.SearchItem = sProcess & ".*" frmFind.SearchItem = sProcess & ".*"
frmFind.FolderSearch = False frmFind.FolderSearch = False
@@ -366,13 +367,7 @@ Public Class mgrPath
frmFind.ShowDialog() frmFind.ShowDialog()
If frmFind.FoundItem <> String.Empty Then If frmFind.FoundItem <> String.Empty Then
sFolder = IO.Path.GetDirectoryName(frmFind.FoundItem) Return frmFind.FoundItem
sMessage = mgrCommon.FormatString(mgrPath_ConfirmPathCorrect, New String() {sGameName, sFolder})
If mgrCommon.ShowMessage(sMessage, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Return sFolder
Else
sFolder = String.Empty
End If
Else Else
bSearchFailed = True bSearchFailed = True
End If End If
@@ -386,6 +381,8 @@ Public Class mgrPath
If mgrCommon.ShowMessage(sMessage, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then If mgrCommon.ShowMessage(sMessage, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
sFolder = SetManualgamePath() sFolder = SetManualgamePath()
End If End If
frmFind.Dispose()
End If End If
Return sFolder Return sFolder