~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_getwd.c

  • Committer: Monty Taylor
  • Date: 2008-07-02 14:35:48 UTC
  • mto: This revision was merged to the branch mainline in revision 51.
  • Revision ID: monty@inaugust.com-20080702143548-onj30ry0sugr01uw
Removed all references to THREAD.

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