SourceForge has been redesigned. Learn more.
Close

SDK LZMA Stream C#

Help
GordonJ
2013-05-01
2013-05-05
  • GordonJ

    GordonJ - 2013-05-01

    Hi,

    I am using the C# SDK and I can decode a LZMA stream to a memory stream or a output file stream by setting up the input and output streams and calling this one line of the decoder:

      decoder.Code(inStream, outStream, outstreamsize, null);
    

    (There is a lot more setup that I am not showing, configuring the streams and so on.)

    My question is: is it possible with the SDK to get the output of the LZMA as a stream that I can then use so it would be something more like this:

      Stream readStream=decoder. ***** something here to get a decoded LZMA stream *****
    
      byte[] _buffer = new byte[BufferSize];
      ulong sizetogo = outstreamsize;
      while (sizetogo > 0)
      {
           int sizenow = sizetogo > BufferSize ? BufferSize : (int)sizetogo;
           readStream.Read(_buffer, 0, sizenow);
    
           /* more code in here to use and write out the _buffer */
    
           sizetogo = sizetogo - (ulong)sizenow;
      }
      readStream.Close();
    

    Thanks in advance.

    GordonJ.

     
  • Igor Pavlov

    Igor Pavlov - 2013-05-02

    C# LZMA decoder in LZMA SDK doesn't support such interface.
    You can use C version of LZMA decoder instead.

     
  • GordonJ

    GordonJ - 2013-05-05

    Thanks for the fast reply,
    I have now successfully converted the C# SDK Decoder into a correctly working C# stream:
    public class Decoder : Stream, ICoder, ISetDecoderProperties

    and added:
    public override int Read(byte[] buffer, int offset, int count)

    So it does now correctly work with my above code example.

     

Log in to post a comment.