Fix: struct dirent has no "d_type" on MinGW/MSYS2

I found current git tree does not compile on Windows because
struct dirent has no member "d_type" on MinGW/MSYS2.
(TOYAMA Shin-ich via Tuxpaint-devel list)
This commit is contained in:
Bill Kendrick 2020-11-21 14:26:08 -08:00
parent de907326cf
commit 032c89a65e

View file

@ -19071,6 +19071,7 @@ static int do_new_dialog(void)
DIR *d; DIR *d;
struct dirent *f; struct dirent *f;
struct dirent2 *fs; struct dirent2 *fs;
struct stat sbuf;
int place; int place;
char *dirname[NUM_PLACES_TO_LOOK]; char *dirname[NUM_PLACES_TO_LOOK];
char **d_names = NULL, **d_exts = NULL; char **d_names = NULL, **d_exts = NULL;
@ -19157,7 +19158,10 @@ static int do_new_dialog(void)
{ {
f = readdir(d); f = readdir(d);
if (f != NULL && f->d_type != DT_DIR) if (f !=NULL)
{
safe_snprintf(fname, sizeof(fname), "%s/%s", dirname[places_to_look], f->d_name);
if (!stat(fname, &sbuf) && S_ISREG(sbuf.st_mode))
{ {
memcpy(&(fs[num_files_in_dirs].f), f, sizeof(struct dirent)); memcpy(&(fs[num_files_in_dirs].f), f, sizeof(struct dirent));
fs[num_files_in_dirs].place = places_to_look; fs[num_files_in_dirs].place = places_to_look;
@ -19172,6 +19176,7 @@ static int do_new_dialog(void)
} }
} }
} }
}
while (f != NULL); while (f != NULL);
closedir(d); closedir(d);