Fix issue #162
This commit is contained in:
parent
a47c907fca
commit
a41d8c0e60
@ -481,8 +481,8 @@ int Fl_X11_System_Driver::filename_list(const char *d,
|
||||
fl_utf8to_mb(d, dirlen, dirloc, dirlen + 1);
|
||||
|
||||
#ifndef HAVE_SCANDIR
|
||||
// This version is when we define our own scandir
|
||||
int n = fl_scandir(dirloc, list, 0, sort);
|
||||
// This version is when we define our own scandir. Note it updates errmsg on errors.
|
||||
int n = fl_scandir(dirloc, list, 0, sort, errmsg, errmsg_sz);
|
||||
#elif defined(HAVE_SCANDIR_POSIX)
|
||||
// POSIX (2008) defines the comparison function like this:
|
||||
int n = scandir(dirloc, list, 0, (int(*)(const dirent **, const dirent **))sort);
|
||||
@ -504,7 +504,11 @@ int Fl_X11_System_Driver::filename_list(const char *d,
|
||||
free(dirloc);
|
||||
|
||||
if (n==-1) {
|
||||
// Don't write to errmsg if FLTK's fl_scandir() already set it.
|
||||
// If OS's scandir() was used (HAVE_SCANDIR), we return its error in errmsg here..
|
||||
#ifdef HAVE_SCANDIR
|
||||
if (errmsg) fl_snprintf(errmsg, errmsg_sz, "%s", strerror(errno));
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <stddef.h> /* For 'offsetof()', 'NULL' and 'size_t' */
|
||||
#include <limits.h> /* For 'INT_MAX' */
|
||||
#include <string.h> /* For 'memcpy()' */
|
||||
#include "flstring.h" /* For 'fl_snprintf()' */
|
||||
#if defined(HAVE_PTHREAD) && defined(HAVE_PTHREAD_H)
|
||||
# include <pthread.h>
|
||||
#endif /* HAVE_PTHREAD */
|
||||
@ -137,7 +138,7 @@ int
|
||||
fl_scandir(const char *dir, struct dirent ***namelist,
|
||||
int (*sel)(struct dirent *),
|
||||
int (*compar)(struct dirent **, struct dirent **),
|
||||
char *errmsg, int errmsg_sz) {
|
||||
char *errmsg, int errmsg_sz)
|
||||
{
|
||||
int result = -1;
|
||||
DIR *dirp;
|
||||
|
Loading…
Reference in New Issue
Block a user