Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;tharrell.net
  2. UseCRC32Fingerprint()
  3.  
  4. Declare crawl(path$)
  5. Declare Verify(path$)
  6.  
  7. path$=PathRequester("","")
  8. If Len(path$)>0
  9.   Debug "file-path,file-size,CRC32 of file"
  10.   crawl(path$)
  11. EndIf
  12.  
  13. ;path$=OpenFileRequester("","","*.*",0)
  14. ; If Len(path$)>0
  15. ;   Verify(path$)
  16. ; EndIf
  17. End
  18.  
  19. Procedure crawl(path$)
  20.   Protected emdir.l
  21.   emdir=ExamineDirectory(#PB_Any,path$,"*.*")
  22.   If emdir
  23.     While NextDirectoryEntry(emdir)
  24.       Delay(2)
  25.       If DirectoryEntryType(emdir)=#PB_DirectoryEntry_Directory
  26.         If DirectoryEntryName(emdir)<>"." And DirectoryEntryName(emdir)<>".." And DirectoryEntryName(emdir)<>"$RECYCLE.BIN"
  27.           CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  28.             crawl(path$+DirectoryEntryName(emdir)+"/")
  29.           CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
  30.             crawl(path$+DirectoryEntryName(emdir)+"\")
  31.           CompilerElse
  32.             crawl(path$+DirectoryEntryName(emdir)+"/")
  33.           CompilerEndIf
  34.         EndIf
  35.       Else
  36.         Debug path$+DirectoryEntryName(emdir)+","+FileSize(path$+DirectoryEntryName(emdir))+","+FileFingerprint(path$+DirectoryEntryName(emdir),#PB_Cipher_CRC32)
  37.       EndIf
  38.     Wend
  39.     FinishDirectory(emdir)
  40.   EndIf
  41. EndProcedure
  42.  
  43. Procedure Verify(path$)
  44.   Protected ss$
  45.   If FileSize(path$)>0
  46.     If ReadFile(0,path$)
  47.       While Eof(0)=0
  48.         Delay(2)
  49.         ss$=ReadString(0)
  50.         If OSVersion()<>#PB_OS_Windows And CountString(StringField(ss$,1,","),"\")>0 : ss$=ReplaceString(ss$,"\","/") : EndIf
  51.         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
  52.       Wend
  53.       CloseFile(0)
  54.     EndIf
  55.   EndIf
  56. EndProcedure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement