;==================================================================================================
; Function Name: File_Seeker($path, $file, $array)
; Description: searchs for a file recursively on given drive
; Parameter(s): $path path where to search
; $file filename to search for
; $array to save the search results
; $ext search for file extension, e.g. .mp3
; $exact to search for exact file name (not case sensitive)
; $rec to search recursively for files and folders
; $folder include also folder names to search pattern
; Return Value(s): an array with the full path of the files, $array[0] = amount of found files
; Version: v0.82 Build 2010-02-13 Beta
; Author(s): UEZ
;==================================================================================================
Func File_Seeker($path, $file, ByRef $aResults, $ext = 0, $exact = 0, $rec = 1, $folder = 0)
Local $extended
If $file <> "" And IsArray($aResults) And BitAND($ext, $exact) <> 1 Then
If StringRegExp(StringLeft($path, 1), "[a-zA-Z]") And StringMid($path, 2, 1) = ":" Then
If StringRight($path, 1) <> "\" Then $path &= "\"
Local $seek, $suffix = ""
Local $search = FileFindFirstFile($path & "*")
If $search = -1 Then
SetError(2)
Return
EndIf
While 1
$seek = FileFindNextFile($search)
$extended = @extended
If @error Then ExitLoop
If $extended And $rec Then File_Seeker($path & $seek & "\", $file, $aResults, $ext, $exact, $rec, $folder)
If $exact And Not $ext Then
If $seek = $file Then _ArrayAdd($aResults, $path & $seek)
Else
If $ext Then
If StringRegExp($seek, "(?i:\" & $file & "+$\b)") And StringLeft($file, 1) = "." Then
If ($extended And $folder) Or Not $extended Then _ArrayAdd($aResults, $path & $seek)
EndIf
Else
If $file = "*" Then
If ($extended And $folder) Or Not $extended Then _ArrayAdd($aResults, $path & $seek)
Else
If StringInStr($file, ".") Then
If StringRegExp($seek, "(?i:\" & $file & ")+") Then
If ($extended And $folder) Or Not $extended Then _ArrayAdd($aResults, $path & $seek)
EndIf
Else
If StringRegExp($seek, "(?i:" & $file & ")+") Then
If ($extended And $folder) Or Not $extended Then _ArrayAdd($aResults, $path & $seek)
EndIf
EndIf
EndIf
EndIf
EndIf
WEnd
FileClose($search)
$aResults[0] = UBound($aResults) - 1
SetError(0)
Return $aResults
Else
SetError(1)
Return
EndIf
Else
SetError(1)
Return
EndIf
EndFunc ;==>File_Seeker