Search code examples
c++qtmemorystreambuffering

C++ (Qt), System command using memory buffers instead of redirection


I would like to know how to use memory buffers as the io streams to a system command using Qt.

Normally you would do something pseudocode like:

Exec Command(" command < inputfile > outputfile");

but I would like to do the entire operation in memory.

I would prefer Something psudocode like:

ByteArray input;
ByteArray output;
Exec Command("command name", &input, &output);

A specific reference, example or link to the answer would be awesome. I just need a starting spot, I think.

Thanks in advance.


Solution

  • One way to do that would be to create memory-mapped input and output files, and specify full path to input and output files in regular shell command - this way it will effectively be in memory.

    You can create/access those programmatically, take a look at

    Streaming from memory mapped files in Qt