using fstream to read resource data c++
-
my application currently reads and uses data from files at a location on the host machine using fstream what i would like to do is include these files and their data as resources so that the application does not rely on the data being stored on the host machine i am using FindResource, LoadResource, LockResource etc but i'm having trouble passing the actual data content straight to fstream - is this possible??
FindResource(..); LoadResource(..); char* ptr = (char*) LockResource(..); fstream.open(ptr,ofstream::binary);
any help would be greatly appreciated - i'm pretty new to resources! -
my application currently reads and uses data from files at a location on the host machine using fstream what i would like to do is include these files and their data as resources so that the application does not rely on the data being stored on the host machine i am using FindResource, LoadResource, LockResource etc but i'm having trouble passing the actual data content straight to fstream - is this possible??
FindResource(..); LoadResource(..); char* ptr = (char*) LockResource(..); fstream.open(ptr,ofstream::binary);
any help would be greatly appreciated - i'm pretty new to resources!bimgot wrote:
char* ptr = (char*) LockResource(..);
What do you want to do with
ptr
at this point?bimgot wrote:
fstream.open(ptr,ofstream::binary);
The first argument to
fstream
's constructor is the name of the file to open, not the actual data within the file. Perhaps that is where your confusion lies.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
bimgot wrote:
char* ptr = (char*) LockResource(..);
What do you want to do with
ptr
at this point?bimgot wrote:
fstream.open(ptr,ofstream::binary);
The first argument to
fstream
's constructor is the name of the file to open, not the actual data within the file. Perhaps that is where your confusion lies.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
as i understand LockResource returns a pointer to the first byte of the data stored in the resource.. currently i use fstream to read, validate and store some wave file data so that it can be used to play back the wave file since the open function of fstream takes a char* for the name of the file to open, i wondered if a char* for the resource would work in the same way i think my confusion is as you say with fstream but since the class i want to use the data from the resource with is based on fstream, i wondered if there was a solution that doesnt involve re-writing the class..