Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;tharrell.net
- UseCRC32Fingerprint()
- Declare crawl(path$)
- Declare Verify(path$)
- path$=PathRequester("","")
- If Len(path$)>0
- Debug "file-path,file-size,CRC32 of file"
- crawl(path$)
- EndIf
- ;path$=OpenFileRequester("","","*.*",0)
- ; If Len(path$)>0
- ; Verify(path$)
- ; EndIf
- End
- Procedure crawl(path$)
- Protected emdir.l
- emdir=ExamineDirectory(#PB_Any,path$,"*.*")
- If emdir
- While NextDirectoryEntry(emdir)
- Delay(2)
- If DirectoryEntryType(emdir)=#PB_DirectoryEntry_Directory
- If DirectoryEntryName(emdir)<>"." And DirectoryEntryName(emdir)<>".." And DirectoryEntryName(emdir)<>"$RECYCLE.BIN"
- CompilerIf #PB_Compiler_OS = #PB_OS_Linux
- crawl(path$+DirectoryEntryName(emdir)+"/")
- CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
- crawl(path$+DirectoryEntryName(emdir)+"\")
- CompilerElse
- crawl(path$+DirectoryEntryName(emdir)+"/")
- CompilerEndIf
- EndIf
- Else
- Debug path$+DirectoryEntryName(emdir)+","+FileSize(path$+DirectoryEntryName(emdir))+","+FileFingerprint(path$+DirectoryEntryName(emdir),#PB_Cipher_CRC32)
- EndIf
- Wend
- FinishDirectory(emdir)
- EndIf
- EndProcedure
- Procedure Verify(path$)
- Protected ss$
- If FileSize(path$)>0
- If ReadFile(0,path$)
- While Eof(0)=0
- Delay(2)
- ss$=ReadString(0)
- If OSVersion()<>#PB_OS_Windows And CountString(StringField(ss$,1,","),"\")>0 : ss$=ReplaceString(ss$,"\","/") : EndIf
- If FileSize(StringField(ss$,1,","))<>Val(StringField(ss$,2,",")) Or FileFingerprint(StringField(ss$,1,","),#PB_Cipher_CRC32)<>StringField(ss$,3,",") : Debug StringField(ss$,1,",")+" is corrupt" : EndIf
- Wend
- CloseFile(0)
- EndIf
- EndIf
- EndProcedure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement