Create an inputStream from a MemoryBlock, help me


#1

how I can create an inputStream from a MemoryBlock.


#2
MemoryBlock myMemoryBlock;
MemoryInputStream myInputStream (myMemoryBlock.getData(), myMemoryBlock.getSize(), false);

#3

thank you very much.


#4

InputStream need to GZIPDecompressorInputStream.


#5

my code

        File f=File("agent.gas");
        file_inStream=f.createInputStream();
        MemoryBlock mb;
        file_inStream->readIntoMemoryBlock(mb,8);
   
        if (mb.toString()!="YCC-GAS!") {
            txtinf->setText("Invalid format",false);
            return;
        }
        mb.removeSection(0,mb.getSize());

       file_inStream->readIntoMemoryBlock(mb,file_inStream->getTotalLength()-8);

      InputStream*  data_decomp=(InputStream*)mb.getData(); //does not work     I

       GZIPDecompressorInputStream zipDecomp(data_decomp, false,true);
        

helps to create an InputStream from MemoryBlock


#6

[quote=“TheVinn”] MemoryBlock myMemoryBlock; MemoryInputStream myInputStream (myMemoryBlock.getData(), myMemoryBlock.getSize(), false); [/quote]

MemoryInputStream not valid for GZIPDecompressorInputStream


#7

yesssssssssss, problem solved.

        File f=File("agent.gas");
        file_inStream=f.createInputStream();
        MemoryBlock mb;
        file_inStream->readIntoMemoryBlock(mb,8);
   
        if (mb.toString()!="YCC-GAS!") {
            txtinf->setText("Invalid format",false);
            return;
        }
        mb.removeSection(0,mb.getSize());

       file_inStream->readIntoMemoryBlock(mb,file_inStream->getTotalLength()-8);

      MemoryInputStream*  data_decomp=new MemoryInputStream(mb.getData(),mb.getSize(),false);

       GZIPDecompressorInputStream zipDecomp(data_decomp, false,true);

Ok -----> MemoryInputStream* data_decomp=new MemoryInputStream(mb.getData(),mb.getSize(),false);