17
17
#include "mysys/mysys_err.h"
18
18
#include <mystrings/m_string.h>
21
#include <sys/param.h>
26
Resolve all symbolic links in path
27
'to' may be equal to 'filename'
29
Because purify gives a lot of UMR errors when using realpath(),
30
this code is disabled when using purify.
32
If MY_RESOLVE_LINK is given, only do realpath if the file is a link.
37
#elif defined(MAXPATHLEN)
38
#define BUFF_LEN MAXPATHLEN
40
#define BUFF_LEN FN_LEN
43
int my_realpath(char *to, const char *filename, myf MyFlags)
45
#if defined(HAVE_REALPATH) && !defined(HAVE_BROKEN_REALPATH)
48
struct stat stat_buff;
50
if (!(MyFlags & MY_RESOLVE_LINK) ||
51
(!lstat(filename,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
54
if ((ptr=realpath(filename,buff)))
56
strncpy(to,ptr,FN_REFLEN-1);
61
Realpath didn't work; Use my_load_path() which is a poor substitute
62
original name but will at least be able to resolve paths that starts
67
my_error(EE_REALPATH, MYF(0), filename, my_errno);
68
my_load_path(to, filename, NULL);
74
my_load_path(to, filename, NULL);
79
21
bool test_if_hard_path(const char *dir_name)