Hi,
i have an incoming object (file) on a istream.
i need to pass it to another (C programmed!)module in a char* array and
providing its size(also needing the size to mallocate the char* array).
i used to get it using the tellg() function. but on some files this does
not seem to work right.
kinda like this:
istream input;
input.seekg(0, ios::end);
int size=input.tellg();
but on some files the module i get the istream from seem to deliver a -1
when calling seekg. which is the error state.
strangely though i can read the whole input to a file like in:
ofstream out("file.bla", ios::out|ios::binary);
out << input.rdbuf();
so my idea and question is:
can i somehow copy/read the whole content into some kind of automated
buffer and get the size this way?(how much was copied).
the one thing i cant do is copy to a local file. so it should be some
kind of temp buffer.
I know this approach is somewhat slow and also wasteful but thats ok.
i need the size of that file!!!! :D
thanks for any ideas!