~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_format.cc

  • Committer: Mark Atwood
  • Date: 2009-03-04 01:02:00 UTC
  • mto: (968.2.20 mordred)
  • mto: This revision was merged to the branch mainline in revision 971.
  • Revision ID: me@mark.atwood.name-20090304010200-t1n4xxdoil2yae9a
add gearman logging plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
#include <config.h>
17
 
 
18
 
#include <drizzled/internal/my_sys.h>
19
 
 
20
 
#include <fcntl.h>
21
 
 
22
 
#ifdef HAVE_SYS_STAT_H
23
 
# include <sys/stat.h>
24
 
#endif
25
 
 
26
 
#include <algorithm>
27
 
 
28
 
#include <drizzled/internal/m_string.h>
29
 
 
30
 
using namespace std;
31
 
 
32
 
namespace drizzled
33
 
{
34
 
namespace internal
35
 
{
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include "mysys_priv.h"
 
17
#include <mystrings/m_string.h>
36
18
 
37
19
/*
38
20
  Formats a filename with possible replace of directory of extension
94
76
    size_t tmp_length;
95
77
    if (flag & MY_SAFE_PATH)
96
78
      return NULL;
97
 
    tmp_length= min(strlength(startpos), (size_t)(FN_REFLEN-1));
 
79
    tmp_length= cmin(strlength(startpos), FN_REFLEN-1);
98
80
    strncpy(to,startpos,tmp_length);
99
81
    to[tmp_length]= '\0';
100
82
  }
114
96
    realpath if the file is a symbolic link
115
97
  */
116
98
  if (flag & MY_RETURN_REAL_PATH)
117
 
  {
118
 
    struct stat stat_buff;
119
 
    char rp_buff[PATH_MAX];
120
 
    if ((!flag & MY_RESOLVE_SYMLINKS) || 
121
 
       (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
122
 
    {
123
 
      if (!realpath(to,rp_buff))
124
 
        my_load_path(rp_buff, to, NULL);
125
 
      rp_buff[FN_REFLEN-1]= '\0';
126
 
      strcpy(to,rp_buff);
127
 
    }
128
 
  }
 
99
    (void) my_realpath(to, to, MYF(flag & MY_RESOLVE_SYMLINKS ?
 
100
                                   MY_RESOLVE_LINK: 0));
129
101
  else if (flag & MY_RESOLVE_SYMLINKS)
130
102
  {
131
103
    strcpy(buff,to);
132
 
    ssize_t sym_link_size= readlink(buff,to,FN_REFLEN-1);
133
 
    if (sym_link_size >= 0)
134
 
      to[sym_link_size]= '\0';
 
104
    (void) my_readlink(to, buff, MYF(0));
135
105
  }
136
106
  return(to);
137
107
} /* fn_format */
165
135
  }
166
136
  return((size_t) (found - str));
167
137
} /* strlength */
168
 
 
169
 
} /* namespace internal */
170
 
} /* namespace drizzled */