~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_format.cc

  • Committer: Brian Aker
  • Date: 2008-12-16 20:47:48 UTC
  • Revision ID: brian@tangent.org-20081216204748-7uqj2xgo1mkxolzr
Enabling loaddata_autocom_innodb

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "mysys/mysys_priv.h"
 
16
#include "mysys_priv.h"
17
17
#include <mystrings/m_string.h>
18
18
 
19
 
#include <algorithm>
20
 
 
21
 
using namespace std;
22
 
 
23
19
/*
24
20
  Formats a filename with possible replace of directory of extension
25
21
  Function can handle the case where 'to' == 'name'
51
47
    strncpy(pos,buff,sizeof(buff)-1- (int) (pos-dev));
52
48
  }
53
49
 
 
50
  if (flag & MY_PACK_FILENAME)
 
51
    pack_dirname(dev,dev);                      /* Put in ./.. and ~/.. */
54
52
  if (flag & MY_UNPACK_FILENAME)
55
53
    (void) unpack_dirname(dev,dev);             /* Replace ~/.. with dir */
56
54
 
80
78
    size_t tmp_length;
81
79
    if (flag & MY_SAFE_PATH)
82
80
      return NULL;
83
 
    tmp_length= min(strlength(startpos), (size_t)(FN_REFLEN-1));
 
81
    tmp_length= cmin(strlength(startpos), FN_REFLEN-1);
84
82
    strncpy(to,startpos,tmp_length);
85
83
    to[tmp_length]= '\0';
86
84
  }
100
98
    realpath if the file is a symbolic link
101
99
  */
102
100
  if (flag & MY_RETURN_REAL_PATH)
103
 
  {
104
 
    struct stat stat_buff;
105
 
    char rp_buff[PATH_MAX];
106
 
    if ((!flag & MY_RESOLVE_SYMLINKS) || 
107
 
       (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
108
 
    {
109
 
      if (!realpath(to,rp_buff))
110
 
        my_load_path(rp_buff, to, NULL);
111
 
      rp_buff[FN_REFLEN-1]= '\0';
112
 
      strcpy(to,rp_buff);
113
 
    }
114
 
  }
 
101
    (void) my_realpath(to, to, MYF(flag & MY_RESOLVE_SYMLINKS ?
 
102
                                   MY_RESOLVE_LINK: 0));
115
103
  else if (flag & MY_RESOLVE_SYMLINKS)
116
104
  {
117
105
    strcpy(buff,to);
118
 
    ssize_t sym_link_size= readlink(buff,to,FN_REFLEN-1);
119
 
    if (sym_link_size >= 0)
120
 
      to[sym_link_size]= '\0';
 
106
    (void) my_readlink(to, buff, MYF(0));
121
107
  }
122
108
  return(to);
123
109
} /* fn_format */