~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_getwd.c

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