|
From: Javier Loureiro on 1 Jul 2008 20:33 I use a small library (physfs) to read files inside a zip (or a directory if I am in debug). It is a simple and typical virtual filesystem. but there are some other libraries that request a FILE * as input. So, is there any way to wrap an array of memory as an standard FILE? -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: wasti.redl on 2 Jul 2008 02:58 On Jul 2, 1:33 pm, Javier Loureiro <derethors...(a)gmail.com> wrote: > I use a small library (physfs) to read files inside a zip (or a > directory if I am in debug). It is a simple and typical virtual > filesystem. > > but there are some other libraries that request a FILE * as input. So, > is there any way to wrap an array of memory as an standard FILE? There's no standard way, since FILE is opaque. There might be platform-specific intrusive ways of doing it, though. For example, I know that at least one CRT implementation used to implement the printf family by delegating to a single function taking a FILE*, so sprintf had to disguise its target buffer as such. Sebastian -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Edward Rosten on 2 Jul 2008 17:32 On Jul 2, 5:33 am, Javier Loureiro <derethors...(a)gmail.com> wrote: > I use a small library (physfs) to read files inside a zip (or a > directory if I am in debug). It is a simple and typical virtual > filesystem. > > but there are some other libraries that request a FILE * as input. So, > is there any way to wrap an array of memory as an standard FILE? The GNU C library implementation of FILE* allows you to use FILE* in much the same way as iostreams. Sadle, this is not standard, though. Of particular interest to you will be the fmemopen function. -Ed -- (You can't go wrong with psycho-rats.)(http://mi.eng.cam.ac.uk/~er258) /d{def}def/f{/Times s selectfont}d/s{11}d/r{roll}d f 2/m{moveto}d -1 r 230 350 m 0 1 179{ 1 index show 88 rotate 4 mul 0 rmoveto}for/s 12 d f pop 235 420 translate 0 0 moveto 1 2 scale show showpage -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Maxim Yegorushkin on 7 Jul 2008 00:01 On Jul 2, 12:33 pm, Javier Loureiro <derethors...(a)gmail.com> wrote: > I use a small library (physfs) to read files inside a zip (or a > directory if I am in debug). It is a simple and typical virtual > filesystem. > > but there are some other libraries that request a FILE * as input. So, > is there any way to wrap an array of memory as an standard FILE? Using memory mapped files it may be possible to pass a shared memory file descriptor (shm_open()) into fdopen() to get FILE*. Max -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
|
Pages: 1 Prev: num_put facet has no 'float' handling Next: strcpy_s vs strcpy |