How-to use tmpfile fonction.

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
Polo35
Posts: 25
Joined: Sun Apr 09, 2006 7:22 am

How-to use tmpfile fonction.

Post 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
User avatar
evilo
Posts: 230
Joined: Thu Apr 22, 2004 8:40 pm
Contact:

Post 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 :)
Polo35
Posts: 25
Joined: Sun Apr 09, 2006 7:22 am

Post 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
Polo35
Posts: 25
Joined: Sun Apr 09, 2006 7:22 am

Post 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
Post Reply