kyz/libmspack

Decompressing files in memory?

samsonsite1 opened this issue · 3 comments

Please add support for decompressing files that have already been loaded into memory.

I'm trying to use mszipd_init() and mszipd_decompress(), but it will only work with file handles.

Or if it already does it, then I would like to see a C/C++ coding example of how to decompress a file loaded in a memory buffer. Thanks.

Ah, nevermind. I figured it out. I had to create my own file system, and remove the default file system, mspack_default_system.

But, it would have been much easier if libmspack had an C/C++ coding example of a file system that reads/writes from memory, instead of using file handles, so people could just use that as a starting point. So, stil requesting a coding example for the docs.

kyz commented

Hi samsonite1, glad to hear you found out how to do it.

For reference, the libmspack README has an example code section and it lists with two relevant example programs in the test/ directory:

  • cabd_memory - An mspack_system implementation that reads/writes to memory.
  • multifh - An mspack_system implementation that can simultaneously work on in-memory images, raw file descriptors, open file handles and regular disk files.

I'll consider breaking up the test/ directory into extra directories like examples/ and only leaving automated tests in test/, it seems to be causing confusion.

kyz commented

I've created a new directory, examples/, which contains the cabd_memory.c and multifh.c programs. This should make them more findable