[bb] Data Archiver by Andres [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:42

Previous topic - Next topic

BlitzBot

Title : Data Archiver
Author : Andres
Posted : 1+ years ago

Description : Download the packer from <a href="http://www.oat.ee/andres/projects/da.exe" target="_blank">here</a>

LoadDAFile%() will only restore/unpack files! You have to download the <a href="http://www.oat.ee/andres/projects/da.exe" target="_blank">packer</a> to archive files.
path$ - path of a file
FNCFile$ - the archive
targetfile$ - file name/path$ as the file will be restored


Code :
Code (blitzbasic) Select
Function LoadDAFile%(path$, FNCFile$ = "data.da", targetfile$ = "temp.da")
If Not Mid$(path$, 1, 1) = "" Then path$ = "" + path$
Local file% = ReadFile(FNCFile$), bank%, output%
If file%
FNCVersion$ = ReadString$(file%)
While Not Eof(file%)
tpath$ = ReadString(file%)
isfile% = ReadByte(file%)
size% = ReadInt(file%)
If Lower(tpath$) = Lower(path$) And isfile% = 1
output% = WriteFile(targetfile$)
bank = CreateBank(10 * 1024)
If bank% And output%
While TN < size%
If TN + BankSize(bank) > size% Then N = size% - TN Else N = BankSize(bank)
N = ReadBytes(bank, file%, 0, N)
For i = 0 To N - 1
PokeByte(bank, i, 255 - PeekByte(bank, i))
Next
WriteBytes(bank, output%, 0, N)
TN = TN + N
Wend
CloseFile file%
CloseFile output%
FreeBank bank
Return True
EndIf
Else
SeekFile(file%, FilePos(file%) + size%)
EndIf
Wend
CloseFile file%
EndIf
End Function

Function FreeDAFile(targetfile$ = "temp.da")
If FileType(targetfile$) = 1 Then DeleteFile targetfile$
If FileType(targetfile$) = 0 Then Return True
End Function


Comments : none...