Verfasst: 12.12.2006 08:51
ich sehe da auch keine mögliche continue-verwendung.
Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Code: Alles auswählen
ProcedureDLL PBE_ScanPath(path.s, callbackProcedure.l) ; Scan the given path recursively and call callback (optimized by AND51)
Protected dir=ExamineDirectory(#PB_Any, path, "")
If dir
While NextDirectoryEntry(dir)
If DirectoryEntryName(dir) <> "." And DirectoryEntryName(dir) <> ".."
CallFunctionFast(callbackProcedure, dir, path)
If DirectoryEntryType(dir) = #PB_DirectoryEntry_Directory
PBE_ScanPath(path + DirectoryEntryName(dir) + "\", callbackProcedure)
EndIf
EndIf
Wend
FinishDirectory(dir)
EndIf
EndProcedure
Code: Alles auswählen
EnableExplicit
Procedure PBE_ScanPath(Path.s, *callbackProc) ; Scan the given path recursively and call callback (format dirId.l, path.s) (optimized by AND51)
Protected dir.l, name.s, files.l
If *callbackProc = 0 : ProcedureReturn #False : EndIf
If Right(Path, 1) <> "\" : Path + "\" : EndIf
dir = ExamineDirectory(#PB_Any, Path, "")
If dir
While NextDirectoryEntry(dir)
name = DirectoryEntryName(dir)
If name <> "." And name <> ".."
If DirectoryEntryType(dir) = #PB_DirectoryEntry_Directory
files + PBE_ScanPath(Path + name + "\", *callbackProc)
Else
files + 1
CallFunctionFast(*callbackProc, Path + name)
EndIf
EndIf
Wend
FinishDirectory(dir)
ProcedureReturn files
EndIf
ProcedureReturn #False
EndProcedure
Procedure FileCallback(File.s)
Debug File
EndProcedure
Debug PBE_ScanPath("c:\programme\", @FileCallback())
Genau deshalb auch mein Ansatz mit der Übergabe der Dir-ID.AND51 hat geschrieben:Aber trotzdem ist Didelphodon's Idee, 'dir' statt des Dateinamens zu übergeben, besser!
Denn dann kann der Calback auf das dir von ExamineDirectory zugreifen und die befehele DirectoryEntry*() benutzen!!