~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_rename.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "config.h"
17
 
 
18
 
#include "drizzled/internal/my_sys.h"
19
 
#include "drizzled/error.h"
20
 
#include "drizzled/internal/m_string.h"
21
 
 
22
 
namespace drizzled
23
 
{
24
 
namespace internal
25
 
{
 
16
#include "mysys/mysys_priv.h"
 
17
#include "mysys/mysys_err.h"
 
18
#include <mystrings/m_string.h>
 
19
#undef my_rename
26
20
 
27
21
        /* On unix rename deletes to file if it exists */
28
22
 
34
28
  {                             /* Check that there isn't a old file */
35
29
    int save_errno;
36
30
    MY_STAT my_stat_result;
37
 
    save_errno=errno;
 
31
    save_errno=my_errno;
38
32
    if (my_stat(to,&my_stat_result,MYF(0)))
39
33
    {
40
 
      errno=EEXIST;
 
34
      my_errno=EEXIST;
41
35
      error= -1;
42
36
      if (MyFlags & MY_FAE+MY_WME)
43
 
        my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,errno);
 
37
        my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,my_errno);
44
38
      return(error);
45
39
    }
46
 
    errno=save_errno;
 
40
    my_errno=save_errno;
47
41
  }
48
42
#endif
 
43
#if defined(HAVE_RENAME)
49
44
  if (rename(from,to))
 
45
#else
 
46
  if (link(from, to) || unlink(from))
 
47
#endif
50
48
  {
51
 
    errno=errno;
 
49
    my_errno=errno;
52
50
    error = -1;
53
51
    if (MyFlags & (MY_FAE+MY_WME))
54
 
      my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,errno);
 
52
      my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,my_errno);
55
53
  }
56
54
  else if (MyFlags & MY_SYNC_DIR)
57
55
  {
69
67
  }
70
68
  return(error);
71
69
} /* my_rename */
72
 
 
73
 
} /* namespace internal */
74
 
} /* namespace drizzled */