| View previous topic :: View next topic |
| Author |
Message |
Polo35
Joined: 09 Apr 2006 Posts: 25
|
Posted: Sat Jul 08, 2006 1:52 am Post subject: How-to use tmpfile fonction. |
|
|
Hello.
I'd like to use the fonction FILE *tmpfile() from stdio, to use a file without having to write one on mc or hdd.
This fonction normaly create a temporary file, which can be use like a normal file open with fopen().
But this fonction always return NULL pointer, in my prog. :(
So, who can explain me how to use this fonction.
With a little example if possible. ;)
Thanks
Best regards
Polo |
|
| Back to top |
|
 |
evilo

Joined: 22 Apr 2004 Posts: 230
|
Posted: Sat Jul 08, 2006 2:04 am Post subject: |
|
|
it's normal
| Code: |
/*
**
** [func] - tmpfile.
** [desc] - attempts to create a temporary file. if able to create a temporary
** file then returns the pointer to the FILE stream. else returns NULL.
** [entr] - none.
** [exit] - FILE *; the ptr. to the opened temp. file if successful. else NULL.
** [prec] - none.
** [post] - a temporary is opened.
**
*/
FILE *tmpfile(void)
{
return ((tmpnam(NULL) != NULL) ? fopen(__stdio_tmpnam, "rw+") : NULL);
}
|
| Code: |
/*
**
** [func] - tmpnam.
** [desc] - creates a temporary filename string,
** [entr] - char *name; the pointer to the destination string pointer.
** [exit] - char *;
** [prec] -
** [post] -
**
*/
char *tmpnam(char *name)
{
char *ret = NULL;
return (ret);
}
|
the used function is not fully implemented and always return NULL.
so you know now what to do : contribute to the SDK developement :) |
|
| Back to top |
|
 |
Polo35
Joined: 09 Apr 2006 Posts: 25
|
Posted: Sat Jul 08, 2006 2:50 am Post subject: |
|
|
LOL, MDR. :D
No problem, i'm going to find stdio.c from an other source and to port it.
Best regards
Polo |
|
| Back to top |
|
 |
Polo35
Joined: 09 Apr 2006 Posts: 25
|
Posted: Sat Jul 08, 2006 5:01 pm Post subject: |
|
|
Hey.
I found tmpfile stuff in gnu libc source, and the problem is: tmpfile search a dir call tmp in file system, and really create a file.
That's not what i want to do, i want to make a tmp file open only in ram.
Or simulate an opened file.
Does somebody know how to do that?
Best regards
Polo |
|
| Back to top |
|
 |
|