~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_tempfile.cc

  • Committer: Toru Maesaka
  • Date: 2008-12-10 18:33:08 UTC
  • mto: (670.1.11 devel)
  • mto: This revision was merged to the branch mainline in revision 672.
  • Revision ID: dev@torum.net-20081210183308-mb6a5x0sbl1dhc5c
Replaced MySQL's my_stpncpy() with libc and c++ calls

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
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
    std::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?