class TJCRCreateStream - Tricky1975/JCR6_Sharp GitHub Wiki

class TJCRCreateStream

This class is created by TJCRCreate.NewEntry() and should only be created that way. It contains all data it needs to add the file/entry you want to add to JCR6 properly and also contains several methods to write data into the entry itself.

void WriteByte(byte b)

Writes a byte into the TJCRCreateStream

void WriteInt(int i)

Writes an integer into the TJCRCreateStream. Whether this be LittleEndian or BigEndian depends on the setting you chose when you created this stream (it cannot be changed afterward).

void WriteString(string s, bool raw = false)

Writes a string into a TJCRCreateStream. The "raw" boolean may need some extra explanation. If raw is set to "false" (the default setting), it will first write an integer value containing the length of the string and then the string itself. This in proper communication of the QuickStream.ReadString() method (see TrickyUnits). If 'raw' is set to "true" it will only save the string itself.

NOTE: I've only tested this with 'pure ASCII' so I do not know how UniCOde strings will respond to this routine. Please take note of that.

void WriteLong(long i)

Writes a long (64-bit integer) into the JCR6CreateStream. The same rules for Endian issues apply as for WriteInt()

void WriteBytes(byte[] b, bool ce = false)

Writes an array of bytes into a JCR6CreateStream In 99% of the cases the ce boolean value can best be left to false, unless you are an advanced programmer. 'ce' means "CheckEndian", and when set to "true" it will automatically reverse the array order when the Endian setting of your CPU is different from the Endian setting of the JCRCreateStream. This can be handy if you write nummeric types that JCR6 does not support by default.

void Close()

Closes the TJCRCreateStream and allows JCR6 to compress the written data (if instructed to do so) and to add it to the resource accordingly.

NOTE: When you close the JCRCreate resource or if that resource falls through the garbage collector, all TJCRCreateStreams which are still open, will automatically be closed, and handled accordingly. But as this is not really a nice and secure way to work, I do not recommend to let it come to that, and to close all TJCRCreateStream entries as soon as you are done with them to prevent memory issues or other unwanted issues. TJCRCreateStream data cannot fall through the garbage collector as long as they are still open and as long as their parent TJCRCreate is still active.

⚠️ **GitHub.com Fallback** ⚠️