~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_tempfile.cc

  • Committer: Brian Aker
  • Date: 2008-12-11 08:52:18 UTC
  • mfrom: (670.1.11 devel)
  • Revision ID: brian@tangent.org-20081211085218-cpmznmzrflyd82j2
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "mysys_err.h"
20
20
#include <stdio.h>
21
21
#include <errno.h>
 
22
#include <string>
22
23
#ifdef HAVE_PATHS_H
23
24
#include <paths.h>
24
25
#endif
25
26
 
26
 
 
 
27
using namespace std;
27
28
 
28
29
/*
29
30
  @brief
69
70
  }
70
71
#elif defined(HAVE_MKSTEMP)
71
72
  {
72
 
    char prefix_buff[30];
73
 
    uint32_t pfx_len;
74
73
    File org_file;
75
 
 
76
 
    pfx_len= (uint32_t)(strcpy(my_stpncpy(prefix_buff,prefix ? prefix : "tmp.",
77
 
                                          sizeof(prefix_buff)-7),"XXXXXX")+6
78
 
                               -prefix_buff);
 
74
    string prefix_str;
 
75
 
 
76
    prefix_str= prefix ? prefix : "tmp.";
 
77
    prefix_str.append("XXXXXX");
 
78
 
79
79
    if (!dir && ! (dir =getenv("TMPDIR")))
80
80
      dir= P_tmpdir;
81
 
    if (strlen(dir)+ pfx_len > FN_REFLEN-2)
 
81
    if (strlen(dir)+prefix_str.length() > FN_REFLEN-2)
82
82
    {
83
83
      errno=my_errno= ENAMETOOLONG;
84
84
      return(file);
85
85
    }
86
 
    strcpy(convert_dirname(to,dir,NULL),prefix_buff);
 
86
    strcpy(convert_dirname(to,dir,NULL),prefix_str.c_str());
87
87
    org_file=mkstemp(to);
88
88
    /* TODO: This was old behavior, but really don't we want to
89
89
     * unlink files immediately under all circumstances?