~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_tempfile.c

  • Committer: Monty Taylor
  • Date: 2008-10-13 09:29:43 UTC
  • mfrom: (509 drizzle)
  • mto: (509.1.4 codestyle)
  • mto: This revision was merged to the branch mainline in revision 511.
  • Revision ID: monty@inaugust.com-20081013092943-rwvx4a6d85b5l2dh
MergedĀ inĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    implementation, it's main use is to generate a file with
46
46
    a name that does not already exist.
47
47
 
 
48
    When passing O_TEMPORARY flag in "mode" the file should
 
49
    be automatically deleted
 
50
 
48
51
    The implementation using mkstemp should be considered the
49
52
    reference implementation when adding a new or modifying an
50
53
    existing one
64
67
  {
65
68
    strmake(to,res,FN_REFLEN-1);
66
69
    (*free)(res);
67
 
    file=my_create(to, 0, mode | O_EXCL, MyFlags);
 
70
    file=my_create(to, 0, mode | O_EXCL | O_NOFOLLOW, MyFlags);
68
71
  }
69
72
#elif defined(HAVE_MKSTEMP)
70
73
  {
85
88
    }
86
89
    my_stpcpy(convert_dirname(to,dir,NULL),prefix_buff);
87
90
    org_file=mkstemp(to);
88
 
    /* TODO: This was old behavior, but really don't we want to 
89
 
     * unlink files immediately under all circumstances?
90
 
     * if (mode & O_TEMPORARY)
 
91
    if (mode & O_TEMPORARY)
91
92
      (void) my_delete(to, MYF(MY_WME | ME_NOINPUT));
92
 
     */
93
93
    file=my_register_filename(org_file, to, FILE_BY_MKSTEMP,
94
94
                              EE_CANTCREATEFILE, MyFlags);
95
95
    /* If we didn't manage to register the name, remove the temp file */
121
121
      strmake(to,res,FN_REFLEN-1);
122
122
      (*free)(res);
123
123
      file=my_create(to,0,
124
 
                     (int) (O_RDWR | O_TRUNC | O_EXCL),
 
124
                     (int) (O_RDWR | O_TRUNC | O_EXCL | O_NOFOLLOW |
 
125
                            O_TEMPORARY | O_SHORT_LIVED),
125
126
                     MYF(MY_WME));
126
127
 
127
128
    }