~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_format.cc

  • Committer: Lee
  • Date: 2009-01-01 03:07:33 UTC
  • mto: (758.1.3 devel)
  • mto: This revision was merged to the branch mainline in revision 759.
  • Revision ID: lbieber@lbieber-desktop-20090101030733-fb411b55f07vij8q
more header file cleanup

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
65
47
    strncpy(pos,buff,sizeof(buff)-1- (int) (pos-dev));
66
48
  }
67
49
 
 
50
  if (flag & MY_PACK_FILENAME)
 
51
    pack_dirname(dev,dev);                      /* Put in ./.. and ~/.. */
68
52
  if (flag & MY_UNPACK_FILENAME)
69
53
    (void) unpack_dirname(dev,dev);             /* Replace ~/.. with dir */
70
54
 
94
78
    size_t tmp_length;
95
79
    if (flag & MY_SAFE_PATH)
96
80
      return NULL;
97
 
    tmp_length= min(strlength(startpos), (size_t)(FN_REFLEN-1));
 
81
    tmp_length= cmin(strlength(startpos), FN_REFLEN-1);
98
82
    strncpy(to,startpos,tmp_length);
99
83
    to[tmp_length]= '\0';
100
84
  }
114
98
    realpath if the file is a symbolic link
115
99
  */
116
100
  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
 
  }
 
101
    (void) my_realpath(to, to, MYF(flag & MY_RESOLVE_SYMLINKS ?
 
102
                                   MY_RESOLVE_LINK: 0));
129
103
  else if (flag & MY_RESOLVE_SYMLINKS)
130
104
  {
131
105
    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';
 
106
    (void) my_readlink(to, buff, MYF(0));
135
107
  }
136
108
  return(to);
137
109
} /* fn_format */
165
137
  }
166
138
  return((size_t) (found - str));
167
139
} /* strlength */
168
 
 
169
 
} /* namespace internal */
170
 
} /* namespace drizzled */