Menu

Unpacking 7z-archive from memory

Help
Anton-V-K
2022-12-14
2022-12-14
  • Anton-V-K

    Anton-V-K - 2022-12-14

    Does LZMA SDK has API for extracting 7z-archive from memory?
    Are there any examples to demonstrate such functionality? I've quickly examined \CPP\7zip\Bundles, but couldn't find relevant samples.

    Typical usage scenario: downloading an archive from Internet, while keeping it in memory, and extracting it to disk (or preferably to memory as well) when the download is complete.

    According to the hints in the related discussion Extract to memory , the interface IArchiveExtractCallback may partially help with this task. I guess, its method GetStream is called to request 'output stream' for writing extracted content.
    The only sample which overrides this method is CPP\7zip\Bundles\SFXSetup (I'm referring to CExtractCallbackImp::GetStream).
    So probably extracting to memory can be handled this way.

    And what about extracting from memory?

     
  • Igor Pavlov

    Igor Pavlov - 2022-12-14

    When you open archive you send IInStream object.

    IInArchive::
      STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openCallback)
    

    IInStream object can be created with
    CReferenceBuf from StreamObjects.h.

     
    👍
    1

    Last edit: Igor Pavlov 2022-12-14

Log in to post a comment.