| 990 | |
| 991 | |
| 992 | static find_files_result |
| 993 | find_files(THD *thd, Dynamic_array<LEX_CSTRING*> *files, |
| 994 | const Lex_ident_db *db, |
| 995 | const char *path, const LEX_CSTRING *wild) |
| 996 | { |
| 997 | MY_DIR *dirp; |
| 998 | Discovered_table_list tl(thd, files, wild); |
| 999 | DBUG_ENTER("find_files"); |
| 1000 | |
| 1001 | if (!(dirp = my_dir(path, MY_THREAD_SPECIFIC | (db ? 0 : MY_WANT_STAT)))) |
| 1002 | { |
| 1003 | if (my_errno == ENOENT && db) |
| 1004 | my_error(ER_BAD_DB_ERROR, MYF(0), db->str); |
| 1005 | else |
| 1006 | my_error(ER_CANT_READ_DIR, MYF(0), path, my_errno); |
| 1007 | DBUG_RETURN(FIND_FILES_DIR); |
| 1008 | } |
| 1009 | |
| 1010 | if (!db) /* Return databases */ |
| 1011 | { |
| 1012 | for (size_t i=0; i < dirp->number_of_files; i++) |
| 1013 | { |
| 1014 | FILEINFO *file= dirp->dir_entry+i; |
| 1015 | #ifdef USE_SYMDIR |
| 1016 | char *ext; |
| 1017 | char buff[FN_REFLEN]; |
| 1018 | if (my_use_symdir && !strcmp(ext=fn_ext(file->name), ".sym")) |
| 1019 | { |
| 1020 | /* Only show the sym file if it points to a directory */ |
| 1021 | char *end; |
| 1022 | *ext=0; /* Remove extension */ |
| 1023 | unpack_dirname(buff, file->name); |
| 1024 | end= strend(buff); |
| 1025 | if (end != buff && end[-1] == FN_LIBCHAR) |
| 1026 | end[-1]= 0; // Remove end FN_LIBCHAR |
| 1027 | if (!mysql_file_stat(key_file_misc, buff, file->mystat, MYF(0))) |
| 1028 | continue; |
| 1029 | } |
| 1030 | #endif |
| 1031 | if (!MY_S_ISDIR(file->mystat->st_mode)) |
| 1032 | continue; |
| 1033 | |
| 1034 | if (is_in_ignore_db_dirs_list(file->name)) |
| 1035 | continue; |
| 1036 | |
| 1037 | if (tl.add_file(file->name)) |
| 1038 | goto err; |
| 1039 | } |
| 1040 | } |
| 1041 | else |
| 1042 | { |
| 1043 | if (ha_discover_table_names(thd, db, dirp, &tl, false)) |
| 1044 | goto err; |
| 1045 | } |
| 1046 | if (is_show_command(thd)) |
| 1047 | tl.sort(); |
| 1048 | #ifndef DBUG_OFF |
| 1049 | else |
no test coverage detected