~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_tempfile.c

Removed/replaced DBUG symbols and standardized TRUE/FALSE

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
#include "mysys_priv.h"
17
 
#include <mystrings/m_string.h>
 
17
#include <m_string.h>
18
18
#include "my_static.h"
19
19
#include "mysys_err.h"
20
20
#include <errno.h>
60
60
{
61
61
  File file= -1;
62
62
 
 
63
  DBUG_ENTER("create_temp_file");
 
64
  DBUG_PRINT("enter", ("dir: %s, prefix: %s", dir, prefix));
63
65
#if defined(_ZTC__)
64
66
  if (!dir)
65
67
    dir=getenv("TMPDIR");
72
74
#elif defined(HAVE_MKSTEMP)
73
75
  {
74
76
    char prefix_buff[30];
75
 
    uint32_t pfx_len;
 
77
    uint pfx_len;
76
78
    File org_file;
77
79
 
78
 
    pfx_len= (uint) (my_stpcpy(my_stpncpy(prefix_buff,
 
80
    pfx_len= (uint) (strmov(strnmov(prefix_buff,
79
81
                                    prefix ? prefix : "tmp.",
80
82
                                    sizeof(prefix_buff)-7),"XXXXXX") -
81
83
                     prefix_buff);
84
86
    if (strlen(dir)+ pfx_len > FN_REFLEN-2)
85
87
    {
86
88
      errno=my_errno= ENAMETOOLONG;
87
 
      return(file);
 
89
      DBUG_RETURN(file);
88
90
    }
89
 
    my_stpcpy(convert_dirname(to,dir,NULL),prefix_buff);
 
91
    strmov(convert_dirname(to,dir,NullS),prefix_buff);
90
92
    org_file=mkstemp(to);
91
93
    if (mode & O_TEMPORARY)
92
94
      (void) my_delete(to, MYF(MY_WME | ME_NOINPUT));
126
128
                     MYF(MY_WME));
127
129
 
128
130
    }
 
131
    else
 
132
    {
 
133
      DBUG_PRINT("error",("Got error: %d from tempnam",errno));
 
134
    }
129
135
    environ=(const char**) old_env;
130
136
  }
131
137
#else
133
139
#endif
134
140
  if (file >= 0)
135
141
    thread_safe_increment(my_tmp_file_created,&THR_LOCK_open);
136
 
  return(file);
 
142
  DBUG_RETURN(file);
137
143
}