26
26
#include <drizzled/error.h>
27
27
#include <drizzled/internal/m_string.h>
34
32
int my_create_with_symlink(const char *linkname, const char *filename,
35
33
int createflags, int access_flags, myf MyFlags)
39
35
/* Test if we should create a link */
41
char abs_linkname[FN_REFLEN];
36
bool create_link= false;
42
37
char rp_buff[PATH_MAX];
44
39
if (my_disable_symlinks)
46
41
/* Create only the file, not the link and file */
49
43
filename= linkname;
55
if (!realpath(linkname,rp_buff))
56
my_load_path(rp_buff, linkname, NULL);
57
rp_buff[FN_REFLEN-1]= '\0';
58
strcpy(abs_linkname,rp_buff);
60
create_link= (linkname && strcmp(abs_linkname,filename));
47
if (!realpath(linkname,rp_buff))
48
my_load_path(rp_buff, linkname, NULL);
49
rp_buff[FN_REFLEN-1]= '\0';
50
char abs_linkname[FN_REFLEN];
51
strcpy(abs_linkname, rp_buff);
52
create_link= strcmp(abs_linkname, filename);
63
55
if (!(MyFlags & MY_DELETE_OLD))
79
if ((file=my_create(filename, createflags, access_flags, MyFlags)) >= 0)
71
int file= my_create(filename, createflags, access_flags, MyFlags);
72
if (file >= 0 && create_link)
74
/* Delete old link/file */
75
if (MyFlags & MY_DELETE_OLD)
76
my_delete(linkname, MYF(0));
78
if (symlink(filename,linkname))
83
/* Delete old link/file */
84
if (MyFlags & MY_DELETE_OLD)
85
my_delete(linkname, MYF(0));
87
if (symlink(filename,linkname))
89
/* Fail, remove everything we have done */
91
my_close(file,MYF(0));
92
my_delete(filename, MYF(0));
96
else if (MyFlags & MY_SYNC_DIR)
97
my_sync_dir_by_file(linkname, MyFlags);
80
/* Fail, remove everything we have done */
82
my_close(file, MYF(0));
83
my_delete(filename, MYF(0));
87
else if (MyFlags & MY_SYNC_DIR)
88
my_sync_dir_by_file(linkname, MyFlags);