I need to create a temporary file, fill it with some data and send the result to a function that accepts only std::istreams
.
I tried using tmpfile() and it works for my first requirement - 'create a file and fill it with some data', but it returns a FILE*
and there is no way to convert it (as far as I know) to std::streams
.
Is there a C++ way of creating a temporary file? If this is not possible, how reliable is tmpnam to return a valid file name? Did anyone test this on Android or iOS?
EDIT: I don't want to copy the data to std::stringstream
as a part of my test is reading the data from the disk.