Best way to store a .zip within code

BlitzPlus Forums/BlitzPlus Programming/Best way to store a .zip within code

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'm a lazy bum with no way to upload files (don't ask why) and a guy did this someplace else without sharing his method. (http://www.blitzbasic.com/Community/posts.php?topic=38938#433551) So I ask, what is the best way to make a B+ file that writes a .zip file which is stored within the code, like a Data statement? Hopefully I don't sound too idiotic.

http://www.sodaware.net/dev/blitz/libs/blitz.zipapi/

I think that should be what you are looking for.

Ive done something like that by adding (just appending) a file to the exe and after that i read the exe from a certain seek position (size of the exe, without the included file) and "extracted" the file. It worked, but its possible that it could crash the application or something.

exe% = OpenFile(exe)
SeekFile(exe%, FileSize(exe))
zip% = ReadFile(zip)
for i = 1 to FileSize(zip)
    WriteByte(exe%, ReadByte(zip%))
next


No, I don't mean that, I mean doing something where I just post the code, you run it, and whoop-dee-doo now you have the zip file.


EDIT dang this post has a short limit.

Here it is with a much smaller zip:
;AddZipData "MindWarp.zip","MindZip.bb","file"

Function AddZipData(zip$,blitz$,label$)

	;Do the two files
	Local fil=ReadFile(zip)
	Local bb=OpenFile(blitz)
	If Not bb RuntimeError "BB file does not exist!"

	;Get end of file position for blitz file
	Repeat
		ReadByte bb
	Until Eof(bb)

	WriteLine bb,"."+label

	newl=1
	Repeat
		newl=newl-1
		If newl=0 Then 
			WriteLine bb,"Data "+Chr(34)+lin$+Chr(34)
			newl=140:lin=""
		EndIf
		writ$=Asc(ReadByte(fil))
		ok=0
		If Int(writ)<10 Then writ="00"+writ:ok=1
		If Int(writ)<100 And ok=0 Then writ="0"+writ
		lin$=lin$+writ
	Until Eof(fil)
	
	WriteLine bb,"Data "+Chr(34)+"END"+Chr(34)

End Function


	fil=WriteFile("MW.zip")
	Restore file
	Repeat
		Read lin$
		For r=1 To 140
			byte$=byte$+Mid(lin,r)
			If byte<>"END" Then WriteByte fil,Chr(byte) Else End
			byte$=""
		Next
	Forever

.file
Data ""
Data "056055051052050048048048056048049049049053050049054049049048048048050048048048049048048048055049049049056057049049052057049049049052049049049051049049049049052049054050053050051054053049049050049049051050049050053049049053050054049049055049050049050049050049053053049056050055050056049049055049050049050050049050050049055050056057049049049050055049049050049049050049049051050050050049050049050050049049050049049050053050"
Data "049049053057049053050049053050049056049049050049050054050053052051049052050049049049054049049049049049049057049050053050049050049054050049049049049050049049049056054050050050050049056055051052050048048048056048050049049053049050050050057050048048049056048048049048048048055049049049056057049049052049057049049049049052057057050056057049050052050049049051050054049049049049049050049050051049055057049054057049049057050053"
Data "049050049049049049051049049049050054057049050049049049049049051050049050050050049049049050050051049057049050050049049056049049049052055050049050049049050049050049049053049049049057049049049049057049050056052053055049050055056050049049050049053055049049050055050049054049049049049050050049049049050050049049053049049049050050055049049050050049050051049049052049049049050049055048050050049055049050049049050050054049049049"
Data "050050049049049051051054049049054049054050049049049050049050050049050057050050056054051050049053050049050055049050049055049053049052049050054052050050052049049050050050055053049050049049057052049050049056049050049049049049050054057055050050050053049050049049049050049054050050050049049049053049054053049049055056050055050050056049050050049057049050050051055049049055049055049049051051056049055053050057049049049049050050"
Data "052052056049055050050056048050049049057056050050050049051053049056049057049049051049050049050049049050050049057050050050049050052049049049057049050050050049050050050056057050049054050055050049057050050054056049050050050049050049049049050049050050049049049051054050050050049050050049049049050049050056050050050050049049049050050050050049049049049053050051049049049057049050053056049050049050049054049049049053049049050050"
Data "049050049049057051049049049056049050049057053050056049049050056049051050050049050050049049053050049049049054049049050049054049050053050052055050055053049050049049049051049048050049050054050050050049050056049052049057049051049050049049053049053049050049055049050049049052049049049050049050049049049054050049050049049049049049050052049050049056049057050056054050049050050049057053050049051049049055050050049049050049050049"
Data "050049050049055050050050049050050050050050054056055051052050048048048056048055049049053049050050050057050048048049056048048050048048048055049049049056057049049052049057049049049049052057057057057057049052050056057049050052050049049051050054049049049049049050049050051049055057049054057049049057050053049050049049049049051049049049050054057049050049049049049049051050049050050050049049049050050051049057049050050049049056"
Data "049049049052055050049050049049050049050049049053049049049057049049049049057049050056052053055049050055056050049049050049053055049049050055050049054049049049049050050049049049050050049049053049049049050050055049049050050049050051049049052049049049050049055048050050049055049050049049050050054049049049050050049049049051051054049049054049054050049049049050049050050049050057050050056054051050049053050049050055049050049055"
Data "049053049052049050054052050050052049049050050050055053049050049049057052049050049056049050049049049049050054057055050050050053049050049049049050049054050050050049049049053049054053049049055056050055050050056049050050049057049050050051055049049055049055049049051051056049055053050057049049049049050050052052056049055050050056048050049049057056050050050049051053049056049057049049051049050049050049049050050049057050050050"
Data "049050052049049049057049050050050049050050050056057050049054050055050049057050050054056049050050050049050049049049050049050050049049049051054050050050049050050049049049050049050056050050050050049049049050050050050049049049049053050051049049049057049050053056049050049050049054049049049053049049050050049050049049057051049049049056049050049057053050056049049050056049051050050049050050049049053050049049049054049049050049"
Data "054049050053050052055050055053049050049049049051049048050049050054050050050049050056049052049057049051049050049049053049053049050049055049050049049052049049049050049050049049049054050049050049049049049049050052049050049056049057050056054050049050050049057053050049051049049055050050049049050049050049050049050049055050050050049050050050050050054056055051052050048048048056048055049049053049052049050057050048048049056048"
Data "048050048048048055049049049056057049049052049057049049049049052057057057057057049053050056057049050052050049049051050054049049049049049050049050051049055057049054057049049057050053049050049049049049051049049049050054057049050049049049049049051050049050050050049049049050050051049057049050050049049056049049049052055050049050049049050049050049049053049049049057049049049049057049050056052053055049050055056050049049050049"
Data "053055049049050055050049054049049049049050050049049049050050049049053049049049050050055049049050050049050051049049052049049049050049055048050050049055049050049049050050054049049049050050049049049051051054049049054049054050049049049050049050050049050057050050056054051050049053050049050055049050049055049053049052049050054052050050052049049050050050055053049050049049057052049050049056049050049049049049050054057055050050"
Data "050053049049053057049054049053049049049049055050050049050049050052049053055049053049049049056049052054049056050049049053050050053049053053049049049056050052050051049050049050049050057049049055050050050050049049052050050049051056049049049049050050055049049049055049049052049056049055049057048049049049051053049049049053049049057055053049050049056054049049049049050054053049049049050049050057050054049057049056050050050049"
Data "049050050050049049049050049050049050053049049049053050050049054049053049049057049050050057049057050049050050050049049049049050049056056050057051049050049054052049049050050049050049050050050054050049049052050051055050056050049050049054054054050055050049050050052053054049051050057050054050050052050051055049049049050049049051056051050050053049054052049050050056049049050049053049049049051049049050051050049049049049049050"
Data "052050050050050050050049054050049052049049056049049055049049050049050057050049049049049055049050050049056050049057055050050053053049049049050049049049050049051050056050054049050049050050053052055053049049057049050049050049050050056055051052050048048048056048050056049053049057049056053051048048049054048048049048048048055049049049056057049049052049057049049049049052049049049049056049049050052049049051050049049049056057"
Data "056049049050049054056049049056054051049050049049050050049050049051050050053049050050053057050056050056050049050050049053050050050049049055051050052050049050049051049049050050049049049055049055049050049050050056049049053051057050049050053049050049052055049049049049049050057049050054050051049053056049053050050055050050050048050049055049051052052055050049050049049049050049049049050049049052056049049050050049055056055050"
Data "056049049056055056049057049057049049050049050049051049050049049049049051050049049049049050049049049051055053051049050050049049050051049054050049050049049049057054055052050049049051049056049049049050049056056049051055052050057050050049049050053053054050049049050049049055049050050057050050054057056056049051049056049049057049057049050049055050053055049050050057049055050049055049054049049049054057050050055049049055049050"
Data "056056049051049054049049055056050050051053049049049050049049050049054050049049053049050049053049052055050057050049049054051049050049051050053049049049049050050050054049052049049050057050050049050049049051055050049050049052050049056049057049049049057049051056050049050049050050052049049050049055050053049050049050050054049049049049050049049049050056051051050049049057057050054050049049049049049049049049049050050054049056"
Data "056057049049049049050049049050056049056050050055050049051049049050049050049050050049049050049050049049055049050054049049050050049049053050049049053050049050053050049050050049050049051054057049052055049050057049049050049054055049049049052051050050050055049052055054050050049049049049053050050050050049049050050049051049049049050049054054050056050050049054049049053049054054053050051054054049050050050057049049050056049050"
Data "049050053051050050049049050055050049050049055053049049049050050049055049049050049056055054056050049053049056050049049050050049049051049050049049049056050053054055053049050049049050049050053049049050056050057049049057057050050049049049054050050050050052049050050055057052052049050050050049052052049050056049057051053055050049049049049049049049049049049049049054050049049049051049056049049050053049050056050049050049053049"
Data "054049053049050055050049050049049049049050050049049057050050050053050056049054053049049049049054050049049049050049050050050056049056050051053055049049049051052053057049050049049057050051050055049055055049050057049049050057049050049056050053049050050056049050050049049057050050049050056049050050050050050053049049049057050054056055049050050049050048048048056048049049049053050049054049049048048048050048048048049048048048"
Data "048048048048049048051048048048048048048048055049049049056057049049052057049049049052049049049056055049050050049050048048048056048050049049053049050050050057050048048049056048048049048048048048048048048049048051048048048050048048048055049049049056057049049052049057049049049049052057057056055049050050049050048048048056048055049049053049050050050057050048048049056048048050048048048048048048048049048051048048048056051048"
Data "048055049049049056057049049052049057049049049049052057057057057057049052056055049050050049050048048048056048055049049053049052049050057050048048049056048048050048048048048048048048049048051048048048050053048048055049049049056057049049052049057049049049049052057057057057057049053056055049050050049050048048048056048050056049053049057049056053051048048049054048048049048048048048048048048049048051048048048049056048048055"
Data "END"



Hm... why is the new file 100 bytes bigger than the original?

sorry for post =/

can someone delete this please

sorry for the post =/

could someone please delete this

If you use the WriteLine command, blitz add to every line the lenght (of the line) in 2 bytes.

For example "HELLO" will take 7 bytes and not 5. It you read the line with ReadLine you must remove the first 2 bytes. So i recommand to use "Bytes" for this.

bye

What difference does it make? Writing with it to a bb file shouldn't cause any issues, should it?