[Solved] TRamStream - Creating a textfile in memory?

BlitzMax Forums/BlitzMax Beginners Area/[Solved] TRamStream - Creating a textfile in memory?

Grisu(Posted May) [#1]
Hello guys!

I want to write a textfile to a zip archive.

But doing this I don't want to write it to the HDD/SDD first and then zip it later. Instead I would like to create a simple textfile as filebuffer / TRamStream object and zip it directly. Should be much faster.

Can someone give me a simple example on how to add multiple strings to a filebuffer?

Something like this doesn't work:
Local zipfileBuffer:TRamStream 
WriteLine zipfileBuffer, "This is String #1"
WriteLine zipfileBuffer, zipfileBuffer+"This is String #2 added"


Grisu


degac(Posted May) [#2]
At the moment I'm not on my computer, but I suppose you need to Create a RamStream before using it, not sure!


BlitzSupport(Posted May) [#3]
Can't check right now, but think it will be something like:

Local zipfileBuffer:TRamStream 

zipfileBuffer = CreateStream () ' Or WriteStream (zipfileBuffer)?

if zipfileBuffer

WriteLine zipfileBuffer, "This is String #1"
WriteLine zipfileBuffer, "This is String #2 added" ' DOn't try to use zipfileBuffer as a string!

CloseStream zipfileBuffer

Endif




Grisu(Posted May) [#4]
Thanks.

Getting closer, after some more goggeling. :)

Still need to test, if this works with the zip module.




Grisu(Posted May) [#5]
Works perfectly. Sometimes you just need a friendly slap in the face to get you back on track. :)

Thanks again!