Page 1 of 1
How-to use tmpfile fonction.
Posted: Sat Jul 08, 2006 1:52 am
by Polo35
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
Posted: Sat Jul 08, 2006 2:04 am
by evilo
it's normal
Code: Select all
/*
**
** [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: Select all
/*
**
** [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 :)
Posted: Sat Jul 08, 2006 2:50 am
by Polo35
LOL, MDR. :D
No problem, i'm going to find stdio.c from an other source and to port it.
Best regards
Polo
Posted: Sat Jul 08, 2006 5:01 pm
by Polo35
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