~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/default.cc

  • Committer: Brian Aker
  • Date: 2009-06-29 19:56:01 UTC
  • mfrom: (1079.1.1 my_dir_removal)
  • Revision ID: brian@gaz-20090629195601-20tmdpxkyfnc2l2e
Merge David

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include "mysys/mysys_priv.h"
37
37
#include <mystrings/m_string.h>
38
38
#include <mystrings/m_ctype.h>
39
 
#include <mysys/my_dir.h>
40
39
#include <drizzled/configmake.h>
 
40
#include <drizzled/gettext.h>
41
41
 
42
42
#include <stdio.h>
 
43
#include <dirent.h>
43
44
 
44
45
const char *my_defaults_file=0;
45
46
const char *my_defaults_group_suffix=0;
589
590
  FILE *fp;
590
591
  uint32_t line=0;
591
592
  bool found_group=0;
592
 
  uint32_t i;
593
 
  MY_DIR *search_dir;
594
 
  FILEINFO *search_file;
 
593
  DIR *dirp;
 
594
  struct dirent dirent_entry;
 
595
  struct dirent *dirent_result;
595
596
 
596
597
  if ((dir ? strlen(dir) : 0 )+strlen(config_file) >= FN_REFLEN-3)
597
598
    return 0;                                   /* Ignore wrong paths */
668
669
                                ptr, name, line)))
669
670
          goto err;
670
671
 
671
 
        if (!(search_dir= my_dir(ptr, MYF(MY_WME))))
 
672
        if ((dirp= opendir(ptr)) == NULL)
 
673
        {
 
674
          /**
 
675
           * @todo
 
676
           * Since clients still use this code, we use fprintf here.
 
677
           * This fprintf needs to be turned into errmsg_printf
 
678
           * as soon as the client programs no longer use mysys
 
679
           * and can use the pluggable error message system.
 
680
           */
 
681
          fprintf(stderr, _("error: could not open directory: %s\n"), ptr);
672
682
          goto err;
673
 
 
674
 
        for (i= 0; i < (uint32_t) search_dir->number_off_files; i++)
 
683
        }
 
684
 
 
685
        int rc= readdir_r(dirp, &dirent_entry, &dirent_result);
 
686
 
 
687
        while (!rc && (dirent_result != NULL))
675
688
        {
676
 
          search_file= search_dir->dir_entry + i;
677
 
          ext= fn_ext(search_file->name);
 
689
          ext= fn_ext(dirent_entry.d_name);
678
690
 
679
691
          /* check extension */
680
692
          for (tmp_ext= (char**) f_extensions; *tmp_ext; tmp_ext++)
681
693
          {
682
694
            if (!strcmp(ext, *tmp_ext))
683
 
              break;
684
 
          }
685
 
 
686
 
          if (*tmp_ext)
687
 
          {
688
 
            fn_format(tmp, search_file->name, ptr, "",
689
 
                      MY_UNPACK_FILENAME | MY_SAFE_PATH);
690
 
 
691
 
            search_default_file_with_ext(opt_handler, handler_ctx, "", "", tmp,
692
 
                                         recursion_level + 1);
693
 
          }
 
695
            {
 
696
              fn_format(tmp, dirent_entry.d_name, ptr, "",
 
697
                        MY_UNPACK_FILENAME | MY_SAFE_PATH);
 
698
 
 
699
              search_default_file_with_ext(opt_handler, handler_ctx, "", "",
 
700
                                           tmp, recursion_level + 1);
 
701
            }
 
702
          }
 
703
 
 
704
          rc= readdir_r(dirp, &dirent_entry, &dirent_result);
694
705
        }
695
 
 
696
 
        my_dirend(search_dir);
697
706
      }
698
707
      else if ((!strncmp(ptr, include_keyword, sizeof(include_keyword) - 1)) &&
699
708
               my_isspace(&my_charset_utf8_general_ci, ptr[sizeof(include_keyword)-1]))