fb:porticula NoPaste
io.bas
Uploader: | csde_rats |
Datum/Zeit: | 26.11.2007 23:27:32 |
/'
DOFDA1
data or file digest algorithm 1
(c) 2007 Marian Beermann
aka csde_rats
'/
#Include "dofda1.bi"
Function dofda1_io_getblock(FileNum As UByte, Offset As ULongInt) As dofda1_block Export
Dim tempblock As dofda1_block
Get #FileNum, _
Offset, _
tempblock.num
For n As Integer = 0 To BlockLen
Get #FileNum, _
(Offset+SizeOf(tempblock.num)+(n*SizeOf(tempblock.dat(n)))), _
tempblock.dat(n)
Next
Return tempblock
End Function
Function dofda1_io_writeblock(FileNum As UByte, Offset As ULongInt, bBlock As dofda1_block) As Boolean Export
Dim tempblock As dofda1_block
tempblock = bBlock
If Lof(FileNum) < SizeOf(dofda1_desc) Then Return FALSE
Put #FileNum, _
Offset, _
tempblock.num
For n As Integer = 0 To BlockLen
Put #FileNum, _
(Offset+SizeOf(tempblock.num)+(n*SizeOf(tempblock.dat(n)))), _
tempblock.dat(n)
Next
Put #FileNum, _
(Offset+SizeOf(tempblock.num)+(BlockLen*SizeOf(tempblock.dat(BlockLen)))), _
tempblock.sHash
Return TRUE
End Function
Function dofda1_io_writecontext(FileNum As UByte, Offset As ULongInt, cContext As dofda1_context) As Boolean Export
Dim tempblock As dofda1_block
With cContext
Put #FileNum, _
Offset, _
.desc
Put #FileNum, _
(Offset+SizeOf(.desc)), _
.iBlockNum
For n As ULongInt = 0 To cContext.iBlockNum
tempblock = .ubRawBlocks(n)
If Lof(FileNum) < SizeOf(dofda1_desc) Then Return FALSE
Put #FileNum, _
(Offset+SizeOf(.desc)+SizeOf(.iBlockNum)), _
tempblock.num
For n As Integer = 0 To BlockLen
Put #FileNum, _
(Offset+SizeOf(.desc)+SizeOf(.iBlockNum)+SizeOf(tempblock.num)+(n*SizeOf(tempblock.dat(n)))), _
tempblock.dat(n)
Next
Put #FileNum, _
(Offset+SizeOf(.desc)+SizeOf(.iBlockNum)+SizeOf(tempblock.num)+(BlockLen*SizeOf(tempblock.dat(BlockLen)))), _
tempblock.sHash
Next
End With
Return TRUE
End Function