fb:porticula NoPaste
FolderSearch (allocate/PTR)
Uploader: | Eternal_Pain |
Datum/Zeit: | 14.07.2007 18:59:50 |
Type SearchX
Folder as String
Mask as String
End Type
Type Folder_
Folder as ZString PTR
FolderStart as UInteger PTR
FolderLen as UInteger PTR
MaxFolder as UInteger
LenFolder as UInteger
End Type
Sub SearchFolders (Byval Search as SearchX)
'FreeF (Integer)
Dim FreeF as Integer
FreeF=FreeFile
'FreeF Speichert die naechste freie Dateinummer'
'FF as Folder_ (UDT)
Dim FF as Folder_
Dim NextFolder as UInteger
Dim FolderBuffer as String
Open Pipe "Dir "+Search.Folder+"\*.* /AD /B /S" for input as #FreeF
While Not Eof(FreeF)
Line Input #FreeF,FolderBuffer
If INSTR(lcase(FolderBuffer),lcase(Search.Mask)) Then
FF.Folder=allocate(FF.LenFolder+Len(FolderBuffer)+1)
FF.Folder[FF.LenFolder]=255
*FF.Folder+=FolderBuffer
FF.FolderStart=allocate((FF.MaxFolder+1)*4)
FF.FolderLen=allocate((FF.MaxFolder+1)*4)
FF.FolderStart[FF.MaxFolder]=Len(*FF.Folder)+1
FF.FolderLen[FF.MaxFolder]=Len(FolderBuffer)
FF.MaxFolder+=1
FF.LenFolder=Len(*FF.Folder)
End If
Wend
Close #FreeF
If FF.MaxFolder=0 Then exit sub
?FF.MaxFolder
?*FF.Folder
For l as integer=0 to FF.MaxFolder-1
?l,FF.FolderStart[l],mid(*FF.Folder,FF.FolderStart[l],FF.FolderLen[l]),FF.FolderLen[l]
Next l
End Sub
Dim test as SearchX
test.Folder="D:\freebasic"
test.Mask="int"
SearchFolders (test)
sleep