int __stdcall PackToMem (int hMemPack,char* BufIn,int InLen,int* Taken,char* BufOut, int OutLen,int* Written,int SeekBy);
PackToMem should return MEMPACK_OK (=0) on success, MEMPACK_DONE (=1) when done, or one of the error values otherwise.
- hMemPack is the handle returned by StartMemPack()
- BufIn is a pointer to the data which needs to be packed
- InLen contains the number of bytes pointed to by BufIn.
- Taken has to receive the number of bytes taken from the buffer. If not the whole buffer is taken, the calling program will pass the remaining bytes to the plugin in a later call.
- BufOut is a pointer to a buffer which can receive packed data
- OutLen contains the size of the buffer pointed to by BufOut
- Written has to receive the number of bytes placed in the buffer pointed to by BufOut
- SeekBy may by set to the offset from the current output posisition by which the file pointer has to be moved BEFORE accepting the data in BufOut. This allows the plugin to modify a file header also AFTER packing, e.g. to write a CRC to the header.
PackToMem is the most complex function of the packer plugin. It is called by Total Commander in a loop as long as there is data to be packed, and as there is data to retrieve. The plugin should do the following:
- As long as there is data sent through BufIn, take it and add it to your internal buffers (if there is enough space).
- As soon as there is enough data in the internal input buffers, start packing to the output buffers.
- As soon as there is enough data in the internal output buffers, start sending data to BufOut.
- When InLen is 0, there is no more data to be compressed, so finish sending data to BufOut until no more data is in the output buffer.
- When there is no more data available, return 1.
- There is no obligation to take any data through BufIn or send any through BufOut. Total Commander will call this function until it either returns 1, or an error.