- i_len = strlen( file->d_name );
- psz_file = malloc( i_dirlen + 1 + i_len + 1 );
- sprintf( psz_file, "%s"DIR_SEP"%s", psz_dir, file->d_name );
-
- i_stat = stat( psz_file, &statbuf );
- if( !i_stat && statbuf.st_mode & S_IFDIR )
- {
- AllocatePluginDir( p_this, p_bank, psz_file, i_maxdepth - 1 );
- }
- else if( i_len > strlen( LIBEXT )
- /* We only load files ending with LIBEXT */
- && !strncasecmp( file->d_name + i_len - strlen( LIBEXT ),
- LIBEXT, strlen( LIBEXT ) ) )
- {
- int64_t i_time = 0, i_size = 0;
-
- if( !i_stat )
- {
- i_time = statbuf.st_mtime;
- i_size = statbuf.st_size;
- }
-
- AllocatePluginFile( p_this, p_bank, psz_file, i_time, i_size );
- }
+ const int pathlen = asprintf (&path, "%s"DIR_SEP"%s", psz_dir, file);
+ free (file);
+ if (pathlen == -1 || utf8_stat (path, &st))
+ continue;