specially to get Fangles working....

using Filemapping, works only in windows
Code: Select all
;;Build md5 sum for a partial file
;(c) 2007 by Siegfried Rings
;Windows only
Procedure.s MD5_PartCheck(Filename.s,Maxsize)
length=FileSize(Filename)
If Length<1: ProcedureReturn "":EndIf
If Length>Maxsize:Length=Maxsize:EndIf;Check for max 50000 bytes, should be enough
;md5.s=""
handle=CreateFile_(Filename, #GENERIC_READ , #FILE_SHARE_READ , 0, #OPEN_EXISTING , #FILE_ATTRIBUTE_NORMAL,0)
If handle
MapHandle = CreateFileMapping_(handle, 0, #PAGE_READONLY, 0, length, 0)
If MapHandle
ViewHandle = MapViewOfFile_(MapHandle, #FILE_MAP_READ , 0, 0, 0)
If ViewHandle
md5.s=MD5Fingerprint(ViewHandle, length)
UnmapViewOfFile_(ViewHandle)
EndIf
CloseHandle_(MapHandle) ;okay, now close the Maphandle
EndIf
CloseHandle_(handle);okay, now close the Filehandle
ProcedureReturn md5.s
EndIf
EndProcedure
Debug MD5_PartCheck("c:\test.mp3",50000)