@@ -2771,14 +2771,12 @@ static dberr_t enumerate_ibd_files(process_single_tablespace_func_t callback)
2771
2771
ret = fil_file_readdir_next_file (&err, fil_path_to_mysql_datadir, dir,
2772
2772
&dbinfo);
2773
2773
while (ret == 0 ) {
2774
- size_t len = strlen (dbinfo.name );
2775
2774
2776
2775
/* General tablespaces are always at the first level of the
2777
2776
data home dir */
2778
- if (dbinfo.type == OS_FILE_TYPE_FILE && len > 4 ) {
2779
- bool is_isl = !strcmp (dbinfo.name + len - 4 , " .isl" );
2780
- bool is_ibd = !is_isl
2781
- && !strcmp (dbinfo.name + len - 4 , " .ibd" );
2777
+ if (dbinfo.type == OS_FILE_TYPE_FILE) {
2778
+ bool is_isl = ends_with (dbinfo.name , " .isl" );
2779
+ bool is_ibd = !is_isl && ends_with (dbinfo.name ," .ibd" );
2782
2780
2783
2781
if (is_isl || is_ibd) {
2784
2782
(*callback)(NULL , dbinfo.name , is_isl);
@@ -2794,7 +2792,7 @@ static dberr_t enumerate_ibd_files(process_single_tablespace_func_t callback)
2794
2792
/* We found a symlink or a directory; try opening it to see
2795
2793
if a symlink is a directory */
2796
2794
2797
- len = strlen (fil_path_to_mysql_datadir)
2795
+ size_t len = strlen (fil_path_to_mysql_datadir)
2798
2796
+ strlen (dbinfo.name ) + 2 ;
2799
2797
if (len > dbpath_len) {
2800
2798
dbpath_len = len;
@@ -2837,16 +2835,16 @@ static dberr_t enumerate_ibd_files(process_single_tablespace_func_t callback)
2837
2835
size_t len = strlen (fileinfo.name );
2838
2836
2839
2837
/* We found a symlink or a file */
2840
- if (len > 4
2841
- && ! strcmp (fileinfo. name + len - 4 ,
2842
- " .ibd" )) {
2843
- (*callback)(dbinfo.name , fileinfo.name , false );
2838
+ if (len > 4 ) {
2839
+ bool is_isl= false ;
2840
+ if ( ends_with (fileinfo. name , " .ibd " ) || ((is_isl = ends_with (fileinfo. name , " .ibd" ))))
2841
+ (*callback)(dbinfo.name , fileinfo.name , is_isl );
2844
2842
}
2845
2843
}
2846
2844
2847
2845
if (0 != os_file_closedir (dbdir)) {
2848
2846
fprintf (stderr, " InnoDB: Warning: could not"
2849
- " close database directory %s\n " ,
2847
+ " close database directory %s\n " ,
2850
2848
dbpath);
2851
2849
2852
2850
err = DB_ERROR;
0 commit comments