Memory Location to FILE *

Started by
1 comment, last by 31337 19 years, 10 months ago
Is there anyway to make a FILE * point to a spot in memory? I know that with fread() for the FILE * you can pass it stdin.
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
Advertisement
Technically you could make a FILE * pointer point to a space in memory, like so:

FILE *p = (FILE*)0x48181561894; // Memory address


but it wont do you any good. fread only wants to receive fp structures that either point to a stream or file. and as stdin is a stream its fine, just like stdout, stderr, stdprn, etc.

But why do you want a FILE * to point to a place in memory??
Well, here''s the problem.

I''m modifying a program and extending it to be a web service. Currently you can see what the GUI will look like here: http://phage.sdsu.edu/poole/ibd.html

The program (IBD) has already been written to read in a file, but with CGI (I''m using post in my form) it sends the file over at a spot in memory. So I need to copy that spot in memory over to a buffer (speaking of which, what is the best way to tell how large the file is from the cgi script?) and then parse it.

Unfortuneatly the parsing code has all been written using file input and output. I could move the code over to being memory based functions but I figure this would just cause bugs and what-not.

So basically, I was looking for an easy work around so that I wouldn''t have to change all of the parsing code. Thanks for your post.
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/

This topic is closed to new replies.

Advertisement