12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include "mysys_priv.h"
17
#include "mysys_err.h"
18
#include <mystrings/m_string.h>
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
18
#include "drizzled/internal/my_sys.h"
19
#include "drizzled/error.h"
20
#include "drizzled/internal/m_string.h"
21
#include <sys/param.h>
26
Reads the content of a symbolic link
27
If the file is not a symbolic link, return the original file name in to.
30
0 If filename was a symlink, (to will be set to value of symlink)
31
1 If filename was a normal file (to will be set to filename)
35
int my_readlink(char *to, const char *filename, myf MyFlags)
44
if ((length=readlink(filename, to, FN_REFLEN-1)) < 0)
46
/* Don't give an error if this wasn't a symlink */
47
if ((my_errno=errno) == EINVAL)
55
my_error(EE_CANT_READLINK, MYF(0), filename, errno);
62
#endif /* HAVE_READLINK */
66
/* Create a symbolic link */
68
int my_symlink(const char *content, const char *linkname, myf MyFlags)
76
if (symlink(content, linkname))
81
my_error(EE_CANT_SYMLINK, MYF(0), linkname, content, errno);
83
else if ((MyFlags & MY_SYNC_DIR) && my_sync_dir_by_file(linkname, MyFlags))
86
#endif /* HAVE_READLINK */
90
Resolve all symbolic links in path
91
'to' may be equal to 'filename'
93
Because purify gives a lot of UMR errors when using realpath(),
94
this code is disabled when using purify.
96
If MY_RESOLVE_LINK is given, only do realpath if the file is a link.
100
#define BUFF_LEN 4097
101
#elif defined(MAXPATHLEN)
102
#define BUFF_LEN MAXPATHLEN
104
#define BUFF_LEN FN_LEN
107
int my_realpath(char *to, const char *filename,
108
myf MyFlags __attribute__((unused)))
110
#if defined(HAVE_REALPATH) && !defined(HAVE_purify) && !defined(HAVE_BROKEN_REALPATH)
113
struct stat stat_buff;
115
if (!(MyFlags & MY_RESOLVE_LINK) ||
116
(!lstat(filename,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
119
if ((ptr=realpath(filename,buff)))
121
strmake(to,ptr,FN_REFLEN-1);
126
Realpath didn't work; Use my_load_path() which is a poor substitute
127
original name but will at least be able to resolve paths that starts
131
if (MyFlags & MY_WME)
132
my_error(EE_REALPATH, MYF(0), filename, my_errno);
133
my_load_path(to, filename, NullS);
139
my_load_path(to, filename, NullS);
28
bool test_if_hard_path(const char *dir_name)
30
if (dir_name[0] == FN_HOMELIB && dir_name[1] == FN_LIBCHAR)
31
return (home_dir != NULL && test_if_hard_path(home_dir));
32
if (dir_name[0] == FN_LIBCHAR)
35
} /* test_if_hard_path */
37
} /* namespace internal */
38
} /* namespace drizzled */