der Vollständigkeit halber hier nochmal eine einfache datenbankbasierte Lösung:
Code: Alles auswählen
Structure sFile
Path.s
Name.s
EndStructure
NewList SourceFile.sFile()
NewList DestinationFile.sFile()
Procedure ListFiles(EntryPath.s, List File.sFile())
; by Lebostein
; http://www.purebasic.fr/german/viewtopic.php?p=80742#p80742
Protected UsedDirectory
Protected EntryType
Protected EntryName.s
If Right(EntryPath, 1) <> "\" : EntryPath + "\" : EndIf
UsedDirectory = ExamineDirectory(#PB_Any, EntryPath, "*.*")
If UsedDirectory
While NextDirectoryEntry(UsedDirectory)
EntryType = DirectoryEntryType(UsedDirectory)
EntryName = DirectoryEntryName(UsedDirectory)
If EntryName = "." Or EntryName = "..": Continue: EndIf
If EntryType = #PB_DirectoryEntry_File
AddElement(File())
File()\Path = EntryPath
File()\Name = EntryName
EndIf
If EntryType = #PB_DirectoryEntry_Directory: ListFiles(EntryPath + EntryName, File()): EndIf
Wend
FinishDirectory(UsedDirectory)
EndIf
EndProcedure
ClearList(SourceFile())
ClearList(DestinationFile())
ListFiles("D:\test\tango1\", SourceFile())
ListFiles("D:\test\tango2\", DestinationFile())
UseSQLiteDatabase()
DB = OpenDatabase(#PB_Any, ":memory:", "", "", #PB_Database_SQLite)
DatabaseUpdate(DB, "Create Table SourceFiles (Path, Name)")
DatabaseUpdate(DB, "Create Table DestinationFiles (Path, Name)")
ForEach SourceFile()
DatabaseUpdate(DB, "Insert Into SourceFiles (Path, Name) Values ('" + SourceFile()\Path + "', '" + SourceFile()\Name + "')")
Next
ForEach DestinationFile()
DatabaseUpdate(DB, "Insert Into DestinationFiles (Path, Name) Values ('" + DestinationFile()\Path + "', '" + DestinationFile()\Name + "')")
Next
Debug "Dateien, die in Source fehlen:"
If DatabaseQuery(DB, "Select Name From DestinationFiles Where Name Not In (Select Name From SourceFiles)")
While NextDatabaseRow(DB)
Debug GetDatabaseString(DB, 0)
Wend
FinishDatabaseQuery(DB)
EndIf
Debug "Dateien, die in Destination fehlen:"
If DatabaseQuery(DB, "Select Name From SourceFiles Where Name Not In (Select Name From DestinationFiles)")
While NextDatabaseRow(DB)
Debug GetDatabaseString(DB, 0)
Wend
FinishDatabaseQuery(DB)
EndIf
CloseDatabase(DB)
Habe jetzt keine Geschwindigkeitsmessung gemacht, dürfte aber recht flott sein.
Grüße ... Kiffi
// Edit: Die LinkedLists braucht man hier eigentlich nicht
Code: Alles auswählen
Procedure ListFiles(EntryPath.s, DB, Tablename.s)
; by Lebostein
; http://www.purebasic.fr/german/viewtopic.php?p=80742#p80742
Protected UsedDirectory
Protected EntryType
Protected EntryName.s
If Right(EntryPath, 1) <> "\" : EntryPath + "\" : EndIf
UsedDirectory = ExamineDirectory(#PB_Any, EntryPath, "*.*")
If UsedDirectory
While NextDirectoryEntry(UsedDirectory)
EntryType = DirectoryEntryType(UsedDirectory)
EntryName = DirectoryEntryName(UsedDirectory)
If EntryName = "." Or EntryName = "..": Continue: EndIf
If EntryType = #PB_DirectoryEntry_File
DatabaseUpdate(DB, "Insert Into " + Tablename + " (Path, Name) Values ('" + EntryPath + "', '" + EntryName + "')")
EndIf
If EntryType = #PB_DirectoryEntry_Directory: ListFiles(EntryPath + EntryName, DB, Tablename): EndIf
Wend
FinishDirectory(UsedDirectory)
EndIf
EndProcedure
UseSQLiteDatabase()
DB = OpenDatabase(#PB_Any, ":memory:", "", "", #PB_Database_SQLite)
DatabaseUpdate(DB, "Create Table SourceFiles (Path, Name)")
DatabaseUpdate(DB, "Create Table DestinationFiles (Path, Name)")
ListFiles("D:\test\tango1\", DB, "SourceFiles")
ListFiles("D:\test\tango2\", DB, "DestinationFiles")
Debug "Dateien, die in Source fehlen:"
If DatabaseQuery(DB, "Select Name From DestinationFiles Where Name Not In (Select Name From SourceFiles)")
While NextDatabaseRow(DB)
Debug GetDatabaseString(DB, 0)
Wend
FinishDatabaseQuery(DB)
EndIf
Debug "Dateien, die in Destination fehlen:"
If DatabaseQuery(DB, "Select Name From SourceFiles Where Name Not In (Select Name From DestinationFiles)")
While NextDatabaseRow(DB)
Debug GetDatabaseString(DB, 0)
Wend
FinishDatabaseQuery(DB)
EndIf
CloseDatabase(DB)