~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_symlink2.cc

Added code necessary for building plugins dynamically.
Merged in changes from lifeless to allow autoreconf to work.
Touching plugin.ini files now triggers a rebuid - so config/autorun.sh is no
longer required to be run after touching those.
Removed the duplicate plugin names - also removed the issue that getting them
different would silently fail weirdly later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
  rename files and symlinks like they would be one unit.
21
21
*/
22
22
 
23
 
#include "config.h"
24
 
 
25
 
#include "drizzled/internal/my_sys.h"
26
 
#include "drizzled/error.h"
27
 
#include "drizzled/internal/m_string.h"
28
 
 
29
 
namespace drizzled
30
 
{
31
 
namespace internal
32
 
{
33
 
 
34
 
int my_create_with_symlink(const char *linkname, const char *filename,
35
 
                           int createflags, int access_flags, myf MyFlags)
36
 
{
37
 
  int file;
 
23
#include "mysys/mysys_priv.h"
 
24
#include "mysys/mysys_err.h"
 
25
#include <mystrings/m_string.h>
 
26
 
 
27
File my_create_with_symlink(const char *linkname, const char *filename,
 
28
                            int createflags, int access_flags, myf MyFlags)
 
29
{
 
30
  File file;
38
31
  int tmp_errno;
39
32
  /* Test if we should create a link */
40
33
  int create_link;
64
57
  {
65
58
    if (!access(filename,F_OK))
66
59
    {
67
 
      errno= errno= EEXIST;
 
60
      my_errno= errno= EEXIST;
68
61
      my_error(EE_CANTCREATEFILE, MYF(0), filename, EEXIST);
69
62
      return(-1);
70
63
    }
71
64
    if (create_link && !access(linkname,F_OK))
72
65
    {
73
 
      errno= errno= EEXIST;
 
66
      my_errno= errno= EEXIST;
74
67
      my_error(EE_CANTCREATEFILE, MYF(0), linkname, EEXIST);
75
68
      return(-1);
76
69
    }
87
80
      if (symlink(filename,linkname))
88
81
      {
89
82
        /* Fail, remove everything we have done */
90
 
        tmp_errno=errno;
 
83
        tmp_errno=my_errno;
91
84
        my_close(file,MYF(0));
92
85
        my_delete(filename, MYF(0));
93
86
        file= -1;
94
 
        errno=tmp_errno;
 
87
        my_errno=tmp_errno;
95
88
      }
96
89
      else if (MyFlags & MY_SYNC_DIR)
97
90
        my_sync_dir_by_file(linkname, MyFlags);
135
128
 
136
129
int my_rename_with_symlink(const char *from, const char *to, myf MyFlags)
137
130
{
 
131
#ifndef HAVE_READLINK
 
132
  return my_rename(from, to, MyFlags);
 
133
#else
138
134
  char link_name[FN_REFLEN], tmp_name[FN_REFLEN];
139
135
  int sym_link_size= -1;
140
136
  int was_symlink= (!my_disable_symlinks &&
154
150
  name_is_different= strcmp(link_name, tmp_name);
155
151
  if (name_is_different && !access(tmp_name, F_OK))
156
152
  {
157
 
    errno= EEXIST;
 
153
    my_errno= EEXIST;
158
154
    if (MyFlags & MY_WME)
159
155
      my_error(EE_CANTCREATEFILE, MYF(0), tmp_name, EEXIST);
160
156
    return(1);
174
170
 
175
171
  if (name_is_different && my_rename(link_name, tmp_name, MyFlags))
176
172
  {
177
 
    int save_errno=errno;
 
173
    int save_errno=my_errno;
178
174
    my_delete(to, MyFlags);                     /* Remove created symlink */
179
 
    errno=save_errno;
 
175
    my_errno=save_errno;
180
176
    return(1);
181
177
  }
182
178
 
183
179
  /* Remove original symlink */
184
180
  if (my_delete(from, MyFlags))
185
181
  {
186
 
    int save_errno=errno;
 
182
    int save_errno=my_errno;
187
183
    /* Remove created link */
188
184
    my_delete(to, MyFlags);
189
185
    /* Rename file back */
190
186
    if (strcmp(link_name, tmp_name))
191
187
      (void) my_rename(tmp_name, link_name, MyFlags);
192
 
    errno=save_errno;
 
188
    my_errno=save_errno;
193
189
    result= 1;
194
190
  }
195
191
  return(result);
 
192
#endif /* HAVE_READLINK */
196
193
}
197
 
 
198
 
} /* namespace internal */
199
 
} /* namespace drizzled */