~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_rename.cc

  • Committer: Monty Taylor
  • Date: 2008-11-16 23:47:43 UTC
  • mto: (584.1.10 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116234743-c38gmv0pa2kdefaj
Broke out cached_item.

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_priv.h"
 
17
#include <my_dir.h>
 
18
#include "mysys_err.h"
 
19
#include <mystrings/m_string.h>
 
20
#undef my_rename
26
21
 
27
22
        /* On unix rename deletes to file if it exists */
28
23
 
34
29
  {                             /* Check that there isn't a old file */
35
30
    int save_errno;
36
31
    MY_STAT my_stat_result;
37
 
    save_errno=errno;
 
32
    save_errno=my_errno;
38
33
    if (my_stat(to,&my_stat_result,MYF(0)))
39
34
    {
40
 
      errno=EEXIST;
 
35
      my_errno=EEXIST;
41
36
      error= -1;
42
37
      if (MyFlags & MY_FAE+MY_WME)
43
 
        my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,errno);
 
38
        my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,my_errno);
44
39
      return(error);
45
40
    }
46
 
    errno=save_errno;
 
41
    my_errno=save_errno;
47
42
  }
48
43
#endif
 
44
#if defined(HAVE_RENAME)
49
45
  if (rename(from,to))
 
46
#else
 
47
  if (link(from, to) || unlink(from))
 
48
#endif
50
49
  {
51
 
    errno=errno;
 
50
    my_errno=errno;
52
51
    error = -1;
53
52
    if (MyFlags & (MY_FAE+MY_WME))
54
 
      my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,errno);
 
53
      my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,my_errno);
55
54
  }
56
55
  else if (MyFlags & MY_SYNC_DIR)
57
56
  {
69
68
  }
70
69
  return(error);
71
70
} /* my_rename */
72
 
 
73
 
} /* namespace internal */
74
 
} /* namespace drizzled */