~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_getwd.c

Removed DBUG symbols and fixed TRUE/FALSE

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
/* my_setwd() and my_getwd() works with intern_filenames !! */
17
17
 
18
18
#include "mysys_priv.h"
19
 
#include <mystrings/m_string.h>
 
19
#include <m_string.h>
20
20
#include "mysys_err.h"
21
21
#include "my_static.h"
22
22
#ifdef HAVE_GETWD
23
23
#include <sys/param.h>
24
24
#endif
25
 
#include <drizzled/util/test.h>
26
25
 
27
26
/* Gets current working directory in buff.
28
27
 
43
42
int my_getwd(char * buf, size_t size, myf MyFlags)
44
43
{
45
44
  char * pos;
 
45
  DBUG_ENTER("my_getwd");
 
46
  DBUG_PRINT("my",("buf: 0x%lx  size: %u  MyFlags %d",
 
47
                   (long) buf, (uint) size, MyFlags));
46
48
 
47
49
  if (curr_dir[0])                              /* Current pos is saved here */
48
 
    strmake(buf,&curr_dir[0],size-1);
 
50
    VOID(strmake(buf,&curr_dir[0],size-1));
49
51
  else
50
52
  {
51
53
#if defined(HAVE_GETCWD)
72
74
#else
73
75
#error "No way to get current directory"
74
76
#endif
75
 
    if (*((pos= strchr(buf, '\0'))-1) != FN_LIBCHAR)  /* End with FN_LIBCHAR */
 
77
    if (*((pos=strend(buf))-1) != FN_LIBCHAR)  /* End with FN_LIBCHAR */
76
78
    {
77
79
      pos[0]= FN_LIBCHAR;
78
80
      pos[1]=0;
79
81
    }
80
82
    (void) strmake(&curr_dir[0],buf, (size_t) (FN_REFLEN-1));
81
83
  }
82
 
  return(0);
 
84
  DBUG_RETURN(0);
83
85
} /* my_getwd */
84
86
 
85
87
 
89
91
{
90
92
  int res;
91
93
  size_t length;
92
 
  const char *start;
93
 
  char *pos;
 
94
  char *start, *pos;
94
95
#if defined(VMS)
95
96
  char buff[FN_REFLEN];
96
97
#endif
 
98
  DBUG_ENTER("my_setwd");
 
99
  DBUG_PRINT("my",("dir: '%s'  MyFlags %d", dir, MyFlags));
97
100
 
98
 
  start= dir;
 
101
  start=(char *) dir;
99
102
  if (! dir[0] || (dir[0] == FN_LIBCHAR && dir[1] == 0))
100
103
    dir=FN_ROOTDIR;
101
104
#ifdef VMS
102
105
  {
103
 
    pos=my_stpcpy(buff,dir);
 
106
    pos=strmov(buff,dir);
104
107
    if (pos[-1] != FN_LIBCHAR)
105
108
    {
106
109
      pos[0]=FN_LIBCHAR;                /* Mark as directory */
110
113
    dir=buff;
111
114
  }
112
115
#endif /* VMS */
113
 
  if ((res=chdir(dir)) != 0)
 
116
  if ((res=chdir((char*) dir)) != 0)
114
117
  {
115
118
    my_errno=errno;
116
119
    if (MyFlags & MY_WME)
131
134
    else
132
135
      curr_dir[0]='\0';                         /* Don't save name */
133
136
  }
134
 
  return(res);
 
137
  DBUG_RETURN(res);
135
138
} /* my_setwd */
136
139
 
137
140
 
142
145
int test_if_hard_path(register const char *dir_name)
143
146
{
144
147
  if (dir_name[0] == FN_HOMELIB && dir_name[1] == FN_LIBCHAR)
145
 
    return (home_dir != NULL && test_if_hard_path(home_dir));
 
148
    return (home_dir != NullS && test_if_hard_path(home_dir));
146
149
  if (dir_name[0] == FN_LIBCHAR)
147
 
    return (true);
 
150
    return (TRUE);
148
151
#ifdef FN_DEVCHAR
149
152
  return (strchr(dir_name,FN_DEVCHAR) != 0);
150
153
#else
151
 
  return false;
 
154
  return FALSE;
152
155
#endif
153
156
} /* test_if_hard_path */
154
157
 
161
164
    name                The name to test.
162
165
 
163
166
  RETURN
164
 
    true        name contains a path.
165
 
    false       name does not contain a path.
 
167
    TRUE        name contains a path.
 
168
    FALSE       name does not contain a path.
166
169
*/
167
170
 
168
 
bool has_path(const char *name)
 
171
my_bool has_path(const char *name)
169
172
{
170
173
  return test(strchr(name, FN_LIBCHAR)) 
171
174
#if FN_LIBCHAR != '/'