~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_getwd.c

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

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 <m_string.h>
 
19
#include <mystrings/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>
25
26
 
26
27
/* Gets current working directory in buff.
27
28
 
42
43
int my_getwd(char * buf, size_t size, myf MyFlags)
43
44
{
44
45
  char * pos;
45
 
  DBUG_ENTER("my_getwd");
46
 
  DBUG_PRINT("my",("buf: 0x%lx  size: %u  MyFlags %d",
47
 
                   (long) buf, (uint) size, MyFlags));
48
46
 
49
47
  if (curr_dir[0])                              /* Current pos is saved here */
50
 
    VOID(strmake(buf,&curr_dir[0],size-1));
 
48
    strmake(buf,&curr_dir[0],size-1);
51
49
  else
52
50
  {
53
51
#if defined(HAVE_GETCWD)
74
72
#else
75
73
#error "No way to get current directory"
76
74
#endif
77
 
    if (*((pos=strend(buf))-1) != FN_LIBCHAR)  /* End with FN_LIBCHAR */
 
75
    if (*((pos= strchr(buf, '\0'))-1) != FN_LIBCHAR)  /* End with FN_LIBCHAR */
78
76
    {
79
77
      pos[0]= FN_LIBCHAR;
80
78
      pos[1]=0;
81
79
    }
82
80
    (void) strmake(&curr_dir[0],buf, (size_t) (FN_REFLEN-1));
83
81
  }
84
 
  DBUG_RETURN(0);
 
82
  return(0);
85
83
} /* my_getwd */
86
84
 
87
85
 
91
89
{
92
90
  int res;
93
91
  size_t length;
94
 
  char *start, *pos;
 
92
  const char *start;
 
93
  char *pos;
95
94
#if defined(VMS)
96
95
  char buff[FN_REFLEN];
97
96
#endif
98
 
  DBUG_ENTER("my_setwd");
99
 
  DBUG_PRINT("my",("dir: '%s'  MyFlags %d", dir, MyFlags));
100
97
 
101
 
  start=(char *) dir;
 
98
  start= dir;
102
99
  if (! dir[0] || (dir[0] == FN_LIBCHAR && dir[1] == 0))
103
100
    dir=FN_ROOTDIR;
104
101
#ifdef VMS
105
102
  {
106
 
    pos=strmov(buff,dir);
 
103
    pos=my_stpcpy(buff,dir);
107
104
    if (pos[-1] != FN_LIBCHAR)
108
105
    {
109
106
      pos[0]=FN_LIBCHAR;                /* Mark as directory */
113
110
    dir=buff;
114
111
  }
115
112
#endif /* VMS */
116
 
  if ((res=chdir((char*) dir)) != 0)
 
113
  if ((res=chdir(dir)) != 0)
117
114
  {
118
115
    my_errno=errno;
119
116
    if (MyFlags & MY_WME)
134
131
    else
135
132
      curr_dir[0]='\0';                         /* Don't save name */
136
133
  }
137
 
  DBUG_RETURN(res);
 
134
  return(res);
138
135
} /* my_setwd */
139
136
 
140
137
 
145
142
int test_if_hard_path(register const char *dir_name)
146
143
{
147
144
  if (dir_name[0] == FN_HOMELIB && dir_name[1] == FN_LIBCHAR)
148
 
    return (home_dir != NullS && test_if_hard_path(home_dir));
 
145
    return (home_dir != NULL && test_if_hard_path(home_dir));
149
146
  if (dir_name[0] == FN_LIBCHAR)
150
147
    return (true);
151
148
#ifdef FN_DEVCHAR