summaryrefslogtreecommitdiffstats
path: root/src/unix/fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/unix/fs.c')
-rw-r--r--src/unix/fs.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/unix/fs.c b/src/unix/fs.c
index 216ef97..3d478b7 100644
--- a/src/unix/fs.c
+++ b/src/unix/fs.c
@@ -346,22 +346,30 @@ done:
}
-#if defined(__OpenBSD__) || (defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_8))
-static int uv__fs_scandir_filter(uv__dirent_t* dent) {
+#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_8)
+#define UV_CONST_DIRENT uv__dirent_t
#else
-static int uv__fs_scandir_filter(const uv__dirent_t* dent) {
+#define UV_CONST_DIRENT const uv__dirent_t
#endif
+
+
+static int uv__fs_scandir_filter(UV_CONST_DIRENT* dent) {
return strcmp(dent->d_name, ".") != 0 && strcmp(dent->d_name, "..") != 0;
}
+static int uv__fs_scandir_sort(UV_CONST_DIRENT** a, UV_CONST_DIRENT** b) {
+ return strcmp((*a)->d_name, (*b)->d_name);
+}
+
+
static ssize_t uv__fs_scandir(uv_fs_t* req) {
uv__dirent_t **dents;
int saved_errno;
int n;
dents = NULL;
- n = scandir(req->path, &dents, uv__fs_scandir_filter, alphasort);
+ n = scandir(req->path, &dents, uv__fs_scandir_filter, uv__fs_scandir_sort);
/* NOTE: We will use nbufs as an index field */
req->nbufs = 0;
@@ -790,6 +798,7 @@ static void uv__to_stat(struct stat* src, uv_stat_t* dst) {
dst->st_flags = 0;
dst->st_gen = 0;
#elif !defined(_AIX) && ( \
+ defined(_GNU_SOURCE) || \
defined(_BSD_SOURCE) || \
defined(_SVID_SOURCE) || \
defined(_XOPEN_SOURCE) || \