~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_lib.cc

  • Committer: Brian Aker
  • Date: 2009-05-23 17:13:03 UTC
  • mfrom: (1034.1.8 merge)
  • Revision ID: brian@gaz-20090523171303-d28xhutqic0xe2b4
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* TODO: check for overun of memory for names. */
17
 
/*       Convert MSDOS-TIME to standar time_t (still needed?) */
18
17
 
19
18
#include        "mysys/mysys_priv.h"
20
19
#include        <mystrings/m_string.h>
37
36
 
38
37
#if defined(HAVE_READDIR_R)
39
38
#define READDIR(A,B,C) ((errno=readdir_r(A,B,&C)) != 0 || !C)
40
 
#else
41
 
#define READDIR(A,B,C) (!(C=readdir(A)))
 
39
#else 
 
40
#error You must have a thread safe readdir() 
42
41
#endif
43
42
 
44
43
/*
90
89
  char          tmp_path[FN_REFLEN+1],*tmp_file;
91
90
  char  dirent_tmp[sizeof(struct dirent)+_POSIX_PATH_MAX+1];
92
91
 
93
 
#if !defined(HAVE_READDIR_R)
94
 
  pthread_mutex_lock(&THR_LOCK_open);
95
 
#endif
96
 
 
97
92
  dirp = opendir(directory_file_name(tmp_path,(char *) path));
98
93
  if (dirp == NULL ||
99
94
      ! (buffer= (char *) malloc(ALIGN_SIZE(sizeof(MY_DIR)) + 
145
140
  }
146
141
 
147
142
  (void) closedir(dirp);
148
 
#if !defined(HAVE_READDIR_R)
149
 
  pthread_mutex_unlock(&THR_LOCK_open);
150
 
#endif
 
143
 
151
144
  result->dir_entry= (FILEINFO *)dir_entries_storage->buffer;
152
145
  result->number_off_files= dir_entries_storage->elements;
153
146
 
157
150
  return(result);
158
151
 
159
152
 error:
160
 
#if !defined(HAVE_READDIR_R)
161
 
  pthread_mutex_unlock(&THR_LOCK_open);
162
 
#endif
 
153
 
163
154
  my_errno=errno;
164
155
  if (dirp)
165
156
    (void) closedir(dirp);
166
157
  my_dirend(result);
167
158
  if (MyFlags & (MY_FAE | MY_WME))
168
159
    my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,my_errno);
 
160
 
169
161
  return((MY_DIR *) NULL);
170
162
} /* my_dir */
171
163