~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_symlink.c

  • Committer: Brian Aker
  • Date: 2008-07-13 21:20:24 UTC
  • Revision ID: brian@tangent.org-20080713212024-o6263c1vha7yxdeu
More bool removal. More cow bell!

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
#include "mysys_priv.h"
17
17
#include "mysys_err.h"
18
 
#include <mystrings/m_string.h>
 
18
#include <m_string.h>
19
19
#include <errno.h>
20
20
#ifdef HAVE_REALPATH
21
21
#include <sys/param.h>
35
35
int my_readlink(char *to, const char *filename, myf MyFlags)
36
36
{
37
37
#ifndef HAVE_READLINK
38
 
  my_stpcpy(to,filename);
 
38
  strmov(to,filename);
39
39
  return 1;
40
40
#else
41
41
  int result=0;
42
42
  int length;
 
43
  DBUG_ENTER("my_readlink");
43
44
 
44
45
  if ((length=readlink(filename, to, FN_REFLEN-1)) < 0)
45
46
  {
47
48
    if ((my_errno=errno) == EINVAL)
48
49
    {
49
50
      result= 1;
50
 
      my_stpcpy(to,filename);
 
51
      strmov(to,filename);
51
52
    }
52
53
    else
53
54
    {
58
59
  }
59
60
  else
60
61
    to[length]=0;
61
 
  return(result);
 
62
  DBUG_PRINT("exit" ,("result: %d", result));
 
63
  DBUG_RETURN(result);
62
64
#endif /* HAVE_READLINK */
63
65
}
64
66
 
71
73
  return 0;
72
74
#else
73
75
  int result;
 
76
  DBUG_ENTER("my_symlink");
 
77
  DBUG_PRINT("enter",("content: %s  linkname: %s", content, linkname));
74
78
 
75
79
  result= 0;
76
80
  if (symlink(content, linkname))
82
86
  }
83
87
  else if ((MyFlags & MY_SYNC_DIR) && my_sync_dir_by_file(linkname, MyFlags))
84
88
    result= -1;
85
 
  return(result);
 
89
  DBUG_RETURN(result);
86
90
#endif /* HAVE_READLINK */
87
91
}
88
92
 
111
115
  int result=0;
112
116
  char buff[BUFF_LEN];
113
117
  struct stat stat_buff;
 
118
  DBUG_ENTER("my_realpath");
114
119
 
115
120
  if (!(MyFlags & MY_RESOLVE_LINK) ||
116
121
      (!lstat(filename,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
117
122
  {
118
123
    char *ptr;
 
124
    DBUG_PRINT("info",("executing realpath"));
119
125
    if ((ptr=realpath(filename,buff)))
120
126
    {
121
127
      strmake(to,ptr,FN_REFLEN-1);
127
133
        original name but will at least be able to resolve paths that starts
128
134
        with '.'.
129
135
      */
 
136
      DBUG_PRINT("error",("realpath failed with errno: %d", errno));
130
137
      my_errno=errno;
131
138
      if (MyFlags & MY_WME)
132
139
        my_error(EE_REALPATH, MYF(0), filename, my_errno);
133
 
      my_load_path(to, filename, NULL);
 
140
      my_load_path(to, filename, NullS);
134
141
      result= -1;
135
142
    }
136
143
  }
137
 
  return(result);
 
144
  DBUG_RETURN(result);
138
145
#else
139
 
  my_load_path(to, filename, NULL);
 
146
  my_load_path(to, filename, NullS);
140
147
  return 0;
141
148
#endif
142
149
}