~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/default.cc

  • Committer: Brian Aker
  • Date: 2009-07-11 08:51:36 UTC
  • mfrom: (1089.3.11 merge)
  • Revision ID: brian@gaz-20090711085136-qj01nwm3qynghwtc
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <drizzled/configmake.h>
40
40
#include <drizzled/gettext.h>
41
41
 
42
 
#include <dirent.h>
 
42
#include <mysys/cached_directory.h>
43
43
 
44
44
#include <stdio.h>
45
45
#include <algorithm>
46
46
 
47
47
using namespace std;
48
48
 
49
 
 
50
49
const char *my_defaults_file=0;
51
50
const char *my_defaults_group_suffix=0;
52
51
char *my_defaults_extra_file=0;
595
594
  FILE *fp;
596
595
  uint32_t line=0;
597
596
  bool found_group=0;
598
 
  DIR *dirp;
599
 
  struct dirent dirent_entry;
600
 
  struct dirent *dirent_result;
601
597
 
602
598
  if ((dir ? strlen(dir) : 0 )+strlen(config_file) >= FN_REFLEN-3)
603
599
    return 0;                                   /* Ignore wrong paths */
674
670
                                ptr, name, line)))
675
671
          goto err;
676
672
 
677
 
        if ((dirp= opendir(ptr)) == NULL)
 
673
        CachedDirectory dir_cache(ptr);
 
674
 
 
675
        if (dir_cache.fail())
678
676
        {
679
677
          /**
680
678
           * @todo
687
685
          goto err;
688
686
        }
689
687
 
690
 
        int rc= readdir_r(dirp, &dirent_entry, &dirent_result);
 
688
        CachedDirectory::Entries files= dir_cache.getEntries();
 
689
        CachedDirectory::Entries::iterator file_iter= files.begin();
691
690
 
692
 
        while (!rc && (dirent_result != NULL))
 
691
        while (file_iter != files.end())
693
692
        {
694
 
          ext= fn_ext(dirent_entry.d_name);
 
693
          CachedDirectory::Entry *entry= *file_iter;
 
694
          ext= fn_ext(entry->filename.c_str());
695
695
 
696
696
          /* check extension */
697
697
          for (tmp_ext= (char**) f_extensions; *tmp_ext; tmp_ext++)
698
698
          {
699
699
            if (!strcmp(ext, *tmp_ext))
700
700
            {
701
 
              fn_format(tmp, dirent_entry.d_name, ptr, "",
 
701
              fn_format(tmp, entry->filename.c_str(), ptr, "",
702
702
                        MY_UNPACK_FILENAME | MY_SAFE_PATH);
703
703
 
704
704
              search_default_file_with_ext(opt_handler, handler_ctx, "", "",
706
706
            }
707
707
          }
708
708
 
709
 
          rc= readdir_r(dirp, &dirent_entry, &dirent_result);
 
709
          ++file_iter;
710
710
        }
711
711
      }
712
712
      else if ((!strncmp(ptr, include_keyword, sizeof(include_keyword) - 1)) &&