Back to index

plt-scheme  4.2.1
Functions File Reference
#include "wx.h"
#include <unistd.h>
#include <string.h>

Go to the source code of this file.


char * wxGetTempFileName (char *prefix, char *dest)

Function Documentation

char* wxGetTempFileName ( char *  prefix,
char *  dest 

Definition at line 32 of file

    static short last_temp = 0;    // cache last to speed things a bit
    // At most 1000 temp files to a process! We use a ring count.
    char buf[64];
    short suffix;

    for (suffix = last_temp + 1; suffix != last_temp; ++suffix %= 1000) {
      int pid;
      pid = (int)getpid();
      sprintf (buf, "/tmp/%s%d.%03x", prefix, pid, (int)suffix);
      if (!wxFileExists(buf)) {
       // Touch the file to create it (reserve name)
       FILE *fd;
       fd = fopen (buf, "w");
       if (fd)
         fclose (fd);
       last_temp = suffix;
       if (dest)
         strcpy(dest, buf);
       else {
         dest = copystring(buf);
       return dest;
    wxError("wxWindows: error finding temporary file name.");
    if (dest) dest[0] = 0;

    return NULL;

Here is the call graph for this function: